ATI X1600 available number of texture instructions exceeded

Hi,
I have ATI x1600 PRO. I’m implementing a GPU ray cast volume renderer. I’m getting an error that I’m exceeding available number of texture instructions when my loop iteration count is over 127. If I remove my texture accessing operations the program runs in hardware. I thought the card supported loops and branches in the shader. I’m using latest catalyst driver. Any thoughts?

Here’s my fragment shader:

uniform vec3 eyePos;
uniform float stepSize;
uniform sampler3D volumeTexture;
uniform sampler1D colourTable;

void main()
{
        vec4 value;
	
	vec3 position = gl_TexCoord[0].stp;
	vec3 direction = position - eyePos;
	direction = normalize(direction);
	vec4 dst = vec4 (0,0,0,0);
	for (int i = 0; i < 512; i++)
	{
		//get voxel, apply transfer function
		value = texture3D(volumeTexture, position);
		vec4 src = texture1D(colourTable,value.r);
		
		//front to back compositing
		dst = (1.0 - dst.a) * src + dst;
		
		//advance position
		position = position + direction * stepSize;
	}
	gl_FragColor = dst;
}

Is it possible to get around the loop limit by breaking the loop into several loops of smaller size?

e.g:

for( i = 0; i < 128; i++ ) { ... }
for( i = 128; i < 256; i++ ) { ... }
...

Then stuff the loop contents into a function (or just duplicate the code).

No that doesn’t work unless the sum of the two loops is less than the limit. It looks like it’s un-rolling the for loop.

Another interesting thing is if I add any break statement:
if (dst.a > 0.95) break;
the program compiles and links and promises to run in hardware even for 1024 iterations. However I suspect the loop doesn’t actually run for all those iterations in all the cases because I see some data missing (I could have made a mistake elsewhere, but I suspect the card to be at fault).

You may try a nested loop: it solved a similar issue I have with a different card though (some Nvidia GeForce 5)

for(i=0;i<16;i++)
 {
  for(j=0;j<16;j++)
   {
    ...
   }
}

overlay, thank you very much. That actually works. I don’t know why, but it does.

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