Debug fragment/vertex programs

Does anyone know how to debug asm vertex or fragment programs? thanks!

You can debug vertex programs on a Macintosh – there is a tool called “OpenGL Shader Builder” which lets you step through the shader instruction-by-instruction.

The only way I’ve found to debug a fragment program is to stop it part-way through processing and output an intermediate result as the color. Then, based on the color, you can get some idea of what kinds of values you have. Very, very tedious, though.

The only addition I have to OneSadCookie’s post is that you may want to use floating point render targets(only pbuffers for now) while ‘debugging’ instead of your regular 32bit framebuffer. The reason for this is clamping. The floating point buffer doesn’t clamp[0.0-1.0] color values, which can really help at times. However, if your intermediate values are always in the [0-1] range using an fp buffer wont help much.

When I debug shader code I usually use blocks like these:

 // fp_pbuffer.enable()
 glEnable(..)
 glTransforms()
 ...
 glDrawXXX()

 glReadPixels(..)
 // fp_pbuffer.disable()

And just enable the fp pbuffer when I need to debug the shader.

There’s also some debugging capabaility in Mesa, see

http://freedesktop.org/cgi-bin/viewcvs.cgi/mesa/Mesa/docs/MESA_program_debug.spec

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.