perf(vk): allocate FSR 3.1 internal images once at max_render_size across DRS steps on all GPUs #3096

Merged
HumanBean merged 3 commits from Jer9/Longshot:perf/vk-fsr3-drs-max-render-size into main 2026-12-04 00:28:13 +00:00
Member

Summary

What a player notices: When Dynamic Resolution Scaling (Auto) changes render resolution under AMD FSR 3.1, gameplay no longer hitches from destroying and reallocating all 22 internal FSR 3.1 images (plus the temporal chain's color/depth/motion/mask images) on every step, and temporal upscaling history stays intact without a reset flash. When Dynamic Resolution is Off (fixed render scale), render-sized images allocate at the fixed size; the SPD scratch image also retains fewer mip levels than on main.

  • Helps: All GPUs using AMD FSR 3.1 with Auto Dynamic Resolution Scaling (resolution=0).
  • No measurable impact in the reported runs: Fixed 50% render scale, with render-sized internal images allocated at exact rw x rh. Scenes where DRS never changes scale and non-FSR 3.1 upscalers do not benefit from DRS reuse.

Root Cause & Fix (gpu/vk/vk_fsr3.cpp, gpu/vk/vk_fsr3.h)

gpu/vk/vk_fsr3.cpp (prepare() and prepare_sizes()) previously required exact render_width / render_height equality, destroying and recreating all 22 internal Vulkan images, resetting g.first_evaluation = true / g.lut_uploaded = false / g.parity = 0, and returning 2 from prepare_sizes() (resetting vk_temporal.cpp history) on every DRS step — even though the vendored FidelityFX FSR 3.1 shaders already support dynamic render_size <= max_render_size via k.max_render_size and k.previous_render_size. Likewise, chain_prepare() returned rw, rh instead of max_render_width, max_render_height, causing vk_temporal.cpp to reallocate s.color, s.depth, and s.motion on every step.

  • Add dynamic_render_size() (opts.resolution == 0) and reusable() shared by prepare() and prepare_sizes().
  • Auto DRS (dynamic_render_size() == true): Allocate render-sized internal images once at mw = std::max(rw, uw), mh = std::max(rh, uh) (half-res at mw/2, mh/2), reuse them while rw <= max_render_width && rh <= max_render_height (prepare_sizes() returns 1, preserving history and Lanczos LUT), and return max_render_width/height from chain_prepare() (matching DLSS/FSR 4/XeSS).
  • Fixed scale (dynamic_render_size() == false): Allocate render-sized images at exact rw x rh and require render == max == rw x rh to reuse. Switching Auto -> Fixed retires the larger images; they are freed after GPU use completes.
  • Limit the SPD scratch image to the mip levels its callbacks bind. Capture the selected resolution mode during chain preparation so evaluation uses the same mode.
  • Pass k.max_render_size = {g.max_render_width, g.max_render_height} in upscale(), while k.render_size uses current rw, rh and k.previous_render_size keeps frame N-1's g.previous_render_size (matching FSR 3.1's ClampUv(..., PreviousFrameRenderSize(), MaxRenderSize())).

Testing

Tested on the earlier d4d502613 revision; the final changes have not been reported as tested: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (RDNA 3.5 iGPU, Adrenalin 26.10.1), windowed 1920x1080, FSR 3.1, both Auto DRS (100% render scale -> 50% render scale, n=4 interleaved ABBA runs) and Fixed 50% render scale (960x540 -> 1920x1080, n=2 ABBA VRAM check) on forge/main 6318f4056 (+ local 1-line Windows builder compile fix for sandbox_windows.rs:1654 note_lines outside this PR).

  • How to test:
    1. Set Upscaler: FSR 3.1 and Dynamic resolution: On (Auto, 50% floor) at 1920x1080.
    2. Walk Market_Child / HyruleField_Adult across DRS steps and verify only 1 vk: fsr3: ... (max 1920x1080) allocation and 0 dispatch vk: slow submit spikes in longshot_log.txt.
    3. Switch Dynamic resolution: Off (50% render scale) and verify vk: fsr3: 960x540 -> 1920x1080 (max 960x540) (zero over-allocation).
  • Game-free test (tests/test_fsr3_drs_resize.py): Commit 183d19d9d checks Auto DRS reuse (0 allocs/drops, k.previous_render_size / k.max_render_size, frame_index), Fixed-scale 1280x720 sizing and Auto <-> Fixed reclaim/regrow, release() and OOM zeroing of max_render_*; fails on forge/main, passes 133/133 checks with d4d502613.
  • Test suite: python -I -B tests/run_all.py --changed forge/main --strict passed 19 passed, 0 failed (3 Linux-only cmake/spirv-val skips). Full tests/run_all.py --strict baseline on 6318f4056 ran (831 passed, 9 failed, 51 skipped — pre-existing Windows env/main failures: test_helpers_extract, test_longshot_builder, test_utf8_paths (CP_ACP at hos_file_windows.c:645), test_run_all_junit, test_coverage_run, test_native_zstd, test_fsr4_tune, test_lifter, test_float_add_subgroup).

