Maybe I’m missing something obvious here, but I have a loop in my shader that the shader processor is warning me about.
while (exit.distance < intersections[i].distance)
{
intersections[i + 2] = intersections[i];
i--;
}
In the inspector of this compute shader, I get the following warning:
loop doesn’t seem to do anything, forcing loop to unroll at kernel main
As far as I can tell, that is not true. The loop condition depends on shader input, so I don’t think that the processor is detecting a loop that it thinks will never execute. And I’m clearly modifying array elements in the loop, which I use for the output for the shader. Some debug output directly after the loop verifies to me that the loop is indeed executed and does what it should.
Just as an experiment I tried to add a [loop] attribute, which made the warning message to change:
loop doesn’t seem to do anything, consider removing [loop] infinite loop detected - loop writes no values at kernel main
This isn’t a huge issue, because it’s only a warning and the shader seems to work.
However, a slightly more complicated loop further down in the shader is also flagged with the same error. This time the processor is unable to unroll it and this makes it an error:
force to unroll loop, but unrolling failed at kernel main