GPU: VICTORY_LIBRARY_TIMING measures the host FidelityFX upscaler's GPU and CPU cost #1904

Open
github-bot wants to merge 2 commits from github-bot/gh-1904 into main AGit
Owner

@⁠AwkGrep256 on GitHub · 2026-11-25 00:29 UTC · original
AwkGrep256:ffx-gpu-timing → main · +255 −0 · 5 files · 2 commits · open

Important

Measure what FSR costs inside a frame. main runs the host FidelityFX upscaler. This PR adds Windows D3D12 diagnostics that isolate the upscaler’s GPU work and CPU recording time from the rest of the frame. That makes it possible to assess the cost of FSR when comparing render scales.

✅ On an RX 9070 XT, VICTORY_LIBRARY_TIMING=1 measured 1.32 ms GPU and 80 µs CPU per FSR 4.1.2 upscale at the median. The GPU work was about 1% of frame GPU time in that run. Timing is off by default.

The Series X measurement used #1793’s switches. The instrumentation works independently of #1793 and #1917. Passing Windows CI for this head

Diagnostics switch

Switch Effect
VICTORY_LIBRARY_TIMING=1 Each host library call gets a GPU timestamp before and after it, read when its list is reset (its submission has finished), plus the CPU time of the call. Every 60 calls one line reports the GPU time (average, median, slowest) and the average CPU time. Each call is also logged at debug level (VICTORY_LOG=victory_gpu::library_timing=debug).

Off by default and diagnostics-only; when off nothing is recorded. Up to 64 calls can be in flight; past that a call is not timed.

Measurement in the title

Series X profile, title 1.0.2.1, AMD Radeon RX 9070 XT, Windows 11, diag build of main 02fcf5b with #1793 applied for the Series X switches, FidelityFX SDK 2.4.0 signedbin, FSR 4.1.2, 1080p rendered to a 4K output. 50 upscales in the world.

Min Median Max
GPU time per upscale 1.18 ms 1.32 ms 1.36 ms
CPU time to record it 51 µs 80 µs 36.6 ms (first call: the provider's one-time setup)

For scale, the same frames took 100 to 187 ms on the GPU (1.1 to 2.9 s per frame in all), so the upscaler is about 1 % of the frame's GPU time. Rendering 1080p instead of native 4K saves far more than that.

Tested

Check Result
Unit tests: milliseconds from ticks, report statistics ✅
GPU test: a timed call on a real list reads ordered, non-zero timestamps (RX 9070 XT) ✅
cargo clippy --workspace --all-targets -- -D warnings, with and without diagnostics ✅
The title run above ✅
**@⁠AwkGrep256** on GitHub · 2026-11-25 00:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1904) `AwkGrep256:ffx-gpu-timing` → `main` · +255 −0 · 5 files · 2 commits · open > [!IMPORTANT] > **Measure what FSR costs inside a frame.** `main` runs the host FidelityFX upscaler. This PR adds Windows D3D12 diagnostics that isolate the upscaler’s GPU work and CPU recording time from the rest of the frame. That makes it possible to assess the cost of FSR when comparing render scales. > > ✅ On an RX 9070 XT, `VICTORY_LIBRARY_TIMING=1` measured **1.32 ms GPU** and **80 µs CPU** per FSR 4.1.2 upscale at the median. The GPU work was about **1%** of frame GPU time in that run. Timing is off by default. > > The Series X measurement used #1793’s switches. The instrumentation works independently of #1793 and #1917. [Passing Windows CI for this head](https://github.com/Marvisak/VIctory/actions/runs/45522867288) ## Diagnostics switch | Switch | Effect | |---|---| | `VICTORY_LIBRARY_TIMING=1` | Each host library call gets a GPU timestamp before and after it, read when its list is reset (its submission has finished), plus the CPU time of the call. Every 60 calls one line reports the GPU time (average, median, slowest) and the average CPU time. Each call is also logged at debug level (`VICTORY_LOG=victory_gpu::library_timing=debug`). | Off by default and diagnostics-only; when off nothing is recorded. Up to 64 calls can be in flight; past that a call is not timed. ## Measurement in the title Series X profile, title 1.0.2.1, AMD Radeon RX 9070 XT, Windows 11, diag build of main `02fcf5b` with #1793 applied for the Series X switches, FidelityFX SDK 2.4.0 `signedbin`, FSR 4.1.2, 1080p rendered to a 4K output. 50 upscales in the world. | | Min | Median | Max | |---|---|---|---| | GPU time per upscale | 1.18 ms | **1.32 ms** | 1.36 ms | | CPU time to record it | 51 µs | **80 µs** | 36.6 ms (first call: the provider's one-time setup) | For scale, the same frames took 100 to 187 ms on the GPU (1.1 to 2.9 s per frame in all), so the upscaler is about 1 % of the frame's GPU time. Rendering 1080p instead of native 4K saves far more than that. ## Tested | Check | Result | |---|---| | Unit tests: milliseconds from ticks, report statistics | ✅ | | GPU test: a timed call on a real list reads ordered, non-zero timestamps (RX 9070 XT) | ✅ | | `cargo clippy --workspace --all-targets -- -D warnings`, with and without `diagnostics` | ✅ | | The title run above | ✅ |
The host FidelityFX upscaler records its passes into the title's list
through external::record, and nothing measured what that costs. With
VICTORY_LIBRARY_TIMING=1 (diagnostics) each such call gets a GPU
timestamp before and after it, resolved into a read-back buffer and
read when the list is reset (its submission has finished), plus the CPU
time of the call. Every 60 calls one line reports the GPU time
(average, median, slowest) and the average CPU time.

