Skip to content

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Aug 19, 2025

Fixed #31679.

Description

The PR fixes an issue where WebGL buffers were created over and over again for UBO updates.

The GL buffer is directly coupled to the buffer of THREE.UniformBuffer which is fixed sized. So creating the GL buffer for a UBO once and then caching it should be safe.

Copy link

github-actions bot commented Aug 19, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.91
79.1
338.91
79.1
+0 B
+0 B
WebGPU 575.57
158.81
575.75
158.85
+173 B
+43 B
WebGPU Nodes 574.18
158.56
574.35
158.61
+173 B
+44 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.7
113.91
470.7
113.91
+0 B
+0 B
WebGPU 646.63
174.87
646.8
174.91
+173 B
+41 B
WebGPU Nodes 600.8
164.05
600.98
164.09
+173 B
+40 B

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Aug 19, 2025

The code also distincts now between buffer update and creation. gl.bufferData() is only used for creation, gl.bufferSubData() for the update. In this way, we update UBOs in the same manner as attribute buffers.


} else if ( binding.isSampledTexture ) {

const { textureGPU, glTextureType } = this.get( binding.texture );

this.set( binding, {
Copy link
Collaborator Author

@Mugen87 Mugen87 Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set() calls are changed to avoid inline object creation via {}.

@Mugen87 Mugen87 added this to the r180 milestone Aug 19, 2025
@sunag sunag merged commit ca3194a into mrdoob:dev Aug 19, 2025
13 of 14 checks passed
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.

WebGPURenderer: WebGL buffer for UBO update isn't reused.
2 participants