Game Development Community

Techniques for debugging shaders...

by Joshua "The Power Nap" Taylor · in Torque Game Engine · 10/05/2003 (10:49 am) · 6 replies

Anyone who has worked with shaders knows what a pain they are to debug. Right now I've been dealing with my GeForce4 MX440's limited register combiners.

As of this posting, whenever I actually try and write a value to the screen, the Torque quits out. I'm running a vertex program on top of it, but that works fine. It's not untill I try and proccess the fragment and write it to the screen that I have issues.

What I would like to know is, are there any resources for debugging these things? I know that you can get a parse error list from the API, but I've had this vertex/reg-combiner combo working fine in a stand alone app.

#1
10/05/2003 (11:34 am)
There is a shader debugger that you can set up for use with DirectX, but I don't know of anything like that for OpenGL.
#2
10/05/2003 (11:58 am)
Is there a site where I can go and see it?

I mean, it might be for DirectX, but it might have techniques that are cross platform. In all honesty, I'd just be happy for a list of things that will and won't work with register combiners.

Seeing as my stand alone app works with what I've done, I'd be curious to know if the enviroment mapping was to blame.

I am implementing this on the meshes in the Torque.
#3
10/05/2003 (12:38 pm)
Sadly, it's not for OpenGL. It requires the Direct X SDK and uses DX's reference rasterizer for the actual debugging. (AFAIK, there's no way to 'step' fragment/vertex programs once they've been sent to the GPU.)

My suggestion would be to simplify the code until you can get it to work and then work up from there.
#4
10/05/2003 (12:46 pm)
Well,

it is fairly basic. I've gone through line by line, and it only goes nuts when I add the final write to the output register.
#5
10/06/2003 (2:11 pm)
What problems are you having? Compilation? Only black colors? Random colors? Shape just not there?

If it's "dying" only when you write out, it's probably not actually compiling. Have you tried actually compiling the shader outside of the app?

Fragment programs have many many restrictions put on them that are sometimes very hard to avoid. The MX series is also limited in their shader support, and you must just running into one of those limitations.

Oh, and I don't think there's really a "debugger" for shaders. Just write out debug colors until you get what you want in each step of the calculations. That's the least painful way I've figured out so far, at least.
#6
10/06/2003 (9:29 pm)
I had it working in a stand alone app,

I don't know if the other effects in OpenGL are effecting it or not, but I can't come up with a solution as of yet.