I have shader developed on GeForce 6600 and can’t even get 1/3 of it’s original code to run on Radeon x850. I’ve commented-out entire code and added the following lines at the end of the fragment shader:
I run this in 1280x1024 and I get some sort of test - whenever I draw polygon it has color depending on it’s location on the screen.
When I uncomment some lines at the beginning it still works, but when I uncomment more I just get a gray surfaces. Note that the fragment shader still works, because if not the color would be different.
It doesn’t matter wchich lines I uncomment - at some piont I always get this - gl_FragCoord is simply (0.0, 0.0) on entire screen.
Ain’t that weird?
This happened on Radeon x850, bot the same shader works fine on GeForce 7800.
Out of registers? Too many instructions?
At the point when problems begin I still have 2/3 of the fragment shader commented-out. When I try to run entire shader (as it runs on GeForce) my application stops responding when rendering polygons.
At the moment I can’t post the shader code since it’s on another machine, but I can post it tomorrow on demand.
However, I’m convinced there is nothing wrong with the shader, so my question is:
Is there anything wrong with ATI’s GLSL support that I should know about in the first place?
I skipped lines that are comented-out since entire shader is a bit complex and I’m only trying to run what you see here.
This fragment shader runs fine - i get surface that has different colors over the screen.
There is one line commented-out. When I uncomment it I get a gray color all over polygons that use this shader.
Infolog says:
Link successful. The GLSL vertex shader will run in hardware. The GLSL fragment shader will run in hardware.
And the shader is active - when I change:
color.b = 0.5;
to
color.b = 0.0;
I get a brown surface.
It look like built-in uniform value gl_FragCoord doesn’t work. Maybe it gets hidden by another register when I add too much instructions/registers to shader?
I’ll send this post and try to decrease number of used registers (first of all I will remove the v_texCoord varying variables).
I’ve changed v_texCoord to gl_TexCoord[] - no effect.
Ok, I’ve changed another thing in the line that causes problems:
I’ve replaced v_pos with v_eye, so now the line is:
wave1 = -smoothstep(0.3, 1.0, wave1) + 0.4 - v_eye.y * 0.1;
Now the shader is working again.
I really get the feeling that ATI’s compiler or linker is messed up.
Ok, the shader works now on Radeon x850. It was caused by passing too many (?) varying variables from vertex shader to fragment shader. Old code has the following set of uniforms and varying variables:
gl_FragCoord will take up one interpolator, so if you’re already using 8 this will be a problem. Normally this would mean you drop into software mode, but apparently in this case the shader just got miscompiled, so it executed fine in hardware but did the wrong thing. I’ll file a bug report on it.
I found another strange stuff on my ATI 9600. When I commented out usage of texture2D () in fragment shader and let the usage of gl_TexCoord varying in pixel shader, the shader produced strange results. The solution was to comment out also usage of gl_TexCoord built-in varying. Maybe caused by some kind of shader optimalization.