# ATI: no hardware support for gl\_FragCoord?

**URL:** <https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893>\
**Category:** OpenGL\
**Tags:** glsl\
**Created:** [March 30, 2004, 6:23am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893 "2004-03-30T06:23:00Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![divide](https://community.khronos.org/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@divide](https://community.khronos.org/u/divide)\
**Post date:** [March 30, 2004, 6:23am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/1 "2004-03-30T06:23:00Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![divide](https://community.khronos.org/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@divide](https://community.khronos.org/u/divide)\
**Post date:** [April 3, 2004, 5:50am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/2 "2004-04-03T05:50:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mazy](https://community.khronos.org/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@Mazy](https://community.khronos.org/u/Mazy)\
**Post date:** [April 3, 2004, 6:00am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/3 "2004-04-03T06:00:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![divide](https://community.khronos.org/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@divide](https://community.khronos.org/u/divide)\
**Post date:** [April 3, 2004, 6:45am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/4 "2004-04-03T06:45:00Z")

</div>

what’s your hardware/driver release ?

---

<div class="post-metadata">

**Author:** ![PanzerSchreck](https://community.khronos.org/user_avatar/community.khronos.org/panzerschreck/32/3841_2.png) [@PanzerSchreck](https://community.khronos.org/u/PanzerSchreck)\
**Post date:** [April 3, 2004, 7:24am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/5 "2004-04-03T07:24:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mazy](https://community.khronos.org/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@Mazy](https://community.khronos.org/u/Mazy)\
**Post date:** [April 3, 2004, 8:24am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/6 "2004-04-03T08:24:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LarsMiddendorf](https://community.khronos.org/letter_avatar_proxy/v4/letter/l/94ad74/32.png) [@LarsMiddendorf](https://community.khronos.org/u/LarsMiddendorf)\
**Post date:** [April 4, 2004, 1:21am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/7 "2004-04-04T01:21:00Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![valoh](https://community.khronos.org/letter_avatar_proxy/v4/letter/v/8dc957/32.png) [@valoh](https://community.khronos.org/u/valoh)\
**Post date:** [April 18, 2004, 4:08pm UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/8 "2004-04-18T16:08:00Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![yooyo](https://community.khronos.org/user_avatar/community.khronos.org/yooyo/32/62_2.png) [@yooyo](https://community.khronos.org/u/yooyo)\
**Post date:** [April 19, 2004, 9:04am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/9 "2004-04-19T09:04:00Z")

</div>

> 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 😕

> 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

---

<div class="post-metadata">

**Author:** ![valoh](https://community.khronos.org/letter_avatar_proxy/v4/letter/v/8dc957/32.png) [@valoh](https://community.khronos.org/u/valoh)\
**Post date:** [April 19, 2004, 9:29am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/10 "2004-04-19T09:29:00Z")

</div>

> 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 ☹

---

<div class="post-metadata">

**Author:** ![LarsMiddendorf](https://community.khronos.org/letter_avatar_proxy/v4/letter/l/94ad74/32.png) [@LarsMiddendorf](https://community.khronos.org/u/LarsMiddendorf)\
**Post date:** [April 19, 2004, 9:31am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/11 "2004-04-19T09:31:00Z")

</div>

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

```auto
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;

---

<div class="post-metadata">

**Author:** ![Mazy](https://community.khronos.org/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@Mazy](https://community.khronos.org/u/Mazy)\
**Post date:** [April 19, 2004, 9:44am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/12 "2004-04-19T09:44:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![valoh](https://community.khronos.org/letter_avatar_proxy/v4/letter/v/8dc957/32.png) [@valoh](https://community.khronos.org/u/valoh)\
**Post date:** [April 19, 2004, 10:34am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/13 "2004-04-19T10:34:00Z")

</div>

> 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…

---

<div class="post-metadata">

**Author:** ![Mazy](https://community.khronos.org/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@Mazy](https://community.khronos.org/u/Mazy)\
**Post date:** [April 19, 2004, 12:24pm UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/14 "2004-04-19T12:24:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![divide](https://community.khronos.org/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@divide](https://community.khronos.org/u/divide)\
**Post date:** [April 20, 2004, 6:33am UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/15 "2004-04-20T06:33:00Z")

</div>

the workaround I was using for gl\_FragCoord is the same as LarsMiddendorf’s

---

<div class="post-metadata">

**Author:** ![system](https://community.khronos.org/uploads/default/original/2X/b/ba89cb49313a0e869198c8be354afde8bcae027e.png) [@system](https://community.khronos.org/u/system)\
**Post date:** [October 19, 2021, 7:53pm UTC](https://community.khronos.org/t/ati-no-hardware-support-for-gl-fragcoord/51893/16 "2021-10-19T19:53:44Z")

</div>

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