I wonder if there exists any shader prototyping framework where I can debug (on cpu) my shaders, experiment with them and instantly see results and even write unit tests. The framework does not have to emulate rendering pipeline, compute only will do.

  • $\begingroup$ If you could instantly see the results of shaders by executing them on the CPU, we wouldn't need GPUs at all! $\endgroup$
    – Dan Hulme
    Apr 11, 2018 at 12:13
  • $\begingroup$ why do you want debug it on CPU? What kind of shader do you want to prototype? $\endgroup$ Apr 11, 2018 at 13:46
  • $\begingroup$ I want to step through the code and see how my variables change. The framework does not have to be exactly hlsl/glsl/metal interpreter. Bare C++ and some facilities like texture sampling, shader intrinsic functions. It will help to develop and debug a shader and then I will port C++ implementation into the real shading language. $\endgroup$
    – ref2401
    Apr 11, 2018 at 14:01

2 Answers 2


If you really need this level of debugging (spoiler: you don't, more on that later), AFAIK only NVIDIA's NSight can provide it. However, in order to remain interactive, you probably need two machines - one to actually run your shader, and the other to debug it - because stopping a GPU for debugging will - quite understandably - freeze the display of the computer, making it unusable.

One step down from that is RenderDoc and its ability to swap shaders in a capture on the fly, as well as step through Direct3D bytecode and inspect its registers (i.e. a virtual machine for the DXBC, it's most often sufficiently detailed to actually find shader bugs).

And what most graphics programmers do most days is simply what I like to call "your mom's debugger", which on the CPU means sprinkling your code with print statements with the intention of later reviewing the log; but in shaders, you just stuff your shader outputs with debug values instead and inspect those values. There are also ways to "print text" from shaders (for instance, this ShaderToy).


If you’re comfortable working in Metal, there’s a brand-new shader debugger which does exactly what you’re after—it’ll let you step through your code while showing the values of your variables, as well as edit the code and re-run it. It’s in the Xcode 10 beta; there’s a presentation about how to use it available here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.