by zubspace · 4y ago · 0 comments
The most common cause for errors in my shader code are values outside of the expected range or matrix transformation errors where I have to go through them step by step on paper...
So, how do you debug shaders? Is there a reliable tool which actually helps? Or am I missing something?
I haven't used it alot, but it was quite excellent out of the box for me. I needed to pass some debug flags to shader compilation - and it was only automatically able to capture output to the screen buffer as far as i remember. But there is an api to integrate it if you want offscreen target debugging i think.
For game console development you have access to world-class shader debuggers that let you step through the raw shader assembly on the GPU at the hardware level (so you can see the individual waves/threads and register values).
In practice shader debugging only sucks in OpenGL (vulkan is not great, but is closer to ideal). In Direct3D it's totally fine. This is partly due to Direct3D having well-specified semantics and always having a reference rasterizer, so a debugger can use refrast to do accurate shader step-through (unless you hit driver bugs).
The Graphics Debugger that's integrated into Visual Studio also has a shader debugger (for D3D/HLSL).
RenderDoc allows shader debugging for some backends, although I currently don't remember which one (either D3D, GL or Vulkan).
Nvidia has the NSIGHT debugger, which AFAIK exists both as standalone tool and integrated into Visual Studio and also allows to step through shader code.
Game consoles usually come with their own graphics debugging tools.
Works fine for some things, but I've definitely dead-ended on others, no way I could think of to inspect.
The problem with Khronos standards is that they always let the community fix their lack of tooling, so the best you can hope for is vendor specific debugging tools, or something like RenderDoc, which isn't as feature rich.
I've only done very basic shader stuff, but it helped me when I got stuck.