I’m using the Debug->Graphics->Start Graphics Debugging feature in Visual Studio to kick off the graphics analyzer.
My issue is that when stepping through shader code, a whole lot of variables show up as “Not in scope” when hovered over, and even more importantly perhaps is that large portions of the code are simply skipped over when stepping through code. I’m guessing that maybe there is some optimization going on which changes the flow of code? If so, it would be helpful to turn off during development/debugging if thats the case.
Workflow/info:
- I have an empty C++ VS project setup
to start the Unity editor when I
start graphics debugging. - The shaders have the
enable_d3d11_debug_symbols define
enabled. - I capture a frame from within the VS
graphics analyzer, then select a
pixel to debug. - I drill down to the appropriate
Pixel/Vert shader and click the
green arrow which opens up the
associated shader source file and
begin debugging.
Overall, I’m using the technique described here, except I’m simply running the Unity Editor through Visual Studio instead of making a standalone build…this speeds up testing changes as I don’t need to constantly do builds to see changes.
Debugging works as expected aside from many variables not being in scope to inspect, and skipping over (sometimes) significant portions of code, but those are pretty large issues as they keep me from getting insight into how pretty big chunks of the code is working.
Any help would be greatly appreciated.
Edit
I got a response over on MSDN suggesting to pass the shader compiler the D3DCOMPILE_SKIP_OPTIMIZATION flag. I have also seen it suggested to additionally use D3DCOMPILE_PREFER_FLOW_CONTROL and D3DCOMPILE_DEBUG (although Unity’s enable_d3d11_debug_symbols may already do this one).
Does anyone know how to pass shader compiler flags in Unity? I might make a new question to directly ask this question.