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

WebGPURenderer: Introduce indirect drawing support #29615

Merged
merged 4 commits into from
Oct 10, 2024
Merged

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Oct 10, 2024

Related issue: #29594

Description

This PR introduces indirect drawing support and a simple example in webgpu_particles.
Part of the work and also related to this result in #29594 PR

const uint32 = new Uint32Array( 5 );
uint32[ 0 ] = indexCount;	// indexCount
uint32[ 1 ] = fireCount; 	// instanceCount
uint32[ 2 ] = 0;		// firstIndex
uint32[ 3 ] = 0;		// baseVertex
uint32[ 4 ] = 0;		// firstInstance

const indirectAttribute = new THREE.IndirectStorageBufferAttribute( uint32, 5 );

geometry.setIndirect( indirectAttribute );

@sunag sunag added this to the r170 milestone Oct 10, 2024
Copy link

github-actions bot commented Oct 10, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 689.82
170.9
689.92
170.93
+97 B
+33 B
WebGPU 812.95
218.95
813.52
219.09
+572 B
+140 B
WebGPU Nodes 812.46
218.82
813.03
218.94
+572 B
+123 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 462.84
111.78
462.94
111.81
+97 B
+27 B
WebGPU 536.92
144.9
537.35
145
+433 B
+98 B
WebGPU Nodes 493.03
134.63
493.46
134.72
+433 B
+96 B

@sunag sunag marked this pull request as ready for review October 10, 2024 20:47
@sunag sunag merged commit f4afcaa into mrdoob:dev Oct 10, 2024
12 checks passed
@sunag sunag deleted the dev-indirect branch October 10, 2024 21:20
@Spiri0
Copy link
Contributor

Spiri0 commented Oct 20, 2024

I thought I would use another interesting example to test this and it works really well

https://codepen.io/Spiri0/pen/zYgzgJR?editors=0111

When I wanted to test this in my app, it kept giving me this error message over and over again

image

The console messages drawIndexedIndirect and draw come from my analysis. After hours of troubleshooting, I found the cause and it can easily be reproduced using this example. The cause is "material.wireframe = true" which I always had on in my app and that forces the indexed path in the backend. Everything is fine without material.wireframe = true;
So this is not an error in the drawIndirect logic.

image

Now I need a break, it was a Sisyphean task to find that. I could look into this over the next week as to why wireframe = true forces the indexed path even if you don't set any indexes in InstancedBufferGeometry

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.

2 participants