Well we just had a bit of a firedrill when we learned that gl_FragCoord causes some ATI cards on windows to revert to software shading. I don't know if this is fixed in a driver upgrade - we used a simple workaround suggested by a user on gamedev.net:
- We store the clip-space coordinate in a varying variable. (We have to compute that anyway, it's just the result of ftransform()).
- We then perform a perspective divide and change the coordinate range in the fragment shader.
Fortunately we wanted the screen coordinate as 0..1 so having clip coordinates is almost what we want anyway. The perspective divide must be per-pixel - varying variables only interpolate in a perspective-correct manner in homogenous clip coordinates, not window coordinates. At least, I think. :-)
This is a case where "the Google" comes in really handy -- having confirmation from other users of a known bug gives us a lot more confidence in the workaround.
I had some trouble with this until I found this paper:
ReplyDeletehttp://www.google.com/url?sa=t&ct=res&cd=20&url=http%3A%2F%2Fdeveloper.amd.com%2Fmedia%2Fgpu_assets%2FATI_OpenGL_Programming_and_Optimization_Guide.pdf&ei=PUKHSPnjHqLQiAHFrqybBQ&usg=AFQjCNFProzLiXf5Aqqs4jZ2jOb4x0pssg&sig2=V6gD5mpE9P3kM8LFQUnknw
It mentions that increasing point size or line widths will cause this issue. I'm glad that this didn't require changing the shader itself.