4 Replies Latest reply on Mar 4, 2012 9:38 PM by pillum

    GLSL compiler bug



      I dont know if this is the right forum for bug reports, but i could not find better one. Anyway here is the bug i found:

      this fragment shader

      #version 330
      out vec4 color0;
      void main() {
           const float a = 1;
           float b = clamp(a, 0, 1);
           color0 = vec4(b);

      outputs vec4(0,0,0,0) instead of vec4(1,1,1,1).

      if either the const qualifier for "a" or the clamp operation is removed, the shader will work correctly.

      neither the shader version nor the shader type are important - happens with all versions and all shader types



      also tested it with the GPU Shader Analyser tool (very nice tool by the way) and it shows this assembly code:

      ; -------- Disassembly --------------------
      00 ALU: ADDR(32) CNT(1)
      0 x: MOV R0.x, 0.0f
      01 EXP_DONE: PIX0, R0.xxxx

      appears to be a bug with the compiler const-folding