Well here is my lovely little fragment shader. And it all works great. Except for one little thing. When the loop count goes from 6 to 7 I get “The GLSL fragment shader will run in software - available number of texture instructions exceeded.” Hmmm… That will not do at all. I am pretty sure that “texture instructions” refers to “texture3D.” And I think that the loop is being parallized. And I think that because singleCoord is calculated in the loop that the texture3D command is being parallized along with the loop resulting in more than one call to texture3D. Of course I’m gussing, but it seems to make sense. The thing is, there really needs to be only one call to texture3D. The loop only finds one valid value for singleCoord so I can’t think of any reason for texture3D to be parallized. So my question is, how can I insure that only one call to texture3D is made after the loop is finished?
I don’t think this is actually about texture instructions, more like total instructions. What graphics card are you using?
By the way, you can use a 1x1 luminance texture with a single white pixel and black as border color to do a 2D range check. This may be faster on some cards.
I thought that might be it to for a while. However if I simply add a large number of instructions I don’t get the message. Also, I don’t get the message if there is no linkage between the loop and the texture3D command, that is if I set singleCoord2 instead of singleCoord I don’t get the message. Though I suppose both of these results could be explained by some sort of code optimization.
It doesn’t do what I want it to do, but it does let me get the loop to 23. So I guess it is a total instruction count limit. I need the count to be around 500 for what I want to do so I guess fragment shading isn’t going to work for me.
For 500 iterations you need a card with dynamic branching in the fragment shader (GeForce 6 and later, Radeon X1k). With loop unrolling the shader will just become too big.