Search Unity

Visual Studio Graphics Analyzer - Skipping shader's lines of code, variables "Not in scope"

Discussion in 'Editor & General Support' started by Lipoly, Jul 28, 2017.

  1. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    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 that's 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.
     
  2. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    Update:
    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.
     
  3. PlanarBit

    PlanarBit

    Joined:
    Jul 22, 2016
    Posts:
    20
    Experiencing exactly same issue (Unity 2018.3, Visual Studio 2017).
    Anyone happen to find solution/workaround?

    BTW:
    Went through some alternatives - RenderDoc, NVIDIA Nsight Visual Studio Edition, MS PIX.
    None of them provided HLSL debugging capability.
    Probably something happened with Unity HLSL generation/optimization (because this worked previously with Visual Studio Graphics Debugger).
     
    Last edited: Apr 16, 2019
    SKoptev likes this.