glLinkProgramARB hangs

I was playing with my shaders without any problem when I modified one of my fragment shader a little bit and it caused glLinkProgramARB to never return. I copy my shader hereafter to see if you find any problem.

It is interesting that if I remove any of the executable lines from my “main” function, the link operation would work fine.

The info log returns no error, I’m using a GeForce FX 6800 Ultra with the driver 71.89. I tried more recent beta drivers with the same result.

Anybody seen this before or now what’s wrong?

/sFSGlobals/
varying vec3 vertEye;
uniform vec4 cloudColor;
uniform float fMaxIntensity;
uniform sampler2D nTextIdx0;
uniform sampler2D nTextIdx1;
uniform sampler2D nTextIdx2;
uniform sampler2D nTextIdx3;
/sFSSkyGlobals/
uniform vec2 sunPosScreen;
uniform float fSunCoreRadius;
uniform float fSunHaloRadius;
uniform float fSun2ndDiskRadius;
uniform float fSunRaysRadius;
uniform vec3 fSunColor;
uniform float fNumRays;
uniform float fSun2ndDiskInt;
uniform float fSunRaysInt;
/sFSFogExp2/
uniform float fGroundFogVisInv;
uniform float fGroundFogExp;
float fnFogProp(float fDist)
{
return ( 1.-pow(2.7172, -fGroundFogExpfDistfGroundFogExpfDist));
}
/sFSFog/
varying float vertDist;
varying float fVh;
uniform float fLocalH;
uniform float fFogAlt;
uniform vec4 stGroundFogColor;
float fFogProp;
vec4 mixFogColor;
void fnFog()
{
float fDeltaH = abs(min(fFogAlt, fLocalH) - min(fFogAlt, fVh));
float fDistEffective = max(fDeltaH, 1.) * vertDist / max(abs(fLocalH-fVh), 1.);
fDistEffective = step( step(fFogAlt,fVh) * step(fFogAlt,fLocalH), 0.5 );
fFogProp = fnFogProp(fDistEffective);
mixFogColor = stGroundFogColor;
}
/sFSPlastic/
void main(void)
{
gl_FragColor = gl_Color;
/sFSHPClouds/
vec4 HPTexColor = texture2D(nTextIdx3, vec2(gl_TexCoord[3]));
gl_FragColor = mix(gl_FragColor, cloudColor, HPTexColor);
/sFSSun/
vec3 sunColor;
sunColor = fSunColor / fMaxIntensity;
float fDist = distance(vec2(gl_FragCoord), sunPosScreen);
float sunProp = min(max(fDist-fSunCoreRadius,0.)/fSunHaloRadius,1.);
gl_FragColor.rgb = mix(sunColor,gl_FragColor.rgb, sunProp);
float f2ndDiskInt = max(sin(min(fDist,1.5
fSun2ndDiskRadius)1.57/(1.1fSun2ndDiskRadius))-0.998, 0.)1./(1.-0.998);
gl_FragColor.rgb = mix(gl_FragColor.rgb, sunColor, fSun2ndDiskInt
f2ndDiskInt);
float fTheta = atan(gl_FragCoord.y-sunPosScreen.y, gl_FragCoord.x-sunPosScreen.x);
float fSpikesInt = abs(sin (fNumRays
fTheta));
fSpikesInt = pow(fSpikesInt, 575.);
fSpikesInt = pow(fSunRaysRadius(abs(sin(5.fTheta))+0.2)/fDist, 3.);
gl_FragColor.rgb = mix(gl_FragColor.rgb, sunColor, fSpikesInt
fSunRaysInt);
fnFog();
gl_FragColor.rgb = mix(gl_FragColor, mixFogColor, fFogProp);
/sColorLimitedEnd/
gl_FragColor.rgb *= fMaxIntensity;
}

I’ve reproduced the problem with Cg. It cames to the abuse of reusing gl_FragColor. Uses a temporary variable instead.
Try this

  
/*sFSPlastic*/
void main(void)
{ 
vec4 FragColor;
FragColor = gl_Color;
/*sFSHPClouds*/
vec4 HPTexColor = texture2D(nTextIdx3, vec2(gl_TexCoord[3]));
FragColor = mix(FragColor, cloudColor, HPTexColor);
/*sFSSun*/
vec3 sunColor;
sunColor = fSunColor / fMaxIntensity;
float fDist = distance(vec2(gl_FragCoord), sunPosScreen);
float sunProp = min(max(fDist-fSunCoreRadius,0.)/fSunHaloRadius,1.);
FragColor.rgb = mix(sunColor,FragColor.rgb, sunProp);
float f2ndDiskInt = max(sin(min(fDist,1.5*fSun2ndDiskRadius)*1.57/(1.1*fSun2ndDiskRadius))-0.998, 0.)*1./(1.-0.998);
FragColor.rgb = mix(FragColor.rgb, sunColor, fSun2ndDiskInt*f2ndDiskInt);
float fTheta = atan(gl_FragCoord.y-sunPosScreen.y, gl_FragCoord.x-sunPosScreen.x);
float fSpikesInt = abs(sin (fNumRays*fTheta));
fSpikesInt = pow(fSpikesInt, 575.);
fSpikesInt *= pow(fSunRaysRadius*(abs(sin(5.*fTheta))+0.2)/fDist, 3.);
FragColor.rgb = mix(FragColor.rgb, sunColor, fSpikesInt*fSunRaysInt);
fnFog();
FragColor.rgb = mix(FragColor.rgb, mixFogColor.rgb, fFogProp);
/*sColorLimitedEnd*/
FragColor.rgb *= fMaxIntensity;
gl_FragColor = FragColor;
}

Really? That’s interesting. Do you have any idea on why reusing the same label multiple times would be a problem?

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