Support baseInstance/baseVertex draw and multidraw extension calls #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for WEBGL_draw_instanced_base_vertex_base_instance and
WEBGL_multi_draw_instanced_base_vertex_base_instance via the
DrawCall.drawRanges
interface. It resolves #197.This change lets you specify the first vertex and/or instance in your range on a per-draw basis, like this:
The multidraw+baseVertex+baseInstance extension calls will be used if they're available, since they cover the most use cases (and provide
gl_DrawID
). Then ifbaseVertices
orbaseInstances
have been set the non-multidraw baseVertex+baseInstance extension calls will be used. If not, the existing draw call preference order (multidraw then non-multidraw) takes over.I added an example at
examples/multi-draw-base-instance.html
:I tested this with the existing
examples/multi-draw.html
andexamples/multi-draw-base-instance.html
, and also spot checked the rest of the examples and didn't see anything broken. That said I didn't explicitly test thedrawElementsInstancedBaseVertexBaseInstanceWEBGL
andmultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL
calls, instead I just made sure they conformed to the API.