Hi,

It seems there is a bug in the compiler. The problem may be reproduced with the following shader (complete shader_test file attached):

        void main()
        {
                float f = 0.0;
                while (true) {
                        f = 1.0;
                        break;
                        f = 0.5;
                }
                gl_FragColor = vec4(1.0 - f, f, 0.0, 1.0);
        }

The result of compilation is equal to:

        while (true) {
                break;
        }
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

In other words, GLSL compiler eliminates both assignments to "f" in the loop body and the resulting value of the "f" variable is 0.

Vadim

[require]
GLSL >= 1.20

[vertex shader]
void main()
{
        gl_Position = gl_Vertex;
}

[fragment shader]
void main()
{
        float f = 0.0;
        while (true) {
                f = 1.0;
                break;
                f = 0.5;
        }
        gl_FragColor = vec4(1.0 - f, f, 0.0, 1.0);
}

[test]
clear color 0.0 0.0 0.0 0.0
clear

draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to