Catalyst 3.7 broke my fragment programs

I upgraded my ATi graphics driver from Catalyst 3.6 to 3.7, and suddenly my shadow mapping fragment program isn’t working anymore.

I’m using Cg’s cgc compiler to compile the fragment program.

My program samples a shadowmap at the 4 nearest texels and lerps between them. It then calculates a shadow factor, which is multiplied by diffuse lighting and then the base texture to produce a lit, shadowed, textured mesh. At least, that’s what it did with Cat 3.6. With Catalyst 3.7, it produces a plain white mesh.

In an effort to find out where the shader was going wrong, I separated out the separate parts of the program.

First, I isolated the shadow calculation in order to produce an unlit, untextured mesh with shadows:

float3 baseCol=tex2D(baseTex,texCoord).xyz;
smTexCoord.xy -= float2(halfOverShadowmapSize,halfOverShadowmapSize);

float xj = frac(smTexCoord.xshadowmapSize); //x offset within texel
float yj = frac(smTexCoord.y
shadowmapSize); //y offset within texel
float d = oneOverShadowmapSize;

float4 ts;
ts.x=step( smTexCoord.z, tex2D(shadowMap,float2(smTexCoord.x, smTexCoord.y)).r);
ts.y=step( smTexCoord.z, tex2D(shadowMap,float2(smTexCoord.x+d, smTexCoord.y)).r);
ts.z=step( smTexCoord.z, tex2D(shadowMap,float2(smTexCoord.x, smTexCoord.y+d)).r);
ts.w=step( smTexCoord.z, tex2D(shadowMap,float2(smTexCoord.x+d, smTexCoord.y+d)).r);

float sa=lerp(ts.x, ts.z, yj);
float sb=lerp(ts.y, ts.w, yj);
float shadowFactor=lerp(sa,sb,xj);

    //simply output the shadowfactor (black/white with no lighting or texture)
    color.rgb=shadowFactor;
    color.a=1.0;

This worked as expected.

I then tested my diffuse lighting calculations, setting the shadowFactor to 1 in all cases. This produced a diffuse lit, textured mesh, with no shadows, as expected.

float shadowFactor=1;

  float3 L = normalize(lightPosition - P).xyz;
  float diffuseLight = max(dot(L, N), 0);
  float3 diffuse = Kd * lightColor * diffuseLight;

//get the final colour
color.xyz=baseCol*(diffuse*shadowFactor+Ka);

I’ve verified both the shadowing code and the diffuse lighting code to be correct (and clearly they both worked fine before the driver upgrade), and yet when I combine them, the code fails.

I know that the Cg compiler will be optimises out code which doesn’t effect the final output, so the final program with all calculations will be significantly longer, but it is within the 9700 Pro’s native limits, and as I said above, it worked fine before.

Has anyone else experienced similar problems?

[This message has been edited by bunny (edited 09-11-2003).]

I got some problems with Cg generated fragments in ATI hardware with Catalyst 3.6 & 3.7. I submited a small repro demo to them and then they told me they have solved those problems (the fix will be available in a future driver version).
I recommend you to send them (devrel@ati.com) a small demo with the problem as it seems that they are doing a good work.

Hope this helps.

[This message has been edited by Cab (edited 09-12-2003).]