ValhallaTeam / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Incorrect work of for-loop #434

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create the following fragment shader:

uniform float u1;

void main(void) {
    vec4 color = vec4(0., 0., 0., 1.);
    float count = 0.;
    for(float i = 0.; i >= 0.; i++){
        if(i >= u1){
            break;
        }
        count++;
        continue;
    }
    if(count == u1){
        color.x = 255.;
    }
    else {
        color.y = 255.;
    }

    gl_FragColor = color;
}

After execute this loop 'count' must be equal for uniform 'u1'(color of pixels 
must be red). But it doesn`t(pixels are green).
Under GL all fine.

I used: Chrome 29.0.1531.0 canary.

In attached file there are small demo for represent this bug.

Original issue reported on code.google.com by sss0...@gmail.com on 9 Jun 2013 at 2:50

Attachments:

GoogleCodeExporter commented 9 years ago
This is not a bug. OpenGL ES 2.0 implementations are not required to support 
dynamic branching. See Appendix A section 4 of the GLSL ES 1.00 specification: 
"In general, control flow is limited to forward branching and to loops where 
the maximum number of iterations can easily be determined at compile time." 
Direct3D 9 also has loop iteration limitations.

Original comment by nico...@transgaming.com on 9 Jun 2013 at 7:03