Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/webgpu_compute_birds.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Node>} computeNodes - The compute node(s).
* @param {ComputeNode|Array<ComputeNode>} computeNodes - The compute node(s) to be executed.
* @param {?(Array<number>|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.
*/
Expand Down
36 changes: 29 additions & 7 deletions src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

}

Expand Down