Live data from Hacker News

RT64: N64 graphics renderer in emulators and native ports

github.com

21–30 of 54 posts

Re: RT64: N64 graphics renderer in emulators and native ports

#21
post #4

> Uses ubershaders to guarantee no stutters due to pipeline compilation. I may sound way out of the loop here, but... How come this was never a problem for older dx9/dx11/GL games and emulators?

It was, but it was made worse by DX12/Vulkan. Previously shader stages were separate and fixed pipeline settings were loose bag of knobs. If that corresponded to hardware stages, great, everybody was happy! However, if there was mismatch between API and hardware (for example, some fixed pipeline state wasn't really hardware state but lowered to shader code) then driver needed to hack around it. If that could be done by patching the shader, it was ugly, but it worked fine. But if it required recompilation, then stutters occurred and it couldn't be prevented by application because it was all hidden from it. The solution was thought to encapsulate everything in pipeline state objects. If you could do that, excellent, no stutters no matter on what hardware it runs. It has issues however: in reality applications (especially emulators) don't always know beforehand which states they will need, previous ugly driver tricks that sometimes could have avoided recompilation by patching shaders are no longer possible, and even if the hardware does have easily switchable state API doesn't expose that leading to combinatorial explosion of state objects that was previously unnecessary. Some of that was rolled back by introducing API extensions that allow more granular switches of partial state.

Re: RT64: N64 graphics renderer in emulators and native ports

#22
post #4

> Uses ubershaders to guarantee no stutters due to pipeline compilation. I may sound way out of the loop here, but... How come this was never a problem for older dx9/dx11/GL games and emulators?

The oldest N64 emulators predate programmable shaders. They mapped possible configurations of the N64 GPU onto configurations of the host GPU. But this is really hard and some configurations are just impossible. It's basically a huge list of tricks and special cases. For reference, I think it was like 16K lines for the color combiner, which basically does (A-B)*C+D.

Re: RT64: N64 graphics renderer in emulators and native ports

#23
post #4

> Uses ubershaders to guarantee no stutters due to pipeline compilation. I may sound way out of the loop here, but... How come this was never a problem for older dx9/dx11/GL games and emulators?

Epic published a very well written article explaining what the problem is, what makes it so much worse in modern games, and why it's a uniquely difficult problem to solve.

https://www.unrealengine.com/en-US/tech-blog/game-engines-an...

Re: RT64: N64 graphics renderer in emulators and native ports

#24

Earlier quoted context omitted.

Older games used precompiled shaders. These are inaccessible to the game devs and usually handled by the hardware makers, so the platform OEM for consoles and the video card OEM on PCs. Game devs have begged for the ability to write their own shaders for years and finally got it with DX11 and Vulkan. And that's when things went to hell. Instead of the shaders being written and compiled for the specific hardware, they…

Compiling shaders directly from a high level representation to the GPU ISA only really happens on consoles. In DirectX on PC, shaders have been compiled into an intermediate form going back to Direct3D 8. All of these intermediate forms are lowered into an ISA-specific instruction set by the drivers. This final compilation step is triggered lazily when a draw happens, so if you are working on a "modern" engine that u…

> Compiling shaders directly from a high level representation to the GPU ISA only really happens on consoles.

No, that's not correct. In fact, it's mostly the other way around. Consoles have known hardware and thus games can ship with precompiled shaders. I know this has been done since at least PS2 era since I enjoy taking apart game assets.

While on PC, you can't know what GPU is in the consumer device.

For example, Steam has this whole concept of precompiled shader downloads in order to mitigate the effect for the end user.

Re: RT64: N64 graphics renderer in emulators and native ports

#25

Earlier quoted context omitted.

Compiling shaders directly from a high level representation to the GPU ISA only really happens on consoles. In DirectX on PC, shaders have been compiled into an intermediate form going back to Direct3D 8. All of these intermediate forms are lowered into an ISA-specific instruction set by the drivers. This final compilation step is triggered lazily when a draw happens, so if you are working on a "modern" engine that u…

> Compiling shaders directly from a high level representation to the GPU ISA only really happens on consoles. No, that's not correct. In fact, it's mostly the other way around. Consoles have known hardware and thus games can ship with precompiled shaders. I know this has been done since at least PS2 era since I enjoy taking apart game assets. While on PC, you can't know what GPU is in the consumer device. For example…

> Consoles have known hardware and thus games can ship with precompiled shaders. I know this has been done since at least PS2 era since I enjoy taking apart game assets.

That's what I said. Consoles ship GPU machine code, PCs ship textual shaders (in the case of OpenGL) or some intermediate representation (DXIL, DXBC, SPIRV, ...)

Re: RT64: N64 graphics renderer in emulators and native ports

#26

I guess the big test will be running Kaze Emanuar’s code through it.

For those who haven't heard, Kaze is the guy who optimized Mario 64's code, fixed some physics bugs, etc., claims roughly 6x speedup, so that he can make a mod / ROM-hack that runs smoother despite having better graphics: https://www.youtube.com/watch?v=t_rzYnXEQlE

Has he actually released it yet?

Re: RT64: N64 graphics renderer in emulators and native ports

#27
post #19
post #16

Earlier quoted context omitted.

It predates dolphin's use of it, though don't ask me by how long. Here's a reference to the term from 2008: https://realtimecollisiondetection.net/blog/?p=73

Ubershader actually has three different opposite meanings, unfortunately. The classic usage is a single source shader which is specialized using #define's and compiled down to hundreds of shaders. This is what Christer uses in that blog post above (and Aras does as well in his ubershader blog post) Dolphin used it to mean a single source shader that used runtime branches to cover all the bases as a fallback while a s…

Thank you. This is my favorite kind of comment. There are lots of "technical" terms which manage to acquire similar but distinct uses (today I was contending with "agent" and "prompt"). Keeping them straight in your own head, and recognizing when others don't is as valuable as it is unappreciated.

Re: RT64: N64 graphics renderer in emulators and native ports

#28

I guess the big test will be running Kaze Emanuar’s code through it.

For those who haven't heard, Kaze is the guy who optimized Mario 64's code, fixed some physics bugs, etc., claims roughly 6x speedup, so that he can make a mod / ROM-hack that runs smoother despite having better graphics: https://www.youtube.com/watch?v=t_rzYnXEQlE

And discovered you could disable cache writeback to have a region of fast RAM without bus contention, and ways to use the hidden 9th bit in each byte which is only usd by certain graphics framebuffer operations.

I don't think he uses either one in serious code, but if he did, good luck emulating it.

Re: RT64: N64 graphics renderer in emulators and native ports

#29
post #28

Earlier quoted context omitted.

For those who haven't heard, Kaze is the guy who optimized Mario 64's code, fixed some physics bugs, etc., claims roughly 6x speedup, so that he can make a mod / ROM-hack that runs smoother despite having better graphics: https://www.youtube.com/watch?v=t_rzYnXEQlE

And discovered you could disable cache writeback to have a region of fast RAM without bus contention, and ways to use the hidden 9th bit in each byte which is only usd by certain graphics framebuffer operations. I don't think he uses either one in serious code, but if he did, good luck emulating it.

He demos his code on both console and emulator, so there shouldn't be an issue in that regard.
Post reply on HN