ATI: no hardware support for gl_FragCoord?

When I use gl_FragCoord (.x, .z or whatever) in a fragment program, it automatically switch to software renderer… Does it means there’s no support currently for this basic built-in variable ?? That’s very annoying when you need depth to compute your pixel…

(I’m using Radeon 9800SE with catalyst 4.3)

ok I found a nice workaround. If you have this problem too and want to deal with it mail me.

gl_FragCoords works for me… so maybe its in conjunction with some other part of your programs?

what’s your hardware/driver release ?

I also have no problem with that constant, and I’m using ATI’s GLSL-implementation since the CoD-Hotfix-Catalyst (I think it was Cat3.9+) on a Radeon9700.
So I’m quite sure that your problem emerges from somewhere else. Maybe you assigned something to glFragCoord.* that caused the driver to switch to SW-mode. (Like glFragCoord.x = Noise(), where the noise-command will force the whole shader into SW-mode).

Originally posted by divide:
what’s your hardware/driver release ?
9800Pro catalyst 3.4

There is something wrong with gl_FragCoord and there are some strange side effects. The returned value is correct and the shader runs in hw, but the interpolation of varyings seems to be corrupted even in other shader objects. I’ve got a similar problem http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_t opic;f=11;t=000037 with the Radeon 9800 pro and Catalyst 4.3 .

@divide:
could you post your workaround here? Perhaps this is for more people interesting. With catalyst 4.4 there still seem something broken with gl_FragCoord support.

When I use gl_FragCoord, the programm compiles and link fine, the drivers says it should run in hardware but rendering is awful slow (as if it run in sw) and the object get rendered with white color.
This happen in my own program and with the typhoonlabs shader designer.
Modifying the 3dlabs glsl SDK example it works correct :confused:

Always with the same primitive shader:
vertex main:
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

fragment main:
gl_FragColor = gl_FragCoord;

tested on Radeon 9800 with catalyst 4.4

Originally posted by valoh:
[b]@divide:
could you post your workaround here? Perhaps this is for more people interesting. With catalyst 4.4 there still seem something broken with gl_FragCoord support.

When I use gl_FragCoord, the programm compiles and link fine, the drivers says it should run in hardware but rendering is awful slow (as if it run in sw) and the object get rendered with white color.
This happen in my own program and with the typhoonlabs shader designer.
Modifying the 3dlabs glsl SDK example it works correct :confused:

Always with the same primitive shader:
vertex main:
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

fragment main:
gl_FragColor = gl_FragCoord;

tested on Radeon 9800 with catalyst 4.4[/b]
I have test it on FX5900 with 60.72 dets and it works in hw. I have to change your FS to gl_FragColor = gl_FragCoord/100.0; and I got nice color gradient. gl_FragCoord contains window coordinates of fragment.

yooyo

Originally posted by yooyo:
I have test it on FX5900 with 60.72 dets and it works in hw. I have to change your FS to gl_FragColor = gl_FragCoord/100.0; and I got nice color gradient. gl_FragCoord contains window coordinates of fragment.

yooyo
yeah, I know. This shader shouldn’t do anything usefull, it was only for driver testing.
And unfortunately there is still a driver bug in catalyst 4.4 regarding gl_FragCoord :frowning:

I used the following “solution” to get screen space texture coords. This is obviously more expensive than reading gl_FragCoord:

VertexShader:

varying vec4 fragpos;
fragpos = gl_ModelViewProjectionMatrix * gl_Vertex;


FragmentShader:


vec2 coord=(fragpos.xy/fragpos.w+1.0)*0.5;
color=texture2D(...,coord);

The depth of the fragment is equal to fragpos.z/fragpos.w;

Ive still have no problem with gl_FragPosition and radeon 9800 pro, either in 4.3 or 4.4 drivers. no slowdown here. and ive tried them in several different programs. Make a sample application and send to ati, it seem like you got some strange but there.

Originally posted by Mazy:
Ive still have no problem with gl_FragPosition and radeon 9800 pro, either in 4.3 or 4.4 drivers. no slowdown here. and ive tried them in several different programs. Make a sample application and send to ati, it seem like you got some strange but there.
yes, this seem to be a bug which occur not under all circumstances. With the modified example from the 3dlabs sdk I didn’t had the problem.
I really love that kind of bug: find the ogl state which corrupts another. Well, Easter is just over :wink:

@Lars: Thanks, for the workaround but I had hoped somebody already had figured out which state produces this bug.
I have currently no time to strip down my code and search for the bug, but I have sent an email to ATI support with a link to this thread. Hopefully they fix it with the next catalyst version…

PolygonOffset throws my shaders into software render. i bet there is other things that can make that happend :slight_smile:

the workaround I was using for gl_FragCoord is the same as LarsMiddendorf’s

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