Crashes with texture3d

I have some weird crashes with texture3d. I developed my program on a 8800 GTX. I can run it on my machine on both linux and windows, it also runs on boxes with a 8600GT and also tested it on a thinkpad T61P which has a nVidia quadro NVS i believe. Those are the gfx cards the code runs fine. On other computers it crashes when binding the shader. The shader compiler and linker don’t give me errors.
A friend tested it on his mac notebook and it even crashed the apple opengl shader builder.

The code in question is this:


uniform sampler3D texes[10];
uniform bool show[10];
uniform float threshold[10];
uniform float alpha[10];

void lookupTex(inout vec4 col, in sampler3D tex, in float threshold, in float alpha)
{
	vec3 col1 = vec3(0.0);

	col1 = clamp( texture3D(tex, gl_TexCoord[0].xyz).rgb, 0.0, 1.0);
	
	if ( ( (col1.r + col1.g + col1.b)/3.0 - threshold) > 0.0 )
	{
		col.rgb = ((1.0 - alpha) * col.rgb) + (alpha * col1.rgb);
	}

	col.a += clamp (( (col.r*3.0) + (col.g*3.0) + (col.b*3.0) ), 0.0, 1.0) - threshold;
}

for (int i = 9 ; i > -1 ; i--)
{
        if (show[i]) lookupTex(col, texes[i], threshold[i], alpha[i]);
}

I’m using Glew 1.5.0, on the older computers with the 8600GTs it is compiled with a Glew 1.3.5

Well the answer seems to be the same as in http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=251908#Post251908

I just find it strange that it crashes my application and not give me any compiler errors.

I thought the thread you refer to was talking about using instancing indexes into vertices?

Your compiler will often allow functions that are not implemented as the API interface is there, but it will compile with a NULL pointer for the required function if it is not implemented.

Anytime I have tried to use glsl1.3 things in a gls1.2 shader it has generally thrown up an error. But on the C++ side I have crashed code with calls to stubs that don’t exist… Perhaps this is the same.

You can use indexing in shaders for Uniforms and the like in 1.2, but unless you have 1.3 you won’t be able to use instancing.

However, I cannot see where you are doing that in the shader above.

Well i “unraveled” the for loop and do 10 function calls like these:


if (show[9]) lookupTex(col, texes[9], threshold[9], alpha[9]);
...
if (show[0]) lookupTex(col, texes[0], threshold[0], alpha[0]);

that looks ugly but it fixed the crashes on the mac. Haven’t had the chance to test it on another system with something other than a gforce8+ yet.

I am curious… What happens if you do the loop the other way around?

i.e. for (int i = 0; i<9; i++)

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