Skip to content

Conversation

@SebastianTusk
Copy link

Related issue: #32524

Fixed #32524 by providing unique and stable buffer node ids.

@github-actions
Copy link

github-actions bot commented Dec 12, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 355.12
84.44
355.12
84.44
+0 B
+0 B
WebGPU 616.5
171.1
616.61
171.13
+102 B
+25 B
WebGPU Nodes 615.11
170.84
615.21
170.87
+102 B
+25 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 487.45
119.37
487.45
119.37
+0 B
+0 B
WebGPU 687.41
186.69
687.52
186.73
+102 B
+32 B
WebGPU Nodes 637.26
173.91
637.36
173.94
+102 B
+31 B

@SebastianTusk SebastianTusk marked this pull request as draft December 12, 2025 00:59
Sebastian Tusk added 2 commits December 12, 2025 02:00
…hader so use builder.uniforms.index as other uniforms do too
@SebastianTusk SebastianTusk marked this pull request as ready for review December 12, 2025 01:47

super.setup( builder );

const index = builder.uniforms.index ++;
Copy link
Collaborator

@Mugen87 Mugen87 Dec 13, 2025

Choose a reason for hiding this comment

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

I'm not sure it's safe to increase builder.uniforms.index at this point. This property is solely maintained by the node builder. Modifying it outside of the builder could cause unexpected behavior.

Copy link
Author

Choose a reason for hiding this comment

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

I originally wanted to use builder.context. See: BufferNode.js#L131

Unfortunately builder.context gets reset somewhere between vertex and fragment shader. Do you have any place where to store a counter that works during the complete shader build process but gets reset for a new build?

Copy link
Author

Choose a reason for hiding this comment

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

In a way builder.uniforms.index gets misused already in getBufferAttributeFromNode for attributes.

How about abstracting builder.uniforms.index away to a method on NodeBuilder that provides a unique id for uniforms, attributes and also BufferNode?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I need a closer look until I can see more about this issue. I get the point that blindly using the node id is problematic since structural equal programs become differently, leading to redundant shaders.

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: on camera switch the shader of skinned mesh is recompiled unnecessarily

2 participants