Problem with boolean expressions
I have the following problem with the OpenGL 4.3 Shader Language, NVIDIA GTX 680, driver 310.64 (driver 310.61 had the same issue).
A simplyfied code example is:
uniform uint dimension; // fixed at 512
bool continueLoop = true;
ivec3 data = // compute data, range of [0...512]
// variant 1:
continueLoop = data.x < dimension && data.y < dimension && data.z < dimension;
// variant 2:
continueLoop = data.x - dimension < 0 && data.y - dimension < 0 && data.z - dimension < 0;
// variant 3:
continueLoop = data.x - dimension + 1 <= 0 && data.y - dimension + 1 <= 0 && data.z - dimension + 1 <= 0;
// variant 4:
continueLoop = all(lessThanEqual(data - ivec3(dimension), ivec(0)));
The problem is, that only for variant 1, the code executes correctly.
I cannot see any fault here, can someone give me a hint? Or is it a bug?
In my opinion, every variant is the same in terms of boolean algebra, right?
I even tried a lot of parenthesis and int-casting so the -dimension does not underflow or something.