Skip to content

Backend: Introduce createUniformBuffer()#33413

Merged
sunag merged 10 commits intomrdoob:devfrom
sunag:dev-createbuffer
Apr 20, 2026
Merged

Backend: Introduce createUniformBuffer()#33413
sunag merged 10 commits intomrdoob:devfrom
sunag:dev-createbuffer

Conversation

@sunag
Copy link
Copy Markdown
Collaborator

@sunag sunag commented Apr 17, 2026

Related issue: #33373

Description

As before the idea as a whole should bring more clarity to the backend calls, including the management of removal in groups of shared and non-shared uniform buffers.

This also fixed other critical issues such as memory leaks and the recreation of shared uniform groups.

@sunag sunag added this to the r185 milestone Apr 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 365.3
86.77
365.3
86.77
+0 B
+0 B
WebGPU 637.89
177.18
639.04
177.41
+1.15 kB
+233 B
WebGPU Nodes 636.01
176.88
637.16
177.12
+1.15 kB
+239 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 497.82
121.45
497.82
121.45
+0 B
+0 B
WebGPU 709.67
192
710.82
192.25
+1.15 kB
+250 B
WebGPU Nodes 658.89
179.29
660.04
179.56
+1.15 kB
+270 B

@sunag
Copy link
Copy Markdown
Collaborator Author

sunag commented Apr 17, 2026

The usage counter of Backend.deleteBindGroupData() should also be moved to the base class, likely Bindings. Ideally, calls to the Backend should be focused on execution, leaving caching to earlier classes.

@sunag sunag changed the title Backend: Introduce createUniformBuffer() Backend: Introduce createUniformBuffer() - WIP Apr 17, 2026
@sunag
Copy link
Copy Markdown
Collaborator Author

sunag commented Apr 17, 2026

@Mugen87 Just related, it’s still a WIP. I’ll ask for your review before merging so we can test it together 😇

@sunag sunag changed the title Backend: Introduce createUniformBuffer() - WIP Backend: Introduce createUniformBuffer() Apr 18, 2026
@sunag
Copy link
Copy Markdown
Collaborator Author

sunag commented Apr 18, 2026

Simple test - https://jsfiddle.net/ex0q4wb5/1/

Commands
image

Memory
image

--

I'm leaving this #33413 (comment) for other PR.

The example webgpu_postprocessing_pixel seems broken on WebGLBackend but this not seems releated with this PR.
The BindGroup could be removed of cache in NodeBuilder but I think better leave it for other PR too.

@sunag sunag marked this pull request as ready for review April 19, 2026 19:23
@sunag sunag requested a review from Mugen87 April 19, 2026 22:22
@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Apr 20, 2026

The example webgpu_postprocessing_pixel seems broken on WebGLBackend but this not seems releated with this PR.

Indeed. It took me the entire morning but I have eventually found the bug. It was double confusing because the breakage does not appear in production (over https://threejs.org/) and sometimes not locally. More details in #33422.

Comment thread src/renderers/common/Bindings.js Outdated
@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Apr 20, 2026

I've tested some examples locally with the WebGPU and WebGL backend and everything looks good! 👍

@sunag sunag merged commit 4018d68 into mrdoob:dev Apr 20, 2026
10 checks passed
@sunag sunag deleted the dev-createbuffer branch April 20, 2026 12:57
@RenaudRohlinger
Copy link
Copy Markdown
Collaborator

Huge PR!! Amazing.

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