Skip to content

Commit 58c4f4f

Browse files
committed
update and cache compute pass labels
1 parent 3a0a8d9 commit 58c4f4f

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

examples/webgpu_compute_birds.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@
412412

413413
} )().compute( BIRDS ).setName( 'Birds Velocity' );
414414

415+
console.log( computeVelocity );
416+
415417
computePosition = Fn( () => {
416418

417419
const { deltaTime } = effectController;
@@ -472,8 +474,8 @@
472474
effectController.rayOrigin.value.copy( raycaster.ray.origin );
473475
effectController.rayDirection.value.copy( raycaster.ray.direction );
474476

475-
renderer.compute( computeVelocity );
476-
renderer.compute( computePosition );
477+
renderer.compute( [ computeVelocity, computePosition ] );
478+
//renderer.compute( computePosition );
477479

478480
renderer.render( scene, camera );
479481

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ class WebGPUBackend extends Backend {
13101310

13111311
}
13121312

1313-
// compute
1313+
13141314

13151315
/**
13161316
* This method is executed at the beginning of a compute call and
@@ -1322,17 +1322,39 @@ class WebGPUBackend extends Backend {
13221322

13231323
const groupGPU = this.get( computeGroup );
13241324

1325-
//
1325+
if ( groupGPU.computePassDescriptor === undefined ) {
13261326

1327-
const descriptor = {
1328-
label: 'computeGroup_' + computeGroup.id
1329-
};
1327+
let computePassLabel = 'computeGroup[';
1328+
1329+
if ( Array.isArray( computeGroup ) ) {
1330+
1331+
for ( let i = 0; i < computeGroup.length; i ++ ) {
1332+
1333+
const group = computeGroup[ i ];
1334+
computePassLabel += `${group.name}_${group.id}${i !== computeGroup.length - 1 ? ',' : ''}`;
1335+
1336+
}
1337+
1338+
} else {
1339+
1340+
computePassLabel += `${computeGroup.name}_${computeGroup.id}`;
1341+
1342+
}
1343+
1344+
computePassLabel += ']';
1345+
1346+
const descriptor = { label: computePassLabel };
1347+
1348+
groupGPU.computePassDescriptor = descriptor;
1349+
1350+
}
1351+
//
13301352

1331-
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), descriptor );
1353+
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), groupGPU.computePassDescriptor );
13321354

1333-
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( { label: 'computeGroup_' + computeGroup.id } );
1355+
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( groupGPU.computePassDescriptor );
13341356

1335-
groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( descriptor );
1357+
groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( groupGPU.computePassDescriptor );
13361358

13371359
}
13381360

0 commit comments

Comments
 (0)