ValhallaTeam / angleproject

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

ANGLE miscompiles code containing ternary and logical || operator - "X3003: redefinition of 's1'" #412

Closed GoogleCodeExporter closed 9 years ago

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

#ifdef GL_ES
precision highp float;
#endif

void main(void) {
    float within = 0.0;
    float shade = 1.0;

    float bshade = (shade == 1.0 || shade == 0.0) ? 0.0 : shade;
    if (bshade == 0.0 && within == 0.0) {
        discard;
        }
    }

What is the expected output? What do you see instead?

The shader should correctly compile. Instead I receive an error X3003: 
redefinition of 's1', an identifier which does not appear in my program. I've 
done my best to slim down the test case to the bare minimum, so please excuse 
the shader being somewhat "do-nothing" and illogical.

What version of the product are you using? On what operating system?

All recent versions of ANGLE - e.g. Chrome 24 or Firefox 18. Using Windows 7 
x64, Radeon HD 6800 series.

Please provide any additional information below.

This bug has appeared in ANGLE of about 3 months vintage - say since Chrome 
22/23 or so. This is a regression since this code used to work correctly.

This may be related to misimplementation of logical operators described in 
issues 394 and 347.

Original issue reported on code.google.com by amb26pon...@googlemail.com on 17 Feb 2013 at 6:23

GoogleCodeExporter commented 9 years ago
This is most likely a duplicate of Issue 394, but thanks for the extra test 
case!

We convert boolean and ternary operators into conditional statements to get 
short-circuiting behavior (which HLSL does not provide). For this we use 
temporary variables named s#, but apparently under certain conditions the same 
index is reused within the same scope.

Original comment by nicolas....@gmail.com on 19 Feb 2013 at 2:25