2
$\begingroup$

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.

$\endgroup$
  • $\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 '18 at 12:13
  • $\begingroup$ why do you want debug it on CPU? What kind of shader do you want to prototype? $\endgroup$ – Seyed Morteza Kamali Apr 11 '18 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 '18 at 14:01
2
$\begingroup$

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).

$\endgroup$
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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