<p>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.</p>

<p>One step down from that is <a href="http://www.renderdoc.org/" rel="nofollow noreferrer">RenderDoc</a> 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).</p>

<p>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, <a href="https://www.shadertoy.com/view/4dtGD2" rel="nofollow noreferrer">this ShaderToy</a>).</p>

CC BY-SA 3.0
2018-04-13T20:50:19.290Z
2018-04-13T20:50:19.290Z
IneQuation
<p>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 <a href="https://developer.apple.com/videos/play/wwdc2018/608/" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2018-06-13T17:50:38.483Z
2018-06-13T17:50:38.483Z
Noah Witherspoon
<p>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.</p>

CC BY-SA 3.0
2018-04-11T12:13:58.367Z
If you could instantly see the results of shaders by executing them on the CPU, we wouldn't need GPUs at all!
Dan Hulme
CC BY-SA 3.0
2018-04-11T13:46:01.773Z
why do you want debug it on CPU? What kind of shader do you want to prototype?
Seyed Morteza Kamali
CC BY-SA 3.0
2018-04-11T14:01:34.223Z
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.
ref2401
<shader>
Shader Prototyping Frameworks
ref2401
# Shader Prototyping Frameworks

(Asked by: username_0 on 2018-04-11)

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.

**Tags:** shader

> **Comments:**
> **username_1**: If you could instantly see the results of shaders by executing them on the CPU, we wouldn't need GPUs at all!  
> **username_2**: why do you want debug it on CPU? What kind of shader do you want to prototype?  
> **username_0**: 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.  

---

## 2 answers

### Answer by username_3 on 2018-04-13. Score: 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](http://www.renderdoc.org/) 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](https://www.shadertoy.com/view/4dtGD2)).


---

### Answer by username_4 on 2018-06-13. Score: 0

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](https://developer.apple.com/videos/play/wwdc2018/608/).


---

