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

NodeMaterialObserver: Detect geometry exchange. #30409

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 27, 2025

Fixed #30398.

Description

NodeMaterialObserver must detect a geometry exchange otherwise Geometries.updateForRender() is not correctly called which means attributes might not be in a valid state.

Below is the code block that must be executed in order to avoid the errors/warnings mentioned in #30398.

const needsRefresh = this._nodes.needsRefresh( renderObject );
if ( needsRefresh ) {
this._nodes.updateBefore( renderObject );
this._geometries.updateForRender( renderObject );
this._nodes.updateForRender( renderObject );
this._bindings.updateForRender( renderObject );
}

@Mugen87 Mugen87 added this to the r173 milestone Jan 27, 2025
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.27
78.29
336.27
78.29
+0 B
+0 B
WebGPU 512.38
142.34
512.43
142.36
+43 B
+15 B
WebGPU Nodes 511.85
142.24
511.89
142.25
+43 B
+13 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.25
112.13
465.25
112.13
+0 B
+0 B
WebGPU 586.31
159
586.36
159.02
+43 B
+15 B
WebGPU Nodes 541.7
148.55
541.74
148.57
+43 B
+16 B

@@ -362,6 +363,13 @@ class NodeMaterialObserver {
const storedAttributeNames = Object.keys( storedAttributes );
const currentAttributeNames = Object.keys( attributes );

if ( storedGeometryData.id !== geometry.id ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To clarify this does not introduce a "ping-pong" effect since the storedGeometryData is maintained per render object.

@sunag sunag merged commit edc26d4 into mrdoob:dev Jan 27, 2025
12 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.

WebGPU Fatal Error on Mesh Geometry Assignment
2 participants