How to debug a compute shader
Compute shaders are cool – at least, until you run into some kind of trouble.
While you can easily attach a debugger to the CPU code to see what’s going on, the GPU side is harder to check. A mistake in a fragment shader may cause distorted graphics, providing some hint for where the bug lies, but in other cases, you might see just nothing. In addition to undoing the latest changes, you can always attach a debugging tool like RenderDoc and check out what’s going wrong with the usual shader types.
But, while RenderDoc has experimental support for compute shader debugging, this support is still limited. So, in contrast to other shader types, a compute shader is mostly a “black box” for us with RenderDoc – a program receiving and outputting opaque data.
Depending on your GPU, you might want to try out NVIDIA Nsight (for NVIDIA GPUs) or the AMD Radeon GPU Profiler (for AMD GPUs). Links to all three tools...