diff --git a/examples/webgpu_compute_birds.html b/examples/webgpu_compute_birds.html index a5f64a6b1d434a..4ab063caa5e7bd 100644 --- a/examples/webgpu_compute_birds.html +++ b/examples/webgpu_compute_birds.html @@ -472,8 +472,8 @@ effectController.rayOrigin.value.copy( raycaster.ray.origin ); effectController.rayDirection.value.copy( raycaster.ray.direction ); - renderer.compute( computeVelocity ); - renderer.compute( computePosition ); + renderer.compute( [ computeVelocity, computePosition ] ); + //renderer.compute( computePosition ); renderer.render( scene, camera ); diff --git a/src/renderers/common/Renderer.js b/src/renderers/common/Renderer.js index daf9d6d0fd9c92..c6f98be8a27a50 100644 --- a/src/renderers/common/Renderer.js +++ b/src/renderers/common/Renderer.js @@ -2419,7 +2419,7 @@ class Renderer { * Execute a single or an array of compute nodes. This method can only be called * if the renderer has been initialized. * - * @param {Node|Array} computeNodes - The compute node(s). + * @param {ComputeNode|Array} computeNodes - The compute node(s) to be executed. * @param {?(Array|number)} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count. * @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized. */ diff --git a/src/renderers/webgpu/WebGPUBackend.js b/src/renderers/webgpu/WebGPUBackend.js index d75cca0e13ad02..22126c335857ee 100644 --- a/src/renderers/webgpu/WebGPUBackend.js +++ b/src/renderers/webgpu/WebGPUBackend.js @@ -1322,17 +1322,39 @@ class WebGPUBackend extends Backend { const groupGPU = this.get( computeGroup ); - // + if ( groupGPU.computePassDescriptor === undefined ) { - const descriptor = { - label: 'computeGroup_' + computeGroup.id - }; + let computePassLabel = 'computeGroup['; + + if ( Array.isArray( computeGroup ) ) { + + for ( let i = 0; i < computeGroup.length; i ++ ) { + + const group = computeGroup[ i ]; + computePassLabel += `${group.name}_${group.id}${i !== computeGroup.length - 1 ? ',' : ''}`; + + } + + } else { + + computePassLabel += `${computeGroup.name}_${computeGroup.id}`; + + } + + computePassLabel += ']'; + + const descriptor = { label: computePassLabel }; + + groupGPU.computePassDescriptor = descriptor; + + } + // - this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), descriptor ); + this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), groupGPU.computePassDescriptor ); - groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( { label: 'computeGroup_' + computeGroup.id } ); + groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( groupGPU.computePassDescriptor ); - groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( descriptor ); + groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( groupGPU.computePassDescriptor ); }