Skip to content

Commit db8ea42

Browse files
committed
update and cache compute pass labels
1 parent 71c6a2b commit db8ea42

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
@@ -1297,7 +1297,7 @@ class WebGPUBackend extends Backend {
12971297

12981298
}
12991299

1300-
// compute
1300+
13011301

13021302
/**
13031303
* This method is executed at the beginning of a compute call and
@@ -1309,17 +1309,39 @@ class WebGPUBackend extends Backend {
13091309

13101310
const groupGPU = this.get( computeGroup );
13111311

1312-
//
1312+
if ( groupGPU.computePassDescriptor === undefined ) {
13131313

1314-
const descriptor = {
1315-
label: 'computeGroup_' + computeGroup.id
1316-
};
1314+
let computePassLabel = 'computeGroup[';
1315+
1316+
if ( Array.isArray( computeGroup ) ) {
1317+
1318+
for ( let i = 0; i < computeGroup.length; i ++ ) {
1319+
1320+
const group = computeGroup[ i ];
1321+
computePassLabel += `${group.name}_${group.id}${i !== computeGroup.length - 1 ? ',' : ''}`;
1322+
1323+
}
1324+
1325+
} else {
1326+
1327+
computePassLabel += `${computeGroup.name}_${computeGroup.id}`;
1328+
1329+
}
1330+
1331+
computePassLabel += ']';
1332+
1333+
const descriptor = { label: computePassLabel };
1334+
1335+
groupGPU.computePassDescriptor = descriptor;
1336+
1337+
}
1338+
//
13171339

1318-
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), descriptor );
1340+
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), groupGPU.computePassDescriptor );
13191341

1320-
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( { label: 'computeGroup_' + computeGroup.id } );
1342+
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( groupGPU.computePassDescriptor );
13211343

1322-
groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( descriptor );
1344+
groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( groupGPU.computePassDescriptor );
13231345

13241346
}
13251347

0 commit comments

Comments
 (0)