• Advertisement
Sign in to follow this  

how to debug glsl shader

This topic is 2416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I need some help on debugging glsl shader.

I spent some time on the glsl debuggers listed on the wiki, and found that glsldevil is right one i need, the only one can show current values of [color=#273D49][font=arial]variables in shader at runtime.[/font]

However, glsldevil is not stable enough, and I have gone many dejected crashes.

So, everyone, any ideas to debug glsl? and I wonder how do the glsl veterans debug their shaders?

thanks in advance!!

Share this post


Link to post
Share on other sites
Advertisement
There aren't much tools for OpenGL as there is for Direct3D.
For OpenGL, you can write the value computed in your fragment shader to gl_FragColor.
You can even bind a FBO with a format of GL_RGBAF32 to get the full range of floating point values.

Share this post


Link to post
Share on other sites
Most shader debugging i've done is with "printf debugging" - that is, exiting early from the shader and returning some debug value that you can visualize to figure out what's up. Then just work your way through the shader until you figure out which calculation isn't returning what you expect, and go from there

This works better if you can hot-reload the shader while the game is running

Share this post


Link to post
Share on other sites
Thanks V-man and RDragon1. But how to do with vertex and geometry shader? it seems not convenient to directly write some thing visible in vs and gs. Is transform feedback a possible method?

Share this post


Link to post
Share on other sites

Is transform feedback a possible method?

Yes it is. In fact, that's what glslDevil uses AFAIK.

Another possibility is to channel the VS/GS data under investigation to a special debug fragment shader, which can then write the results into an FP32 target. Sometimes the geometry can be rendered as points in order to avoid problems with the interpolators of the rasterizer. Or a flat rasterization mode can be selected.

Share this post


Link to post
Share on other sites
If you are running on windows you could always look up some tools from NV or AMD depending on who made your GPU.

gDEBugger might also be an option regardless of what graphics card you are using (AMD recently brought it and integrated it into Visual Studio 2010), but I've not tried it recently myself so I don't know how well it'll do the job.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement