[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] Infinite loops allowed in WebGL 1.0 currently?



We were looking at a bug in IE recently and came across an interesting case:

 

http://threejs.org/examples/#webgl_materials_parallaxmap

 

This has this fragment of GLSL code:

 

                               "for ( int i = 0; i == 0; i += 0 ) {",

 

This is obviously an infinite loop. I am assuming that the site is working because the code is never hit in practice.

 

The way that we translate GLSL, this is a bit tricky for us. It appears that ANGLE is outputting [loop] in HLSL, and on most hardware this will happily generate an infinite loop that causes TDRs in the shader (we can make Chrome TDR using loop constructs like this).

 

The specification for loops in GLSL seems to have a lot of effort put into preventing unverifiable loops – is the case of a zero increment an oversight in the specification? I would love to return an error for this kind of case but if I do that now, I will end up not working on a site that works in ANGLE based browsers, and this is not good for interoperability.