Skip to content
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

WebGPURenderer: Support BatchedMesh. #27937

Merged
merged 6 commits into from Mar 19, 2024

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Mar 18, 2024

Related issue: #22376

Description

This PR adds BatchMesh support to the WebGPURenderer on both backends. At this moment the WebGPU doesn't use any multi draw, let's add it once multiDrawIndirect is available (more info gpuweb/gpuweb#2315).

On my MacBook Pro M1 Max:
WebGPU: 120fps+, 4ms CPU average, 5GPU
WebGL: 65 fps, 7.6ms CPU, 5GPU

Example:
https://raw.githack.com/renaudrohlinger/three.js/utsubo/feat/webgpu-batch/examples/webgpu_mesh_batch.html

Also fixed some issue regarding timestamps getting reset when computeAsync wasn't being used.
Finally, I refactored the WebGLBackend with WebGLBufferRenderer.

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger added this to the r163 milestone Mar 18, 2024
@vegarringdal
Copy link
Contributor

Nice

Tried the sample link, dont see much difference between webgpu/webgl.
Maybe I did something wrong ?
Added som images, ran both at the same time.

AMD RX5700XT
AMD Ryzen 7 3700X 8-Core Processor 3.59 GHz
Windows 11

Edge
image

Chrome
image

@RenaudRohlinger
Copy link
Collaborator Author

RenaudRohlinger commented Mar 19, 2024

Which reminds me that maybe we should add the GPURenderBundle and consider the PR of @aardgoose (#26983). This PR will benefit a lot from it.

Related:
#26876
#26983

/cc @sunag

@RenaudRohlinger
Copy link
Collaborator Author

@vegarringdal I guess 20k instances doesn't seems enough to see noticeable differences. My numbers comes from a sample of 40k instances. Also I don't want to burn the CPUs of developers so I guess 20k is a good limit.

@RenaudRohlinger RenaudRohlinger merged commit 7059b85 into mrdoob:dev Mar 19, 2024
11 checks passed
RenaudRohlinger added a commit that referenced this pull request Mar 19, 2024
@vegarringdal
Copy link
Contributor

@RenaudRohlinger

K, would nice to be able can compare performance with minimal work.
So if it will be an official sample, then it would prefer to be able to try and kill my cpu/gpu 😄

But anyways, thanks for helping making the webgpu part more complete 👍
Will be fun to see what's possible with webgpu/threejs in the future.

@Mugen87 Mugen87 changed the title WebGPURenderer: Support BatchMesh WebGPURenderer: Support BatchedMesh. Mar 24, 2024
@mrdoob
Copy link
Owner

mrdoob commented Mar 29, 2024

Something broke this feature...

https://threejs.org/examples/?q=batch#webgpu_mesh_batch

If I set count to 20000 nothing changes visually:

Screenshot 2024-03-29 at 14 19 03

Seems like only the WebGPU bakend broke though...

@RenaudRohlinger
Copy link
Collaborator Author

Will check! Probably just an issue with the example or the BatchNode not supporting dynamic update yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants