From 2e3489a88969f887eeea3ae10893e2558d8b8bff Mon Sep 17 00:00:00 2001 From: Elie Michel Date: Fri, 15 Nov 2024 00:05:18 +0100 Subject: [PATCH] Update sample/timestampQuery/TimestampQueryManager.ts Co-authored-by: Kai Ninomiya --- sample/timestampQuery/TimestampQueryManager.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sample/timestampQuery/TimestampQueryManager.ts b/sample/timestampQuery/TimestampQueryManager.ts index 6dd9529b..0f7e7735 100644 --- a/sample/timestampQuery/TimestampQueryManager.ts +++ b/sample/timestampQuery/TimestampQueryManager.ts @@ -75,24 +75,22 @@ export default class TimestampQueryManager { } // Once resolved, we can read back the value of timestamps - readAsync(onTimestampReadBack: (timestamps: BigUint64Array) => void) { - if (!this.timestampSupported) return new Promise(() => {}); - if (this.hasOngoingTimestampReadback) return new Promise(() => {}); + readAsync(onTimestampReadBack: (timestamps: BigUint64Array) => void): void { + if (!this.timestampSupported) return; + if (this.hasOngoingTimestampReadback) return; this.hasOngoingTimestampReadback = true; const buffer = this.timestampMapBuffer; - return new Promise(resolve => { - buffer.mapAsync(GPUMapMode.READ, 0, buffer.size) + void buffer.mapAsync(GPUMapMode.READ) .then(() => { - const rawData = buffer.getMappedRange(0, buffer.size); + const rawData = buffer.getMappedRange(); const timestamps = new BigUint64Array(rawData); onTimestampReadBack(timestamps); buffer.unmap(); this.hasOngoingTimestampReadback = false; - }) - }); + }); } }