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 10 of 28

Thread: unbound sampler declaration andd GLSL shader code

Threaded View

  1. #19
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Quote Originally Posted by fred_em
    Even if my condition is "if (gl_FragCoord.x > 10000)" which is not a dynamic-uniform (as you said), I don't see any reason why the GPU would choose to evaluate the wrong block of code.
    You got that twisted. Conditional statements which are dynamically uniform and evaluate to false will not trigger execution of the code. Since your statement isn't dynamically uniform, potentially both branches are executed as GClements pointed out and if then excuted code triggers undefined behavior which isn't handled graciously by the implementation, you get into trouble.

    Here's why your condition isn't dynamically uniform:

    - it's not a constant expression, so the trivial case is out
    - gl_FragColor is not a uniform but a built-in fragment shader input:

    Code :
    in vec4 gl_FragCoord;

    The GLSL Spec states:

    A fragment-shader expression is dynamically uniform if all fragments evaluating it get the same resulting value.
    It should be obvious that this is generally not (if ever)the case for an expression involving gl_FragCoord - even though it will always evaluates to false.
    Last edited by thokra; 06-26-2013 at 09:43 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
  •