lion0406 / angleproject

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

Dividing long loops into several 256 iteration loops breaks code #338

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It seems ANGLE breaks long loops into several smaller 256 iteration loops. 
Sometimes this breaks the code.

Consider this example:

int j = 400;
for (int i = 0; i <= 400; i++) {
    if (dot(z,z)> 1000.0) { j = i; break; }
    z = complexMul(z,z) + add;
}

Which ANGLE turns into this:

int _j = 400;
for(int _i = 0; _i < 255; _i += 1)
{{ 
   if((dot(_z, _z) > 1000.0)) { { (_j = _i); break;; } ;};
   (_z = (_complexMul(_z, _z) + _add));
};}

for(int _i = 255; _i < 401; _i += 1)
{{

    if((dot(_z, _z) > 1000.0)) {{ (_j = _i);break;;};};
    (_z = (_complexMul(_z, _z) + _add));   
};};

The meaning is changed, however. If the first loop breaks when i=10, j should 
be equal to 10, but the next loop sets j=255. 

There is a working example here: http://hvidtfeldts.net/WebGLError/webgl.html

If 'Iterations' is increased beyond 256 the Julia set on the right disappears. 
If I turn ANGLE off, it works as expected.

I found this error on latest version of Chrome and Chromium (Win 7, 64bit).

Chrome: 19.0.1084.52 (Official Build 138391) Angle revision 1022
Chromium: 21.0.1175.0 (Developer Build 142124) Angle revision 1046

Original issue reported on code.google.com by mikae...@gmail.com on 14 Jun 2012 at 7:01

GoogleCodeExporter commented 9 years ago
Thanks for reporting this and providing a detailed explanation of the issue. 
ANGLE breaks up loops because Shader Model 3 only supports 255 iterations per 
loop. But it should indeed not execute the second loop if the first one hit a 
break statement. Similarly there would be a problem when a continue statement 
is hit on the last iteration.

Original comment by nicolas....@gmail.com on 14 Jun 2012 at 8:23

GoogleCodeExporter commented 9 years ago

Original comment by nicolas....@gmail.com on 5 Jul 2012 at 2:41

GoogleCodeExporter commented 9 years ago
Fixed in r1213.

Original comment by nicolas....@gmail.com on 11 Jul 2012 at 8:47