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

ConstNode: Optimize indexes #30388

Merged
merged 3 commits into from
Jan 24, 2025
Merged

ConstNode: Optimize indexes #30388

merged 3 commits into from
Jan 24, 2025

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jan 23, 2025

Description

Added optimization to constants, which now prioritizes the output type if the values ​​are primitive. Previously it was mandatory to use uint() for indexes like .element( uint( 1 ) ) for this optimization, after this PR the conversion is done automatically.

// TSL
cameraProjectionMatrix.element( 2 ).element( 3 ) // 1
cameraProjectionMatrix.element( uint( 2 ) ).element( uint( 3 ) ) // 2

// WGSL - Before
render.cameraProjectionMatrix[ u32( 2.0 ) ][ u32( 3.0 ) ] // 1
render.cameraProjectionMatrix[ 2u ][ 3u ] // 2

// WGSL - Now
render.cameraProjectionMatrix[ 2u ][ 3u ] // 1
render.cameraProjectionMatrix[ 2u ][ 3u ] // 2

@sunag sunag added this to the r173 milestone Jan 23, 2025
Copy link

github-actions bot commented Jan 23, 2025

📦 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 511.96
142.14
512.03
142.15
+68 B
+12 B
WebGPU Nodes 511.43
142.03
511.49
142.04
+68 B
+11 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 585.91
158.79
585.97
158.83
+68 B
+41 B
WebGPU Nodes 541.29
148.37
541.36
148.4
+68 B
+32 B

@sunag sunag marked this pull request as ready for review January 24, 2025 02:05
@sunag sunag merged commit ac9c39e into mrdoob:dev Jan 24, 2025
12 checks passed
@sunag sunag deleted the dev-optz branch January 24, 2025 02:07
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.

1 participant