Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Aug 19, 2025

Related issue: -

Description

The PR adds WebGPU compatibility checks to some compute demos that don't work properly with WebGL 2.

  1. webgpu_compute_birds runs with 3-4 FPS in Firefox/macOS with M2 Pro and produces the following WebGL warnings:

WebGL warning: texSubImage: Uploads from a buffer with a final row with a byte count smaller than the row stride can incur extra overhead. 27
WebGL warning: drawArraysInstanced: Drawing to a destination rect smaller than the viewport rect. (This warning will only be given once)

@cmhhelgeson Is this example supposed to run with WebGL 2? If so, do you know why Firefox complains?

  1. webgpu_compute_cloth shows a broken velvet mesh in the first frames and then the velvet disappears. The following warnings are logged.

WebGL warning: texSubImage: Uploads from a buffer with a final row with a byte count smaller than the row stride can incur extra overhead.

screenshot

@holtsetio Does the cloth simulation support WebGL 2? I suppose it's similar problem like webgpu_compute_birds.

  1. webgpu_compute_texture_3d fails with a runtime error:

Uncaught (in promise) Error: Uniform "storageTexture" not declared.

@Mugen87 Mugen87 changed the title Example: Add WebGPU check to some compute demos. Examples: Add WebGPU check to some compute demos. Aug 19, 2025
@cmhhelgeson
Copy link
Contributor

cmhhelgeson commented Aug 19, 2025

@cmhhelgeson Is this example supposed to run with WebGL 2? If so, do you know why Firefox complains?

I recall it working on Chrome/Firefox on Windows but I never tested it on Mac. I'll have to try it again.

I'm not sure how much work we want to put into this given previous statements on aligning the WebGL backend to offer comparable compute capabilities as the WebGPU backend: #31250 (comment) However, I'm not sure the compute_birds example would fall under errors introduced by the transform feedback, so I'll take another look at it.

@sunag sunag added this to the r180 milestone Aug 20, 2025
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Aug 20, 2025

I'm not sure how much work we want to put into this given previous statements on aligning the WebGL backend to offer comparable compute capabilities as the WebGPU backend-

Indeed. The PR does not question this premise.

However, the examples should work without producing warnings in the browser console. If there are warnings, we should understand why and verify if we can fix them.

It's also a red flag if examples work with WebGPU but visually break in the WebGL backend like webgpu_compute_cloth.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Aug 20, 2025

Merging the PR for now. Ideally, at least webgpu_compute_cloth and webgpu_compute_birds can be fixed, so the compatibility check can be removed.

Besides, webgpu_compute_birds is computationally very expensive. Even with Chrome and WebGPU the examples only runs in the range 20-35 FPS on a macMini with M2 Pro. How about reducing the bird count to mitigate this issue?

@Mugen87 Mugen87 merged commit f163bfa into mrdoob:dev Aug 20, 2025
8 checks passed
@cmhhelgeson
Copy link
Contributor

cmhhelgeson commented Aug 20, 2025

Merging the PR for now. Ideally, at least webgpu_compute_cloth and webgpu_compute_birds can be fixed, so the compatibility check can be removed.

Besides, webgpu_compute_birds is computationally very expensive. Even with Chrome and WebGPU the examples only runs in the range 20-35 FPS on a macMini with M2 Pro. How about reducing the bird count to mitigate this issue?

The birds performance issue can likely be resolved by sorting the birds so each bird doesn't have to loop through each of this neighbors. This is something I've wanted to implement and something explicitly mentioned by @simondevyoutube in his shader tutorials as an improvement. We can use bitonic sort for this purpose to get something up quickly, or potentially a prefix sum/counting sort approach for maximum performance.

How about this. I will try to prioritize performance improvements for the compute examples over the weekend. If those aren't addressed by r180 launch, then we can lower the number of birds until the Mac performance issue is sufficiently addressed.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Aug 20, 2025

Sounds good!

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.

3 participants