Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Nov 19, 2024
1 parent 469f3ab commit ff0c3e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions sample/timestampQuery/TimestampQueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export default class TimestampQueryManager {
// A buffer to map this result back to CPU
#timestampMapBuffer: GPUBuffer;

// Last queried elapsed time of the pass.
passElapsedTime: number;
// Last queried elapsed time of the pass in nanoseconds.
passDurationMeasurementNs: number;

// Device must have the "timestamp-query" feature
constructor(device: GPUDevice) {
this.timestampSupported = device.features.has('timestamp-query');
if (!this.timestampSupported) return;

this.passElapsedTime = 0;
this.passDurationMeasurementNs = 0;

// Create timestamp queries
this.#timestampQuerySet = device.createQuerySet({
Expand Down Expand Up @@ -101,7 +101,7 @@ export default class TimestampQueryManager {
// It's possible elapsedNs is negative which means it's invalid
// (see spec https://gpuweb.github.io/gpuweb/#timestamp)
if (elapsedNs >= 0) {
this.passElapsedTime = elapsedNs;
this.passDurationMeasurementNs = elapsedNs;
}
buffer.unmap();
});
Expand Down
2 changes: 1 addition & 1 deletion sample/timestampQuery/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function frame() {

if (timestampQueryManager.timestampSupported) {
// Show the last successfully downloaded elapsed time.
const elapsedNs = timestampQueryManager.passElapsedTime;
const elapsedNs = timestampQueryManager.passDurationMeasurementNs;
// Convert from nanoseconds to milliseconds:
const elapsedMs = Number(elapsedNs) * 1e-6;
renderPassDurationCounter.addSample(elapsedMs);
Expand Down

0 comments on commit ff0c3e7

Please sign in to comment.