magnum icon indicating copy to clipboard operation
magnum copied to clipboard

Re-enable glDrawRangeElements() on WebGL 2 when it actually works

Open mosra opened this issue 10 years ago • 7 comments

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.

mosra avatar May 24 '15 18:05 mosra

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.

mosra avatar Sep 10 '15 09:09 mosra

The Related mozilla bug has been fixed, right?

Squareys avatar Aug 09 '17 19:08 Squareys

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.

mosra avatar Aug 14 '17 17:08 mosra

Workaround reverted in f6ba4111e1669b254da8f0dafdbb5d9cb6df364a.

mosra avatar Aug 30 '18 11:08 mosra

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 avatar Sep 11 '18 10:09 mosra

@mosra Is it okay to put this. back now?

Skylion007 avatar Sep 24 '20 19:09 Skylion007

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.

mosra avatar Sep 24 '20 19:09 mosra

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.

mosra avatar Sep 03 '23 23:09 mosra