Game Development Reference
In-Depth Information
of the breakpoint. Once halted, the state of the program and the state of the
hardware can be examined in detail.
Parallel Nsight allows source breakpoints to be set in HLSL source code using
the standard Visual Studio keybindings and mouse gestures by either left-clicking
at the left of the line of source, or by using the Debug
>
Toggle Breakpoint menu
item.
Parallel Nsight also supports parallel and graphics-aware conditional break-
points, in which a breakpoint only halts at a line of source if a user-supplied
conditional expression evaluates to true. Using conditional breakpoints in Par-
allel Nsight is an incredibly powerful way to debug highly parallel problems on the
GPU, as using a parallel-aware expression can allow you to stop the execution of
GPU on exactly the graphics primitives or threads desired.
For example, take the following pixel shader:
PS_OUTPUT RenderScenePS( VS_OUTPUT In,
uniform bool bTexture )
{
PS_OUTPUT Output;
// Lookup mesh texture and
// modulate it with diffuse
if( bTexture )
Output.RGBColor = tex2D(MeshTextureSampler,
In.TextureUV)
* In.Diffuse;
else
Output.RGBColor = In.Diffuse;
return Output;
}
If this shader at times appears to generate fragments with the red component
incorrectly high, simply add a breakpoint to the last line of the shader, and then
add a conditional expression to the breakpoint:
Output.RGBColor.r > .9
This breakpoint will only break when that shader is executed and when the
color values' red component has a value greater than .9. You can specify complex
conditionals and still maintain great performance because everything is evaluated
in hardware. There is virtually no penalty for conditionals.
Stepping through shader or compute code. Another key feature of a source
debugger is the ability to step line by line over subsequent lines of code, once halted
at a breakpoint. Stepping in this fashion allows a developer to debug control logic,
Search WWH ::




Custom Search