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

WebGPU Storage buffer extension for matrices #29766

Closed

Conversation

Spiri0
Copy link
Contributor

@Spiri0 Spiri0 commented Oct 30, 2024

Related issue: #29760

Description

I added mat3 and mat4 to the storagebuffers.
So far you can use scalars and vectors but it is also desirable to store matrices in storage buffers.
This means that object calculations for which matrices are necessary can be carried out in the GPU with compute shaders instead of in the CPU. This is very useful for drawIndirect topics.

code produced by WGSLNodeBuilder.js

my new mat 3 and mat 4 test storage buffers
struct NodeBuffer_566Struct {
	nodeUniform0 : mat4x4<f32> 

};
@binding( 1 ) @group( 0 )
var<storage, read> NodeBuffer_566 : NodeBuffer_566Struct;

struct NodeBuffer_567Struct {
	nodeUniform1 : mat3x3<f32> 

};
@binding( 3 ) @group( 0 )
var<storage, read> NodeBuffer_567 : NodeBuffer_567Struct;

my previous other storage buffers for position, normal, uv
struct NodeBuffer_550Struct {
	nodeUniform4 : array< vec3<f32> >

};
@binding( 2 ) @group( 1 )
var<storage, read> NodeBuffer_550 : NodeBuffer_550Struct;

struct NodeBuffer_551Struct {
	nodeUniform5 : array< vec3<f32> >

};
@binding( 4 ) @group( 1 )
var<storage, read> NodeBuffer_551 : NodeBuffer_551Struct;

struct NodeBuffer_552Struct {
	nodeUniform6 : array< vec2<f32> >

};
@binding( 6 ) @group( 1 )
var<storage, read> NodeBuffer_552 : NodeBuffer_552Struct;

I added mat3 and mat4 to the storagebuffers
Copy link

github-actions bot commented Oct 30, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 691.67
171.43
691.67
171.43
+0 B
+0 B
WebGPU 820.85
221.46
820.92
221.48
+77 B
+20 B
WebGPU Nodes 820.36
221.32
820.43
221.34
+77 B
+21 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 463.82
112.17
463.82
112.17
+0 B
+0 B
WebGPU 541.68
146.38
541.76
146.41
+77 B
+27 B
WebGPU Nodes 497.68
136.21
497.76
136.23
+77 B
+28 B

fixed lint issue
@Spiri0 Spiri0 changed the title Storage buffer extension for matrices WebGPU Storage buffer extension for matrices Oct 30, 2024
@Spiri0 Spiri0 closed this Oct 30, 2024
@Spiri0 Spiri0 deleted the storagebuffer-extension-for-matrices branch October 30, 2024 13:28
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