Skip to content

Fix overestimated WebGPU GPU frame timing in profiler#8903

Merged
mvaligursky merged 1 commit into
mainfrom
mv-webgpu-gpu-frame-timing
Jun 15, 2026
Merged

Fix overestimated WebGPU GPU frame timing in profiler#8903
mvaligursky merged 1 commit into
mainfrom
mv-webgpu-gpu-frame-timing

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

The GPU time reported by the WebGPU profiler (and shown in mini-stats) was massively overestimated, growing with the number of render/compute passes even when the GPU was mostly idle. On tile-based / pipelined GPUs (Apple Silicon is a well known example) consecutive passes overlap in time — the vertex stage of one pass runs concurrently with the fragment stage of the previous one — so summing per-pass timestamp durations double-counts the overlap.

This reports the frame GPU time as the span between the earliest begin and latest end timestamp across all passes, which stays within the real frame time. Per-pass timings are kept as-is (useful for relative comparison) but are now clamped to be non-negative, fixing the negative readings some users observed.

Changes:

  • WebGPU frame GPU time is now the timestamp span (max end − min begin) across all passes, instead of the sum of per-pass durations.
  • Per-pass GPU durations are clamped to ≥ 0, fixing occasional negative timings caused by begin/end timestamps reported out of order by the driver.
  • WebGL profiling is unchanged — it already measures the whole frame with a single query, so its reported time does not overlap.
  • Fixed a debug-label bug where the timestamp staging buffer was mislabelled.

Closes #8350

Report frame GPU time as the span between the earliest begin and latest
end timestamp across all passes, instead of summing per-pass durations.
On tile-based / pipelined GPUs (e.g. Apple Silicon) consecutive passes
overlap in time, so summing double-counts the overlap and grows with the
number of passes even while the GPU is mostly idle.

Also clamp per-pass durations to be non-negative to fix occasional
negative readings from out-of-order begin/end timestamps, and fix a
debug-label bug on the query staging buffer. WebGL profiling is
unchanged.
@mvaligursky mvaligursky self-assigned this Jun 15, 2026
@mvaligursky mvaligursky merged commit 6d5f49c into main Jun 15, 2026
9 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-gpu-frame-timing branch June 15, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance metrics in WebGPU are totally incorrect

1 participant