-
I am currently porting a webgl2 engine to webgpu, but the engine uses DrawIndex (gl_DrawID) extensively in order to optimize the rendering of scenes with a lot of unique meshes with unique materials. Neither multidraw nor DrawIndex seems to be supported right now; is DrawIndex something we can expect to come soon? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Possibly as part of multi-draw-indirect #1354/#2315 but it will be some time before that gets added, I think. Can you use dynamic offsets to change the binding offset between draw calls? It still needs a setBindGroup call but you can do it without creating tons of GPUBindGroup objects. See Also consider using render bundles to reduce the number of JS calls you need to make each frame - if you are rendering the same thing frame-over-frame then you can bundle together everything that you would have done in one multidraw call in WebGL, and "replay" that each frame. |
Beta Was this translation helpful? Give feedback.
Thank you for the advice; dynamic offsets sounds like a good solution to limit how many bind groups are created; but still require manually changing offset between draw calls, which I would like to avoid through instancing.
Instead, I am currently investigating the use of instance index offsets (firstInstance option in the draw command). It will still require multiple draw calls (one per mesh) - at least until multidraw is implemented.