PDA

View Full Version : ATI: no hardware support for gl_FragCoord ??



divide
03-30-2004, 07:23 AM
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)

divide
04-03-2004, 06:50 AM
ok I found a nice workaround. If you have this problem too and want to deal with it mail me.

Mazy
04-03-2004, 07:00 AM
gl_FragCoords works for me.. so maybe its in conjunction with some other part of your programs?

divide
04-03-2004, 07:45 AM
what's your hardware/driver release ?

PanzerSchreck
04-03-2004, 08:24 AM
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).

Mazy
04-03-2004, 09:24 AM
Originally posted by divide:
what's your hardware/driver release ?9800Pro catalyst 3.4

LarsMiddendorf
04-04-2004, 02:21 AM
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 (http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=11;t=000037) with the Radeon 9800 pro and Catalyst 4.3 .

valoh
04-18-2004, 04:08 PM
@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

yooyo
04-19-2004, 09:04 AM
Originally posted by valoh:
@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.4I 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

valoh
04-19-2004, 09:29 AM
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.

yooyoyeah, 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 :(

LarsMiddendorf
04-19-2004, 09:31 AM
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;

Mazy
04-19-2004, 09:44 AM
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.

valoh
04-19-2004, 10:34 AM
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 ;)

@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...

Mazy
04-19-2004, 12:24 PM
PolygonOffset throws my shaders into software render. i bet there is other things that can make that happend :)

divide
04-20-2004, 06:33 AM
the workaround I was using for gl_FragCoord is the same as LarsMiddendorf's