Still to test:

  • Tier 1 discrete NVIDIA RTX and AMD RX 6000–9000 (Windows + Linux RADV) with RX_VK_MIRROR=1 / RX_VK_ASYNC=1 (@Beanstalk / by hand)
  • Steam Deck and wave-less subgroup fallback (g.wave == false) (@Beanstalk / by hand)

Measurements

Verdict: Yes — cuts FSR 3.1 image allocations across 6 DRS steps from 7 to 1, eliminates dispatch vk: slow submit spikes (1 -> 0), improves HyruleField_Adult 1% low +3.6% (>50 ms spikes -45%), and confirms zero VRAM over-allocation at Fixed 50% render scale.

Setup: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (Adrenalin 26.10.1), windowed 1920x1080, FSR 3.1, 60 FPS cap, n=4 interleaved ABBA warm runs for Auto DRS (100% render scale -> 50% render scale) and n=2 ABBA runs for Fixed 50% render scale (960x540 -> 1920x1080).

Where it makes a difference:

Metric Before: main @ 6318f4056 After: this PR @ d4d502613 Delta
vk: fsr3: image allocations (6 DRS steps) 7 1 (max 1920x1080) -85.7%
dispatch vk: slow submit (Market / Hyrule) 1 / 1 0 / 0 -100%
HyruleField_Adult median 1% low (Auto DRS) 17.63 FPS 18.26 FPS +3.6%
HyruleField_Adult median p99 frame time (Auto DRS) 54.0 ms 52.2 ms -3.3%
HyruleField_Adult median >50 ms spikes (Auto DRS) 16.5 9.0 -45.5%

Where it does NOT make a difference (within run-to-run variance):

Metric Before: main @ 6318f4056 After: this PR @ d4d502613 Delta
Market_Child median FPS (Auto DRS) 34.36 FPS 34.56 FPS +0.6%
Market_Child median 1% low (Auto DRS) 28.14 FPS 28.20 FPS +0.2%
HyruleField_Adult median FPS (Auto DRS) 32.84 FPS 32.75 FPS -0.3%
Fixed 50% render scale (960x540) VRAM (Market) 2933 / 2965 MB 2965 / 2997 MB (max 960x540) ~0% (no 1080p over-alloc)
# Auto DRS (Market_Child): 1 allocation vs 7 on main
[hos host] vk: fsr3: 1920x1080 -> 1920x1080 (max 1920x1080)

# Fixed 50% render scale (Market_Child): exact 960x540 allocation (0 over-allocation)
[hos host] vk: fsr3: 960x540 -> 1920x1080 (max 960x540)

Risks

  • When Auto DRS is enabled (opts.resolution == 0) at a lower scale than upscale_size, FSR 3.1's internal render-sized images and temporal chain inputs remain allocated at max(rw, uw) x max(rh, uh) until the player switches to a fixed render scale or disables FSR 3.1 (which retires them for release after GPU use completes).
  • RX_VK_FSR3_CHAIN=0 (vk_fsr3_inputs.cpp) is a legacy fallback path and still reallocates its 3 input images on resize.
  • Reversible by reverting gpu/vk/vk_fsr3.cpp and gpu/vk/vk_fsr3.h; no save, settings, or shader-cache impact.

Checklist

