Nested loop issue

Hi All,

I’ve run into an interesting problem after upgrading from NVidia driver 280.26 to 301.42 on a GTX 460. I’ve got a glsl shader performing a texture lookup in a nested loop, somewhat along these lines:


uniform int maxCurGMM;
uniform int maxCurMean;

float result = -1.0;
float minDistanceSq = 1000.0;

for (int i = 0; i < maxCurGMM; i++) 
{
    for (int j = 0; j < maxCurMean; j++) 
    {
        vec3 val = texture2D(sGMMTex, vec2((j+0.5)/maxCurMean, (i+0.5)/maxCurGMM)).xyz;
        float colDist = <some function of val>

        if (colDist < minDistanceSq) 
        {
                minDistanceSq = colDist;
                result = i;
        }
    }
}
	
if (result == 0.0) 
{
    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
} 
else 
{
    gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
}

Note that I set maxCurGMM to 2 and maxCurMean to 12 via glUniform1i before invoking the shader.

With the old driver the output looks fine, but the new driver always returns [1.0, 0.0, 1.0, 1.0] indicating that something in the loop is going wrong. Interestingly enough: If I replace maxCurGMM by the constant value 2 in the for statement, the output looks fine again. Same goes for maxCurMean and the value 12. sGMMTex is a TEXTURE_2D with an internal format of GL_RGB32F_ARB. Min and Mag filters are set to nearest and wrap mode is set to clamp. The texture has no mipmaps. Replacing texture2D by texture2DLod with a mipmap level of 0 didn’t help. I am also not getting any opengl errors/warnings.

I am kind of stuck here, any help would be greatly appreciated.

Regards,
Theodor

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