Skip to content

Commit

Permalink
Implement changes to WebGPU timestamp-query
Browse files Browse the repository at this point in the history
Remove call to GPURenderPassEncoder.writeTimestamp as it is not part of
the spec anymore, and was removed by Chrome. It is also not needed
anymore.

The new interface, GPURenderPassDescriptor.timestampWrites was already
implemented so nothing is needed there.
  • Loading branch information
erikdubbelboer committed Jan 27, 2024
1 parent dc499b7 commit 4711709
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
29 changes: 0 additions & 29 deletions src/platform/graphics/webgpu/webgpu-gpu-profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,18 @@ class WebgpuGpuProfiler extends GpuProfiler {
this.timestampQueriesSet = null;
}

frameMarker(isStart) {

if (this.timestampQueriesSet) {

const suffix = isStart ? 'Start' : 'End';
const commandEncoder = this.device.wgpu.createCommandEncoder();
DebugHelper.setLabel(commandEncoder, `GPUTimestampEncoder-${suffix}`);

this.frameGPUMarkerSlot = isStart ? this.getSlot('GpuFrame') : this.frameGPUMarkerSlot;
commandEncoder.writeTimestamp(this.timestampQueriesSet.querySet, this.frameGPUMarkerSlot * 2 + (isStart ? 0 : 1));

const cb = commandEncoder.finish();
DebugHelper.setLabel(cb, `GPUTimestampEncoder-${suffix}-CommandBuffer`);

this.device.addCommandBuffer(cb, isStart);
}
}

frameStart() {

this.processEnableRequest();

if (this._enabled) {
// initial timing marker
this.frameMarker(true);
}
}

frameEnd() {

if (this._enabled) {
// final timing marker
this.frameMarker(false);

// schedule command buffer where timestamps are copied to CPU
this.timestampQueriesSet?.resolve(this.slotCount * 2);
}
}

request() {

if (this._enabled) {
// request results
const renderVersion = this.device.renderVersion;
Expand Down
5 changes: 1 addition & 4 deletions src/platform/graphics/webgpu/webgpu-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
this.extCompressedTextureS3TC = requireFeature('texture-compression-bc');
this.extCompressedTextureETC = requireFeature('texture-compression-etc2');
this.extCompressedTextureASTC = requireFeature('texture-compression-astc');

// Do not request timestamp feature as it has changed and current form is not supported.
// See engine issue #5989
// this.supportsTimestampQuery = requireFeature('timestamp-query');
this.supportsTimestampQuery = requireFeature('timestamp-query');

this.textureRG11B10Renderable = requireFeature('rg11b10ufloat-renderable');
Debug.log(`WEBGPU features: ${requiredFeatures.join(', ')}`);
Expand Down

0 comments on commit 4711709

Please sign in to comment.