This may be more of a general programming question, but since it is related to GLSL I thought best to put it here.
I'm doing some GPGPU stuff inside a geometry shader, and I'm coming up with two very obscure problems:
(1)
In one of my functions, if I use a variable to compute something, the function hangs indefinitely. If I replace that variable with the equivalent number, the function runs just fun. So it looks a bit like this:
void main() {
currSize = gl_FrontColorIn[0];
...
Repeat(0, 1, currSize[1]);
...
void Repeat(int axis, float size, float numRepeats)
for (int i = 0; i < numRepeats; i++) { //HANGS FOREVER
...
EmitVertex();
}
In the above example, if I simply call Repeat(0,1,30), it works just fine and does exactly what I expect it to do. Further, if I comment out the 'EmitVertex' call, it proceeds to terminate normally (but obviously doesn't perform its intended function).
(2)
I have a function Subdiv which contains a for-loop and emits some vertices within that loop, similar to Repeat. Normally, Subdiv works fine. However, sometimes when I put Subdiv in, my GLSL program will fail to link. It's not giving me any coherent error messages to help me diagnose the problem. I'm suspecting maybe some funny loop unrolling going on, but (a)I'm not sure, and (b)no idea how to fix it if so.
Has anyone seen/had problems similar to these, and might you know how to work around them?
Cheers,
--Brian