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

BatchedMesh: Add fallback for when the multi draw extension is not supported #27178

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

gkjohnson
Copy link
Collaborator

Related issue: #22376, #27111, #27170

Description

Adds fallback for rendering BatchedMesh when multi draw is not supported by calling "drawArrays" multiple times in a tight loop. From testing even when the multi_draw extension is not used we still get some performance benefits since we don't have to change material uniforms for individual objects.

cc @RenaudRohlinger

@gkjohnson gkjohnson added this to the r159 milestone Nov 13, 2023
@gkjohnson gkjohnson requested a review from Mugen87 November 13, 2023 09:06
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
656.7 kB (162.8 kB) 656.6 kB (162.8 kB) -176 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
449.2 kB (108.8 kB) 449 kB (108.8 kB) -176 B

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 13, 2023

I'm not sure about this. Wasn't the plan to require WEBGL_multi_draw for BatchedMesh usage?

When we require certain WebGL features, developers hopefully ask at browser developers to finally support certain extensions like WEBGL_multi_draw. AFAICS, Firefox is the only major browser that doesn't support it for some reasons.

@gkjohnson
Copy link
Collaborator Author

I'm not sure about this. Wasn't the plan to require WEBGL_multi_draw for BatchedMesh usage?

I just thought I'd offer this as an easy-to-implement fallback option (thanks Renaud). Originally when considering a fallback I was thinking about a more complex implementation that would require maintaining both the original BatchedMesh implementation and the new multi draw one. But this is much simpler.

When we require certain WebGL features, developers hopefully ask at browser developers to finally support certain extensions like WEBGL_multi_draw. AFAICS, Firefox is the only major browser that doesn't support it for some reasons.

I'll leave whether to merge this for you and @mrdoob to decide - I would like FF to support multi-draw, too, though. A fallback like this might make more sense for #27170 considering InstancedMesh has already been supported and used in FF.

@mrdoob
Copy link
Owner

mrdoob commented Nov 17, 2023

Considering how simple the fallback is, I think we should definitely do this 👍

@mrdoob mrdoob merged commit f02b948 into mrdoob:dev Nov 17, 2023
12 checks passed
@gkjohnson gkjohnson deleted the batched-fallback branch November 17, 2023 09:41
AdaRoseCannon pushed a commit to AdaRoseCannon/three.js that referenced this pull request Jan 15, 2024
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