NVIDIA Nsight Visual Studio Edition 2.2 User Guide > Graphics Debugger > Shader Debugger > How To: Set Breakpoints in a Shader

To set a breakpoint in a shader:

  1. Access the Shader Debugger.
  2. To see the source code of a specific shader, double-click on a row in the Shaders window. The document window opens, showing the corresponding source code.
  3. In the Text Editor window, move the insertion point to the line where you want the application to break.
    To set a breakpoint in a statement that spans two or more lines, move the insertion point to the last line of the statement.
  4. From the Debug menu, choose Toggle Breakpoint.
    Optionally, press the F9 key, or left-click in the left margin of the source code document.


  5. If you wish, you can also set the breakpoint as a conditional breakpoint.  
    1. Right-click on the breakpoint icon in the left margin of the source code document, or on the entry in the "Breakpoints" window, to open the Breakpoint Options dialog box.
    2. Select Conditional.
      The Conditional Breakpoint dialog box opens.
    3. Type the expression to evaluate.
    4. Click OK.
      See below for more information on setting breakpoints in shaders.

Conditional Breakpoints in Shaders

A conditional breakpoint expression can be any HLSL expression that evaluates to a Boolean result. All (scalar) operations (+, -, *, <, >, <=, ==,  ., [], type casts, swizzles … ) on local variables, global variables, and pseudo-variables (intrinsic variables) are allowed.

Limitations

Be aware of the following limitations in expressions for conditional breakpoints:

 

Additional Intrinsic Variables

There are additional intrinsic variables that you can use, depending on the kind of shader you are debugging:

Shader can use the following variables in expressions...
Vertex Shader uint @vertexId
uint @instanceId
uint @drawCallId
Geometry Shader uint @primitiveId
uint @drawCallId
Pixel Shader float3 @pixel
uint @sampleId
uint @drawCallId
Compute Shader

uint3 @groupThreadId
uint3 @groupId 
uint @dispatchId

Hull Shader uint @controlPointId
uint @drawCallId
Domain Shader uint @domainPointId
uint @drawCallId

The following macros are also supported in Compute Shaders:

#define @GroupIdx(X, Y, Z) (@groupId.x == X && @groupId.y == Y && @groupId.z == Z)

#define @ThreadIdx(X, Y, Z) (@groupThreadId.x == X && @groupThreadId.y == Y && @groupThreadId.z == Z)

 

 


NVIDIA® Nsight™ Development Platform, Visual Studio Edition User Guide Rev. 2.2.120522 ©2009-2012. NVIDIA Corporation. All Rights Reserved.