New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 1 user

Issue metadata

Status: Fixed
Owner:
User never visited
Closed: Jul 2012
OS: ----
Priority: Medium
Renderer: ----
Type: Defect



Sign in to add a comment

Dividing long loops into several 256 iteration loops breaks code

Reported by mikae...@gmail.com, Jun 14 2012 Back to list

Issue description

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

 
Owner: nicolas....@gmail.com
Status: Accepted
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.
Status: Started
Status: Fixed
Fixed in r1213.

Sign in to add a comment