Up to 64 calls can be in flight; past that a call is not timed. Off,
nothing is recorded.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:48:11 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:18 UTC · original · edited 2026-11-25 16:46 UTC

Automated triage for the maintainers.

Merge candidate.

Adds VICTORY_LIBRARY_TIMING=1 (diagnostics feature only, off by default): external::record brackets the host library's recording with two timestamp queries, resolves them into a read-back buffer, and HostList::reset (called only after the list's submissions finished) reads them and logs GPU/CPU statistics every 60 calls (crates/victory-gpu/src/library_timing.rs). The query heap/read-back setup, the 64-pair cap and the out-of-order guard in ticks_ms read correctly, and nothing runs when the switch is off. The README line is a single row in the existing switch table.

Optional: main reads switches with crate::switch::on (treats any value but 0 as on); using it here instead of the hand-written == "1" check would match the other VICTORY_* switches. Pairs taken by a list that is dropped without a reset stay busy, which only reduces how many calls get timed.

CI (check): passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1904#issuecomment-7156871719) · edited 2026-11-25 16:46 UTC <!-- victory-triage v1 head=841dc30949f85fb14a92759e92212ced272b1499 verdict=merge-candidate at=2026-11-25T16:42:19Z --> Automated triage for the maintainers. **Merge candidate.** Adds `VICTORY_LIBRARY_TIMING=1` (diagnostics feature only, off by default): `external::record` brackets the host library's recording with two timestamp queries, resolves them into a read-back buffer, and `HostList::reset` (called only after the list's submissions finished) reads them and logs GPU/CPU statistics every 60 calls (`crates/victory-gpu/src/library_timing.rs`). The query heap/read-back setup, the 64-pair cap and the out-of-order guard in `ticks_ms` read correctly, and nothing runs when the switch is off. The README line is a single row in the existing switch table. Optional: main reads switches with `crate::switch::on` (treats any value but `0` as on); using it here instead of the hand-written `== "1"` check would match the other `VICTORY_*` switches. Pairs taken by a list that is dropped without a reset stay busy, which only reduces how many calls get timed. CI (`check`): passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1904/head:github-bot/gh-1904'
git switch 'github-bot/gh-1904'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1904'
git switch 'github-bot/gh-1904'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1904'
git switch 'github-bot/gh-1904'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1904'
git switch 'main'
git merge --squash 'github-bot/gh-1904'
git switch 'main'
git merge --ff-only 'github-bot/gh-1904'
git switch 'main'
git merge 'github-bot/gh-1904'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1904
No description provided.