Re-enable glDrawRangeElements() on WebGL 2 when it actually works
Currently, the glDrawRangeElements() WebGL 2 function is not implemented in Firefox (38) and causes "Not Implemented." assertion. It is also not yet implemented in Emscripten, but I have a patch that adds it.
Related Mozilla bug.
So it is now disabled in Mesh::draw() code until stable Firefox implements it, then it should be added to Emscripten and then re-enabled here for performance reasons.
On the other hand, in the draft WebGL 2 specification there is the following comment that might possibly cause the function to be removed from the final specification:
/* TODO(kbr): argue against exposing this because it can't safely offer better performance than drawElements */ void drawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLintptr offset);
Making this into an issue so I don't forget the particulars.
Related discussion: https://twitter.com/kamidphish/status/641366351001419777
I may remove that call altogether if it really doesn't help with anything. Would simplify the implementation quite a lot.
The Related mozilla bug has been fixed, right?
Yup, and moreover is also patched over / ignored in emscripten in a similar way: https://github.com/kripken/emscripten/blob/6dc4ac5f9e4d8484e273e4dcc554f809738cedd6/src/library_gl.js#L7361 so I guess this is safe to enable now.
Workaround reverted in f6ba4111e1669b254da8f0dafdbb5d9cb6df364a.
Turns out Emscripten has a bug that prevents this to work. Reverted the workaround revert in 6bb0179c65b3813203d2caf12d75e58f650da87f, Emscripten PR submitted in https://github.com/kripken/emscripten/pull/7112.
Reopening until the Emscripten PR is fixed and a version with the fix is widespread enough. I think mid/late 2019 could be okay to put this back.
@mosra Is it okay to put this. back now?
Based on what I read when investigating this, it seems that the API doesn't improve anything on current GPUs anymore (another evidence supporting this is that Vulkan doesn't have any way to specify index range), and so I'm thinking about going the other way instead, and stop using DrawRangeElements altogether. It would make the internals simpler and reduce the amount of public APIs overloads.
glDrawRangeElements() is enabled on WebGL 2 again in 9ec7f26fae3f6e7f6461c086db0134bb721f25c1. Hopefully, after three reverts, this is the last time this particular piece of code gets touched.