Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Problem with boolean expressions

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    7

    Unhappy Problem with boolean expressions

    Dear OpenGL-community,

    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:
    Code :
    uniform uint dimension; // fixed at 512
    void main()
    {
        bool continueLoop = true;
        do
        {
            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)));
        }
        while(continueLoop);
    }

    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.

    Kind regards,
    Daniel
    Last edited by danielkr; 11-30-2012 at 02:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •