From 686c8014b2826bfe5358986e1be8984403db39e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Michel?= Date: Thu, 14 Nov 2024 18:58:01 +0100 Subject: [PATCH] Filter out negative samples --- sample/timestampQuery/main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sample/timestampQuery/main.ts b/sample/timestampQuery/main.ts index a1bb4f46..0b2e6707 100644 --- a/sample/timestampQuery/main.ts +++ b/sample/timestampQuery/main.ts @@ -230,6 +230,9 @@ function frame() { // Read timestamp value back from GPU buffers timestampQueryManager .readAsync(timestamps => { + // This may happen (see spec https://gpuweb.github.io/gpuweb/#timestamp) + if (timestamps[1] < timestamps[0]) return; + // Measure difference (in bigints) const elapsedNs = timestamps[1] - timestamps[0]; // Cast into regular int (ok because value is small after difference)