HTML5 OpenGL backend doesn't need to flush GL commands

Looking at a performance profile of a HTML5 exported page, there seems to be a call to glFlush() that eats up performance and browser responsiveness.

In the above profile, this takes up 7.1% of the main frame loop time, while locking up the main thread. In WebGL, there are no current sensible uses for glFlush() (nor glFinish()), so the time that is taken up by this call is redundant.

The source of the call was traced to Engine\Source\Runtime\OpenGLDrv\Private\OpenGLQuery.cpp, which has

This call could safely be #ifndef EMSCRIPTEN’ed out without effect to execution or timings and it would give a nice performance improvement. WebGL does not currently have sync objects or fences that the code in question relates to.

If one wants to manually work around this in a compiled build, one can edit the generated asm.js file and search for “GLctx.flush();” call (there’s exactly one in the whole file) and remove that, or comment it out.

added the #ifndef EMSCRIPTEN and checked in to perforce - this might not make it to 4.12 – but definitely for 4.13.

thanks Jukka!