-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Open
Labels
Description
Related issue: #31488
Description
Passing only an indirect buffer without accessing the buffer in a compute function produces this error.
Likely because this code in WebGPUBackend.js doesn't have a fallback condition when dispatchBuffer returns undefined.
Although indirect compute is most useful when the number of workgroups is defined by the GPU, I think for the sake of correctness we should still be able to create a minimum viable example where the indirect buffer is used without being modified.
// Line 1381 - 1389 of Renderer.js
if ( dispatchSize && typeof dispatchSize === 'object' && dispatchSize.isIndirectStorageBufferAttribute ) {
const dispatchBuffer = this.get( dispatchSize ).buffer;
passEncoderGPU.dispatchWorkgroupsIndirect( dispatchBuffer, 0 );
return;
}Reproduction steps
- On webgpu_compute_particles rain, at the top of the file, create an IndirectStorageBufferAttribute with the requisite number of workgroups to calculate the initial number of renderer rain particles.
const maxParticleCount = 50000;
const workgroupSize = 64;
const instanceCount = maxParticleCount / 2;
const startNumWorkgroups = Math.ceil( instanceCount / workgroupSize );
const workgroupGridIndirectBuffer = new THREE.IndirectStorageBufferAttribute( new Uint32Array( [ startNumWorkgroups, 1, 1 ]), 1 );- Modify computeParticles to account for the fact that the dispatchSize will be determined by a combination of the workgroupSize and the indirectBuffer rather than the count.
// count not taken into consideration when buffer is indirect
computeParticles = computeUpdate().compute( null, [ 64, 1, 1 ] ).setName( 'Particles' );- Modify the computeParticles call in the animation loop.
renderer.compute( computeParticles, workgroupGridIndirectBuffer );Code
Seen above.
Live example
Screenshots
No response
Version
r181
Device
Desktop
Browser
Chrome
OS
Windows