Fragment Program Debugging Tools - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Fragment Program Debugging Tools

Description:

Color channel masking. Arbitrary code for visualization. Allows scale and bias of values ... Handy reference guide, resource manager. Texture editor ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 28
Provided by: gpg9
Category:

less

Transcript and Presenter's Notes

Title: Fragment Program Debugging Tools


1
Fragment Program Debugging Tools
  • Tim Purcell Stanford / NVIDIA

2
Motivation
  • Everyone writes code with bugs
  • For me personally, more often than I care to
    admit
  • Debugging fragment programs is currently very
    painful

3
Programming Soap Box
  • Successful programming systems require at least
    three tools
  • Compiler
  • Cg, HLSL, GLslang, RTSL, Brook
  • Debugger
  • Profiler

4
Debugging State of the Art
  • printf debugging
  • MOV suspect register to output
  • Comment out anything else writing to output
  • Scale and bias as needed
  • Recompile
  • Display/readback frame buffer
  • Check values
  • Repeat until error is (hopefully) found

5
printf Debugging Examples
6
printf Debugging Examples
7
printf Debugging Examples
8
printf Debugging Examples
9
Ideal Fragment Program Debugger
  • Automate printf debugging
  • Intuitive and easy to use interface
  • Features over performance
  • Debuggers dont need to be fast
  • Easy to add to existing apps
  • And remove
  • Touch as little GPU state as possible
  • Report actual hardware values
  • No software simulations!

10
Debugger Features
  • Per-pixel register watch
  • Including interpolants, outputs, etc.
  • Breakpoints
  • Fragment program interpreter
  • Single step forwards or backwards
  • Execute modified code on the fly
  • And save it

11
Debugger Features - Visualization
  • Display register value at each pixel
  • Color channel masking
  • Arbitrary code for visualization
  • Allows scale and bias of values
  • Multiple visualization windows
  • Visualize each source register and result
  • MUL R2, R1, R0

12
Debugging Options Today
  • Microsoft Shader Debugger Tool
  • Apple OpenGL Shader Builder
  • Imdebug The Image Debugger B. Baxter
  • Shadesmith T. Purcell, P. Sen

13
Microsoft Shader Debugger Tool
  • Pros
  • Direct3D debugging integrated into Visual Studio
    IDE
  • Full featured
  • Assembly and high level debugging
  • Vertex and fragment programs
  • Watches, breakpoints, etc.
  • Cons
  • Only works with software rasterizer
  • Slow and painful
  • D3D only
  • Shader changes require recompilation

14
Apple OpenGL Shader Builder
  • Pros
  • Integrated development environment
  • Handy reference guide, resource manager
  • Texture editor
  • On the fly edit and display of shader changes
  • Cons
  • Canned geometry
  • Basically a shader tool (in the traditional
    sense)
  • not GPGPU debugger
  • ARB vertex/fragment programs only
  • No vendor specific GL extensions support?

15
imdebug
  • Printf-style debugger
  • imdebug("rgb wd hd p", 16, 17, testRGB)
  • Readback memory (texture/frame buffer) and
    display in image window

16
imdebug
17
imdebug
  • Pros
  • Simple addition of single printf-style statement
    to programs
  • Displays hardware computed values not software
    generated values
  • Scale and bias
  • Source available for download
  • Cons
  • Cant breakpoint shaders
  • Can only watch what shader outputs

18
Shadesmith
  • Debugger in the spirit of imdebug
  • Simply add a debug statement when binding shaders
  • Display window with scale, bias, component
    masking
  • Advanced features
  • Can watch any shader register contents without
    recompile
  • Shader single stepping (forward and backward),
    breakpointing
  • Shader source edit and reload without recompile

19
Shadesmith Demo
20
Shadesmith Implementation Insight
  • Only one register modified per instruction
  • Ignore CC for now
  • Decompose fragment program into several smaller
    programs
  • One program per assembly instruction
  • Save register state on host
  • Two approaches
  • Load/store
  • Iterative deepening

21
1. Load / Store Style
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 TEX
R2, R1, TEX0, RECT ...
22
1. Load / Store Style
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 TEX
R2, R1, TEX0, RECT ...
TEX R0, fWPOS, TEX0, RECT TEX R2, fWPOS,
TEX1, RECT TEX R3, fWPOS, TEX2, RECT MAD R1,
R0, R2, R3 MOV oCOLR, R1 END
Interferes with existing texture state
23
2. Iterative Deepening Style
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 TEX
R2, R1, TEX0, RECT ...
24
2. Iterative Deepening Style
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 TEX
R2, R1, TEX0, RECT ...
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 MOV
oCOLR, R1 END
25
2. Iterative Deepening Style
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 TEX
R2, R1, TEX0, RECT ...
... ADD R0, R1, fWPOS MAD R1, R0, R2, R3 TEX
R2, R1, TEX0, RECT MOV oCOLR, R2 END
Later code more expensive than early code
26
Basic Shadesmith Flow
  • Decompose program into smaller programs
  • Use iterative deepening approach
  • Run programs required to determine watch values
  • One program per value watched
  • Readback modified register to host
  • Via glReadPixels()
  • Display register values per pixel
  • Visualization windows
  • Per-pixel values on mouseover

27
Future Work
  • Occlusions from multiple fragments
  • GL trace playback debugging
  • Reproducible bugs
  • Eliminate need to drive app. and debugger
  • Vertex programs
  • Branching
  • Basic OpenGL debugging
  • Why is my screen black?
Write a Comment
User Comments (0)
About PowerShow.com