When I try to link the following GLSL shader on a Radeon X1250, I receive a "Fragment Shader not supported by HW" link error. It seems that the fwidth function is causes the problem (removing the function call fixes the problem), although fwidth function should be supported on all versions of GLSL. I am running the latest drivers on Windows XP Professional. Is there any way get fwidth to work, or to detect specific hardware on which it will not?
Fragment Shader
#version 120
uniform vec4 color;
varying vec2 texCoord;
void main()
{
float f = fwidth(texCoord.y);
float r = 2.0 * length( texCoord - vec2(0.5,0.5) ) + f;
gl_FragColor = color * vec4(1.0,1.0,1.0,1.0 - clamp(0.5*abs(1.0 - r)/f,0.0,1.0));
}
Solved! Go to Solution.
Hi,
Although X1250 is very old hardware, this shader should compile for it. It's possible that there's a driver bug there. Do the dFdx and dFdy functions work? If so, you can use the equivalent code:
float f = abs(dFdx(texCoord.y)) + abs(dFdy(texCoord.y));
If that doesn't work, then I'm afraid there's little we can do about it. We stopped producing new drivers for X1250 around 3 years ago. You might want to simply check the OpenGL version. If it's at least 3.0, then the user is running a Radeon HD 2000 series or newer and this code should compile fine for their hardware.
Thanks,
Graham
Hi,
Although X1250 is very old hardware, this shader should compile for it. It's possible that there's a driver bug there. Do the dFdx and dFdy functions work? If so, you can use the equivalent code:
float f = abs(dFdx(texCoord.y)) + abs(dFdy(texCoord.y));
If that doesn't work, then I'm afraid there's little we can do about it. We stopped producing new drivers for X1250 around 3 years ago. You might want to simply check the OpenGL version. If it's at least 3.0, then the user is running a Radeon HD 2000 series or newer and this code should compile fine for their hardware.
Thanks,
Graham
Thanks for your reply. I tried your suggestion, but the dFdx and dFdy functions don't seem to work either. Like with the fwidth function, the fragment shader compiles fine but then fails to link. I guess it may be better just to target OpenGL 3.0 cards.
That may be the best approach. Unless you commit to OpenGL 3.x or higher, you will be stuck with OpenGL 2.1 feature set and need to support people with old hardware and drivers. I would recommend going for OpenGL 3.2 core profile or higher as a minimum feature set for any new application. All major vendors support it in their latest drivers and you will ensure that your users will have at least somewhat up-to-date hardware and software on their systems.
Cheers,
Graham