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;
}
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).