This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Arguably missed optimization: empty loop causes rendering to miss deadline

In our testing work we've encountered an issue where inserting an empty loop:

for(int temp = 0; temp < C; temp++) {

}

leads to a problem when C is large.

The issue is detailed in full here, where the files are available:

Adding long-running empty loop causes browser to lose WebGL context · Issue #39 · mc-imperial/shader-compiler-bugs · Git…

On my Chromebook, I find that adding an empty loop to this fragment shader, to yield this variant fragment shader, makes the difference between the shader rendering an image, and nothing being rendered.  In the case where nothing is rendered, the Chromebook screen goes blank, and Chrome reports that it has lost its WebGL context.

I don't expect ARM will regard this as a compiler bug, since clearly shaders should not be too long running.  And reducing the loop bound make the problem disappear.

However, it does seem that it would be easy for the Mali GLSL compiler to optimise away the empty loop, and this might indicate that the compiler could do a better job in general of eliminating redundant code that graphics programmers have left in by accident.

Parents
  • Hi Ally,

    I'll raise this one with the compiler team, just so it is at least tracked and we are aware of it if we see it in the wild. Loop-based control flow is still pretty rare in shipping applications; but it would be good to close up the holes like this one.

    Thanks again,

    Pete

Reply
  • Hi Ally,

    I'll raise this one with the compiler team, just so it is at least tracked and we are aware of it if we see it in the wild. Loop-based control flow is still pretty rare in shipping applications; but it would be good to close up the holes like this one.

    Thanks again,

    Pete

Children
No data