-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
WebGPURenderer: BatchedMesh via drawIndexedIndirect #30645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
By curiosity, by how much does it improve the performance on your test ? |
@Makio64 So far, it's more expensive than typical drawIndexed on Chrome macOS since it does almost the same with the overhead of an indirect buffer updated every frame, but the idea is that we handle all this in compute shading, which is where performance should improve. |
If you reserve the same number of vertices for each geometry, drawIndirect/drawIdexedIndirect works very well, then it's all a single drawCall, because you can assign all objects to the indirectBuffer with atomic add. The disadvantage is that if you have objects with very different vertex counts, you use unnecessary memory because you have to reserve the highest vertex count for all objects. But if, as with an instancedGeometry, all instances have the same vertex count, it's perfect. In your case, where you have a dozen different primitives, this would also be very easy to do with drawIndirect/drawIndexedIndirect, since each instance of a primitive has the same vertex count. Then, with 12 different primitives, there would only be 12 drawIndirect drawCalls and you can easily push it up to the buffer limit without causing frame drops. ![]() I'm currently converting my terrain generator to drawIndexedIndirect. I'm almost finished with it now. The entire terrain is a single draw call. Frustum and occlusion also does everything the GPU with a compute shader. @RenaudRohlinger Does atomic.add work for you with metal now? |
Related issue: #29197 (comment)
Description
multiDrawIndirect
was announced in Chrome 131. However, after following its progress for over six months, it’s clear that the Metal backend still lacks a full implementation.Inspired by @aardgoose’s idea, this PR introduces an alternative approach: using multiple drawIndirect() calls with a single indirect buffer, where each call accesses different offsets within the buffer. This method enables GPU compute-directed rendering, potentially capturing many of the benefits of multidraw indirect.
So far I implemented the first step which corresponds to use multiple
drawIndirect()
calls with the a single indirect buffer mapped at different offsets at for each call. Second part will probably be to move theonBeforeRender
logic ofBatchedMesh
in compute shaders.This contribution is funded by Utsubo