Skip to content

Commit

Permalink
Filter out negative samples
Browse files Browse the repository at this point in the history
  • Loading branch information
eliemichel committed Nov 14, 2024
1 parent f97a9bb commit 686c801
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sample/timestampQuery/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 686c801

Please sign in to comment.