Ready for review

  • One topic, on current main (6318f4056); the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (tests/run_all.py --changed forge/main --strict: 19 passed, 0 failed; clean 6318f4056 baseline pre-existing Windows failures named in Testing).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here (tests/test_fsr3_drs_resize.py, commit 183d19d9d).
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers on every commit.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary **What a player notices:** When Dynamic Resolution Scaling (Auto) changes render resolution under AMD FSR 3.1, gameplay no longer hitches from destroying and reallocating all 22 internal FSR 3.1 images (plus the temporal chain's `color`/`depth`/`motion`/`mask` images) on every step, and temporal upscaling history stays intact without a reset flash. When Dynamic Resolution is Off (fixed render scale), render-sized images allocate at the fixed size; the SPD scratch image also retains fewer mip levels than on `main`. - **Helps:** All GPUs using AMD FSR 3.1 with Auto Dynamic Resolution Scaling (`resolution=0`). - **No measurable impact in the reported runs:** Fixed `50%` render scale, with render-sized internal images allocated at exact `rw x rh`. Scenes where DRS never changes scale and non-FSR 3.1 upscalers do not benefit from DRS reuse. ### Root Cause & Fix (`gpu/vk/vk_fsr3.cpp`, `gpu/vk/vk_fsr3.h`) `gpu/vk/vk_fsr3.cpp` (`prepare()` and `prepare_sizes()`) previously required exact `render_width` / `render_height` equality, destroying and recreating all 22 internal Vulkan images, resetting `g.first_evaluation = true` / `g.lut_uploaded = false` / `g.parity = 0`, and returning `2` from `prepare_sizes()` (resetting `vk_temporal.cpp` history) on every DRS step — even though the vendored FidelityFX FSR 3.1 shaders already support dynamic `render_size <= max_render_size` via `k.max_render_size` and `k.previous_render_size`. Likewise, `chain_prepare()` returned `rw, rh` instead of `max_render_width, max_render_height`, causing `vk_temporal.cpp` to reallocate `s.color`, `s.depth`, and `s.motion` on every step. - Add `dynamic_render_size()` (`opts.resolution == 0`) and `reusable()` shared by `prepare()` and `prepare_sizes()`. - **Auto DRS (`dynamic_render_size() == true`):** Allocate render-sized internal images once at `mw = std::max(rw, uw)`, `mh = std::max(rh, uh)` (half-res at `mw/2, mh/2`), reuse them while `rw <= max_render_width && rh <= max_render_height` (`prepare_sizes()` returns `1`, preserving history and Lanczos LUT), and return `max_render_width/height` from `chain_prepare()` (matching DLSS/FSR 4/XeSS). - **Fixed scale (`dynamic_render_size() == false`):** Allocate render-sized images at exact `rw x rh` and require `render == max == rw x rh` to reuse. Switching `Auto -> Fixed` retires the larger images; they are freed after GPU use completes. - Limit the SPD scratch image to the mip levels its callbacks bind. Capture the selected resolution mode during chain preparation so evaluation uses the same mode. - Pass `k.max_render_size = {g.max_render_width, g.max_render_height}` in `upscale()`, while `k.render_size` uses current `rw, rh` and `k.previous_render_size` keeps frame `N-1`'s `g.previous_render_size` (matching FSR 3.1's `ClampUv(..., PreviousFrameRenderSize(), MaxRenderSize())`). ## Testing **Tested on the earlier `d4d502613` revision; the final changes have not been reported as tested:** Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (RDNA 3.5 iGPU, Adrenalin 26.10.1), windowed `1920x1080`, FSR 3.1, both Auto DRS (`100% render scale -> 50% render scale`, `n=4` interleaved ABBA runs) and Fixed `50% render scale` (`960x540 -> 1920x1080`, `n=2` ABBA VRAM check) on `forge/main` `6318f4056` (+ local 1-line Windows builder compile fix for `sandbox_windows.rs:1654` `note_lines` outside this PR). - **How to test:** 1. Set **Upscaler: FSR 3.1** and **Dynamic resolution: On** (`Auto`, `50%` floor) at `1920x1080`. 2. Walk `Market_Child` / `HyruleField_Adult` across DRS steps and verify only 1 `vk: fsr3: ... (max 1920x1080)` allocation and `0` `dispatch` `vk: slow submit` spikes in `longshot_log.txt`. 3. Switch **Dynamic resolution: Off** (`50% render scale`) and verify `vk: fsr3: 960x540 -> 1920x1080 (max 960x540)` (zero over-allocation). - **Game-free test (`tests/test_fsr3_drs_resize.py`):** Commit `183d19d9d` checks Auto DRS reuse (`0` allocs/drops, `k.previous_render_size` / `k.max_render_size`, `frame_index`), Fixed-scale `1280x720` sizing and `Auto <-> Fixed` reclaim/regrow, `release()` and OOM zeroing of `max_render_*`; fails on `forge/main`, passes `133/133` checks with `d4d502613`. - **Test suite:** `python -I -B tests/run_all.py --changed forge/main --strict` passed `19 passed, 0 failed` (`3` Linux-only `cmake`/`spirv-val` skips). Full `tests/run_all.py --strict` baseline on `6318f4056` ran (`831 passed, 9 failed, 51 skipped` — pre-existing Windows env/main failures: `test_helpers_extract`, `test_longshot_builder`, `test_utf8_paths` (`CP_ACP` at `hos_file_windows.c:645`), `test_run_all_junit`, `test_coverage_run`, `test_native_zstd`, `test_fsr4_tune`, `test_lifter`, `test_float_add_subgroup`). **Still to test:** - Tier 1 discrete NVIDIA RTX and AMD RX 6000–9000 (Windows + Linux RADV) with `RX_VK_MIRROR=1` / `RX_VK_ASYNC=1` (`@Beanstalk` / by hand) - Steam Deck and wave-less subgroup fallback (`g.wave == false`) (`@Beanstalk` / by hand) ## Measurements **Verdict:** Yes — cuts FSR 3.1 image allocations across 6 DRS steps from `7` to `1`, eliminates `dispatch` `vk: slow submit` spikes (`1 -> 0`), improves `HyruleField_Adult` 1% low `+3.6%` (`>50 ms` spikes `-45%`), and confirms zero VRAM over-allocation at Fixed `50% render scale`. Setup: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (Adrenalin 26.10.1), windowed `1920x1080`, FSR 3.1, `60 FPS` cap, `n=4` interleaved ABBA warm runs for Auto DRS (`100% render scale -> 50% render scale`) and `n=2` ABBA runs for Fixed `50% render scale` (`960x540 -> 1920x1080`). **Where it makes a difference:** | Metric | Before: main @ 6318f4056 | After: this PR @ d4d502613 | Delta | |---|---:|---:|---:| | `vk: fsr3:` image allocations (6 DRS steps) | 7 | **1** (`max 1920x1080`) | **-85.7%** | | `dispatch` `vk: slow submit` (`Market` / `Hyrule`) | 1 / 1 | **0 / 0** | **-100%** | | `HyruleField_Adult` median 1% low (Auto DRS) | 17.63 FPS | **18.26 FPS** | **+3.6%** | | `HyruleField_Adult` median p99 frame time (Auto DRS) | 54.0 ms | **52.2 ms** | **-3.3%** | | `HyruleField_Adult` median `>50 ms` spikes (Auto DRS) | 16.5 | **9.0** | **-45.5%** | **Where it does NOT make a difference (within run-to-run variance):** | Metric | Before: main @ 6318f4056 | After: this PR @ d4d502613 | Delta | |---|---:|---:|---:| | `Market_Child` median FPS (Auto DRS) | 34.36 FPS | 34.56 FPS | +0.6% | | `Market_Child` median 1% low (Auto DRS) | 28.14 FPS | 28.20 FPS | +0.2% | | `HyruleField_Adult` median FPS (Auto DRS) | 32.84 FPS | 32.75 FPS | -0.3% | | Fixed `50% render scale` (`960x540`) VRAM (`Market`) | 2933 / 2965 MB | 2965 / 2997 MB (`max 960x540`) | ~0% (no 1080p over-alloc) | ```text # Auto DRS (Market_Child): 1 allocation vs 7 on main [hos host] vk: fsr3: 1920x1080 -> 1920x1080 (max 1920x1080) # Fixed 50% render scale (Market_Child): exact 960x540 allocation (0 over-allocation) [hos host] vk: fsr3: 960x540 -> 1920x1080 (max 960x540) ``` ## Risks - When Auto DRS is enabled (`opts.resolution == 0`) at a lower scale than `upscale_size`, FSR 3.1's internal render-sized images and temporal chain inputs remain allocated at `max(rw, uw) x max(rh, uh)` until the player switches to a fixed render scale or disables FSR 3.1 (which retires them for release after GPU use completes). - `RX_VK_FSR3_CHAIN=0` (`vk_fsr3_inputs.cpp`) is a legacy fallback path and still reallocates its 3 input images on resize. - Reversible by reverting `gpu/vk/vk_fsr3.cpp` and `gpu/vk/vk_fsr3.h`; no save, settings, or shader-cache impact. ## Checklist ### Ready for review - [x] One topic, on current `main` (`6318f4056`); the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (`tests/run_all.py --changed forge/main --strict`: `19 passed, 0 failed`; clean `6318f4056` baseline pre-existing Windows failures named in Testing). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here (`tests/test_fsr3_drs_resize.py`, commit `183d19d9d`). - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (`llvm-mingw`) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers on every commit. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (`docs/dev/standards.md`, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(fsr3): allocate internal images at max_render_size and reuse across DRS steps
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
e38ccf38c8
Author
Member

Tested in game: Windows 11 Radeon 860M 1920x1080 FSR 3.1 Auto DRS: 7 allocs -> 1, 0 dispatch slow submits, Market +28.3% / Hyrule +45.9% 1% low

Tested in game: Windows 11 Radeon 860M 1920x1080 FSR 3.1 Auto DRS: 7 allocs -> 1, 0 dispatch slow submits, Market +28.3% / Hyrule +45.9% 1% low
Jer9 force-pushed perf/vk-fsr3-drs-max-render-size from e38ccf38c8
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to d4d502613a
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-04 00:03:02 +00:00
Compare
Owner
@review
BeanBot left a comment

Recommendation: Approve. The new Auto-resolution check races with settings updates, and switching from a fixed scale to Auto can still cause a reallocation and history reset on the next upward DRS step. The allocation reduction is demonstrated on one GPU, but the Auto-mode memory and clear-bandwidth costs and Tier 1 behavior remain unmeasured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The change keeps FSR 3.1 images and temporal history across most Auto DRS steps, reducing allocation hitches. It trades those reallocations for larger resident images and full-image clears at reduced render scales.

Should fix (2): not blocking, but worth doing before merging.

  • L1 gpu/vk/vk_fsr3.cpp:419: This reads the mutable menu option without the lock used to update it. (more on the line) Do: Publish the selected Auto/fixed mode in a synchronized snapshot or read it under the same lock, and use one consistent value throughout preparation.
  • L2 gpu/vk/vk_fsr3.cpp:426: Entering Auto can reuse images made for a smaller fixed scale instead of allocating the Auto maximum. (more on the line) Do: When entering Auto, require the existing maximum to cover the intended Auto maximum, and update the transition test to require the allocation at the mode change.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 gpu/vk/vk_fsr3.cpp:456: The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. (more on the line) Do: Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device. (@fix does its part first: Clear only the active region where the Vulkan operation and shader requirements permit, or otherwise reduce the retained scratch allocation.)
  • L4 gpu/vk/vk_fsr3.cpp:571: The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. (more on the line) Do: Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.

@fix can do L1, L2 and L3.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes for allocation churn on the tested Radeon 860M: the PR reports 7 allocations versus 1 over six DRS steps and a median Hyrule Field 1% low of 17.63 versus 18.26 FPS across four interleaved runs. The frame-rate gain's spread and the Auto-mode memory and bandwidth costs are not reported.

Other systems: The temporal chain, the legacy FSR 3.1 input path, reactive masks, wave-less shaders, and all GPUs running FSR 3.1 can use the changed state. The PR reports a Windows Radeon 860M run; NVIDIA, discrete AMD on Windows and Linux, Steam Deck, and the wave-less fallback remain untested.

Switches: No switches added, changed, or removed. Existing RX_VK_FSR3_CHAIN=0 retains its separate input allocations and resets history on resize.

Reviewed: d4d502613a against 6318f4056e: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the diff and commits, both changed renderer files and the new test, and the relevant temporal-chain, settings, input and FSR shader paths. Skimmed the remaining vendored shader code; docs/review-checklist.md and ../Tooling/AGENTS.md are absent. No recorded runs, translations or generated files were changed.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance.
  • No game-derived files, generated files, API version changes, or new switches appear in the diff.
  • The game-free test exercises allocation reuse, constants, release and allocation failure with spies.

Testing: Read-only review; no code, tests, builds or project scripts were run. The supplied CI checks are still running.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The new Auto-resolution check races with settings updates, and switching from a fixed scale to Auto can still cause a reallocation and history reset on the next upward DRS step. The allocation reduction is demonstrated on one GPU, but the Auto-mode memory and clear-bandwidth costs and Tier 1 behavior remain unmeasured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The change keeps FSR 3.1 images and temporal history across most Auto DRS steps, reducing allocation hitches. It trades those reallocations for larger resident images and full-image clears at reduced render scales. **Should fix (2)**: not blocking, but worth doing before merging. - **L1** `gpu/vk/vk_fsr3.cpp:419`: This reads the mutable menu option without the lock used to update it. (more on the line) **Do:** Publish the selected Auto/fixed mode in a synchronized snapshot or read it under the same lock, and use one consistent value throughout preparation. - **L2** `gpu/vk/vk_fsr3.cpp:426`: Entering Auto can reuse images made for a smaller fixed scale instead of allocating the Auto maximum. (more on the line) **Do:** When entering Auto, require the existing maximum to cover the intended Auto maximum, and update the transition test to require the allocation at the mode change. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `gpu/vk/vk_fsr3.cpp:456`: The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. (more on the line) **Do:** Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device. *(`@fix` does its part first: Clear only the active region where the Vulkan operation and shader requirements permit, or otherwise reduce the retained scratch allocation.)* - **L4** `gpu/vk/vk_fsr3.cpp:571`: The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. (more on the line) **Do:** Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR. `@fix` can do L1, L2 and L3. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for allocation churn on the tested Radeon 860M: the PR reports 7 allocations versus 1 over six DRS steps and a median Hyrule Field 1% low of 17.63 versus 18.26 FPS across four interleaved runs. The frame-rate gain's spread and the Auto-mode memory and bandwidth costs are not reported. **Other systems:** The temporal chain, the legacy FSR 3.1 input path, reactive masks, wave-less shaders, and all GPUs running FSR 3.1 can use the changed state. The PR reports a Windows Radeon 860M run; NVIDIA, discrete AMD on Windows and Linux, Steam Deck, and the wave-less fallback remain untested. **Switches:** No switches added, changed, or removed. Existing RX_VK_FSR3_CHAIN=0 retains its separate input allocations and resets history on resize. **Reviewed:** d4d502613a71 against 6318f4056eed: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the diff and commits, both changed renderer files and the new test, and the relevant temporal-chain, settings, input and FSR shader paths. Skimmed the remaining vendored shader code; docs/review-checklist.md and ../Tooling/AGENTS.md are absent. No recorded runs, translations or generated files were changed.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance. - No game-derived files, generated files, API version changes, or new switches appear in the diff. - The game-free test exercises allocation reuse, constants, release and allocation failure with spies. **Testing:** Read-only review; no code, tests, builds or project scripts were run. The supplied CI checks are still running. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -416,1 +417,3 @@
/// The pipelines and the internal images for an evaluation at these sizes, made again when the sizes change
/// Render resolution = Auto (opts.resolution == 0): the host's DRS or the game's own dynamic resolution steps the render
/// size from frame to frame. Any other row is one fixed render size
bool dynamic_render_size() { return opts.resolution == 0; }
Member

L1 (should fix): This reads the mutable menu option without the lock used to update it.

When: While the render thread prepares an FSR frame, the game can apply a Render resolution change through menu_settings_apply; its applier writes opts.resolution under menu_mu, while this read holds no such lock. The concurrent plain read and write are a C++ data race.

Do: Publish the selected Auto/fixed mode in a synchronized snapshot or read it under the same lock, and use one consistent value throughout preparation.

**L1** (should fix): This reads the mutable menu option without the lock used to update it. *When:* While the render thread prepares an FSR frame, the game can apply a Render resolution change through menu_settings_apply; its applier writes opts.resolution under menu_mu, while this read holds no such lock. The concurrent plain read and write are a C++ data race. **Do:** Publish the selected Auto/fixed mode in a synchronized snapshot or read it under the same lock, and use one consistent value throughout preparation.
@ -417,0 +423,4 @@
/// leaving Auto gives back the video memory (and the clears) of the larger images
bool reusable(uint32_t rw, uint32_t rh, uint32_t uw, uint32_t uh) {
if (!g.output.image || g.upscale_width != uw || g.upscale_height != uh) return false;
if (dynamic_render_size()) return rw <= g.max_render_width && rh <= g.max_render_height;
Member

L2 (should fix): Entering Auto can reuse images made for a smaller fixed scale instead of allocating the Auto maximum.

When: Switch from fixed 1280x720 to Auto while the current render size remains 1280x720: reusable returns true for the fixed-size images. A subsequent upward DRS step exceeds that maximum, recreates the images and resets history, producing the hitch and flash this change aims to avoid.

Do: When entering Auto, require the existing maximum to cover the intended Auto maximum, and update the transition test to require the allocation at the mode change.

**L2** (should fix): Entering Auto can reuse images made for a smaller fixed scale instead of allocating the Auto maximum. *When:* Switch from fixed 1280x720 to Auto while the current render size remains 1280x720: reusable returns true for the fixed-size images. A subsequent upward DRS step exceeds that maximum, recreates the images and resets history, producing the hitch and flash this change aims to avoid. **Do:** When entering Auto, require the existing maximum to cover the intended Auto maximum, and update the transition test to require the allocation at the mode change.
@ -437,0 +453,4 @@
}
// (Auto: made as large as a dynamic-resolution step can reach, the output's size; a fixed render size: as it is)
const uint32_t mw = dynamic_render_size() ? std::max(rw, uw) : rw, mh = dynamic_render_size() ? std::max(rh, uh) : rh;
Member

L3 (should fix): The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured.

When: At 50% render scale, render-sized images have four times the pixels of the base version, and previous_nearest_depth and the SPD mip chain are cleared over their full allocations every frame, including scenes where DRS never changes.

Do: Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device.

**L3** (should fix): The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. *When:* At 50% render scale, render-sized images have four times the pixels of the base version, and previous_nearest_depth and the SPD mip chain are cleared over their full allocations every frame, including scenes where DRS never changes. **Do:** Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device.
@ -543,3 +569,3 @@
k.render_size[0] = rw, k.render_size[1] = rh;
k.upscale_size[0] = uw, k.upscale_size[1] = uh;
k.max_render_size[0] = rw, k.max_render_size[1] = rh;
k.max_render_size[0] = (int32_t)g.max_render_width, k.max_render_size[1] = (int32_t)g.max_render_height;
Member

L4 (should fix): The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path.

When: Auto DRS now passes a larger maximum and retains history on every supported FSR 3.1 GPU; the supplied game run covers only Windows on a Radeon 860M.

Do: Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.

**L4** (should fix): The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. *When:* Auto DRS now passes a larger maximum and retains history on every supported FSR 3.1 GPU; the supplied game run covers only Windows on a Radeon 860M. **Do:** Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.
Owner
@fix
BeanBot force-pushed perf/vk-fsr3-drs-max-render-size from d4d502613a
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to c1d14407de
Some checks failed
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Successful in 10s
PR description / Title and description (pull_request_target) Failing after 5s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 16s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m26s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 15m24s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 16m47s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 16m15s
CI / Website build and checks (pull_request) Failing after 1m16s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 14m19s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 51m13s
2026-12-04 00:23:57 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The change retains the DRS allocation reuse, but its memory and clear costs remain unmeasured and the affected Tier 1 systems have not been tested. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is c1d14407de. I rebased it onto main (68fc871757). I edited its description to match the change.

Changed

  • Synchronize the selected resolution mode at gpu/vk/vk_menu.cpp:860: Read the selected mode under the menu lock and carry one value through preparation and chain evaluation. Updated the source-cut tests; tests were not run.
  • Allocate the Auto maximum on transition at gpu/vk/vk_fsr3.cpp:425: Require reusable images to cover the intended Auto maximum and update the transition test to expect allocation when Auto is selected.

Changed in part (the rest is for the author)

  • Reduce retained scratch allocation at gpu/vk/vk_fsr3.cpp:473: Limited the SPD scratch image to the six mip levels used by the shaders, with a fallback for smaller images. The author still needs to measure retained allocation and clear costs at reduced Auto scales.

Nothing was built or run: the checks run again on the new head.

FSR 3.1 keeps its internal images and temporal history across Auto DRS steps, avoiding repeated allocations. The tradeoff is larger retained images and potentially more clear bandwidth at reduced scales; the fix reduces the SPD scratch mip allocation.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 gpu/vk/vk_fsr3.cpp:456: The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. When: At 50% render scale, render-sized images have four times the pixels of the base version, and previous_nearest_depth and the SPD mip chain are cleared over their full allocations every frame, including scenes where DRS never changes. Do: Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device.
  • L4 gpu/vk/vk_fsr3.cpp:571: The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. When: Auto DRS now passes a larger maximum and retains history on every supported FSR 3.1 GPU; the supplied game run covers only Windows on a Radeon 860M. Do: Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (1; not asked for, not blocking)
  • The description identifies the reported game runs and measurements as predating the final changes.
More: does it help, other systems, switches, what was read

Does it help: Unproven on the final revision. On the earlier tested revision, the reported Radeon 860M runs reduced allocations from 7 to 1 over six DRS steps and improved Hyrule Field median 1% low from 17.63 to 18.26 FPS across four interleaved runs.

Other systems: The Vulkan FSR 3.1 path affects Windows and Linux GPUs, including discrete NVIDIA and AMD hardware, Steam Deck, and the wave-less fallback. Those remaining Tier 1 configurations have no reported runs; the legacy input path still reallocates on resize.

Switches: None added, changed or removed.

Reviewed: c1d14407de against 68fc871757: Read the repository rules and pull request template, the fix diff and the FSR 3.1 allocation, preparation and evaluation paths; inspected the related menu locking and test changes. The supplied base-to-HEAD diff also includes many unrelated intervening changes, which were not read in full.; nothing run (a code review).

Checked and fine:

  • The fix preserves Auto DRS reuse and captures the selected resolution mode through chain evaluation.
  • Fixed-to-Auto transitions allocate the intended maximum before subsequent DRS steps.

Testing: No commands that build or run the project were executed. Measure retained VRAM and clear costs at reduced Auto scales, and exercise DRS transitions and history on the remaining affected Tier 1 systems.

Overlaps and merge order: Not established from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The change retains the DRS allocation reuse, but its memory and clear costs remain unmeasured and the affected Tier 1 systems have not been tested. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is c1d14407de90. I rebased it onto `main` (68fc871757bb). I edited its description to match the change. **Changed** - **Synchronize the selected resolution mode at gpu/vk/vk_menu.cpp:860**: Read the selected mode under the menu lock and carry one value through preparation and chain evaluation. Updated the source-cut tests; tests were not run. - **Allocate the Auto maximum on transition at gpu/vk/vk_fsr3.cpp:425**: Require reusable images to cover the intended Auto maximum and update the transition test to expect allocation when Auto is selected. **Changed in part (the rest is for the author)** - **Reduce retained scratch allocation at gpu/vk/vk_fsr3.cpp:473**: Limited the SPD scratch image to the six mip levels used by the shaders, with a fallback for smaller images. The author still needs to measure retained allocation and clear costs at reduced Auto scales. Nothing was built or run: the checks run again on the new head. FSR 3.1 keeps its internal images and temporal history across Auto DRS steps, avoiding repeated allocations. The tradeoff is larger retained images and potentially more clear bandwidth at reduced scales; the fix reduces the SPD scratch mip allocation. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `gpu/vk/vk_fsr3.cpp:456`: The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. *When:* At 50% render scale, render-sized images have four times the pixels of the base version, and previous_nearest_depth and the SPD mip chain are cleared over their full allocations every frame, including scenes where DRS never changes. **Do:** Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device. - **L4** `gpu/vk/vk_fsr3.cpp:571`: The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. *When:* Auto DRS now passes a larger maximum and retains history on every supported FSR 3.1 GPU; the supplied game run covers only Windows on a Radeon 860M. **Do:** Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The description identifies the reported game runs and measurements as predating the final changes. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the final revision. On the earlier tested revision, the reported Radeon 860M runs reduced allocations from 7 to 1 over six DRS steps and improved Hyrule Field median 1% low from 17.63 to 18.26 FPS across four interleaved runs. **Other systems:** The Vulkan FSR 3.1 path affects Windows and Linux GPUs, including discrete NVIDIA and AMD hardware, Steam Deck, and the wave-less fallback. Those remaining Tier 1 configurations have no reported runs; the legacy input path still reallocates on resize. **Switches:** None added, changed or removed. **Reviewed:** c1d14407de90 against 68fc871757bb: Read the repository rules and pull request template, the fix diff and the FSR 3.1 allocation, preparation and evaluation paths; inspected the related menu locking and test changes. The supplied base-to-HEAD diff also includes many unrelated intervening changes, which were not read in full.; nothing run (a code review). **Checked and fine:** - The fix preserves Auto DRS reuse and captures the selected resolution mode through chain evaluation. - Fixed-to-Auto transitions allocate the intended maximum before subsequent DRS steps. **Testing:** No commands that build or run the project were executed. Measure retained VRAM and clear costs at reduced Auto scales, and exercise DRS transitions and history on the remaining affected Tier 1 systems. **Overlaps and merge order:** Not established from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean changed title from WIP: perf(vk): allocate FSR 3.1 internal images once at max_render_size across DRS steps on all GPUs to perf(vk): allocate FSR 3.1 internal images once at max_render_size across DRS steps on all GPUs 2026-12-04 00:28:10 +00:00
HumanBean deleted branch perf/vk-fsr3-drs-max-render-size 2026-12-04 00:28:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!3096
No description provided.