perf(vk): fold constants and local arrays when unrolling AMD FSR 4, and unroll the postpass #1999

Open
madebyjordan wants to merge 4 commits from madebyjordan/Longshot:perf/fsr4-further into main
Member

Summary

Builds on #1752 (See #744): AMD FSR 4's own GPU time falls 13 % in the game on an RX 6700 XT (3.85 → 3.34 ms), and a cold build of its unrolled pipelines takes 3.3 s in place of 131 s and 1.4 GB of peak commit in place of 4.4 GB, on AMD's Windows RDNA 2 compiler with FSR 4.1.2.

On main, spirv_unroll::unroll_all blindly clones loop bodies containing 576-word OpStores into Function arrays and thousands of local-alloca OpAccessChain/OpLoad/OpStore instructions. That left pass1/pass2/pass12 at ~107,000 words (~50 s and ~3 GB commit charge each to build cold), caused pass4/pass5/pass10 to exceed 200,000 words (40–55 GB OOM, so they stayed rolled), and left postpass (the single slowest FSR 4 pass) rolled because it uses OpINotEqual, multi-OpPhi live-out loops, if (oob) continue;, and wave32.

What this changes:

  • gpu/vk/spirv_unroll.h: Upgrades spirv_unroll::unroll_all to hoist immutable constant-array OpStores once to each function's entry block (scanning past OpLine/OpNoLine so hoisted stores always follow every Function OpVariable), generalize innermost-first loop unrolling (OpULessThan, OpSLessThan, OpINotEqual, multi-OpPhi live-out loops, and single top-level if (cond) continue; selections), merge adjacent trivial blocks, fold 32-bit scalar/vector integer arithmetic, bitcasts, flat composites, and constant-array loads into immediate constants (guarding OpAccessChain against negative or out-of-bounds constant indices across fold_constants, forward_function_allocas, and live-out loop exit_alias), forward intra-block non-escaping plain Function allocas (with bitcasted-vector unpacking, safe dead-store tracking, vector reassembly, and 0-index OpAccessChain escape rejection), and run exact fixed-point DCE (removing dead Function variables only after every store and access chain referencing them is gone, plus unused OpConstantComposite tables and stripped OpNames). Preserves OpDecorate/OpGroupDecorate/OpDecorateId/OpDecorateString, places new constants right before the first OpFunction, guards operand counts against malformed SPIR-V, refuses non-32-bit OpSwitch in block merging and any OpSwitch, degenerate B == M loop, or non-retargeted selection reaching continue (CFG-order-independent) inside unrolled loops, and scans past OpLine/OpNoLine when checking merge-block OpPhis. Allocation and emission order are deterministic so Vulkan pipeline cache keys stay stable across runs.

  • gpu/vk/vk_fsr4.cpp, gpu/vk/device_policy.h, gpu/vk/spirv_unroll_legacy.h:

    • Gates the expanded unroller and postpass unrolling on FSR 4.1.2 (tune::expanded_unroll = best[0] == 4 && best[1] == 1 && best[2] == 2;) across every AMD GPU, removing the single-card/single-driver allow-list. Other FSR 4 versions keep the previous unroller (spirv_unroll_legacy.h) for wave64 network layers only. On every configuration, a pass whose plain fallback twin could not be made (!has_plain) is left rolled.
    • Gates the kCompactHeadroom = 1 GiB cold-build memory threshold (for compact folded shaders <= kCompactUnrollWords = 60,000 words) via DevicePolicy::fsr4_compact_builds to AMD's older Windows shader compiler (RDNA 1 and 2, matching nan_bits's "proprietary shader compiler" check), where compile memory (<60 MB) was measured; every other compiler (RDNA 3/4 LLPC, RADV) and larger shaders up to 120,000 words keep kBuildHeadroom = 8 GiB until their compile memory is measured.
    • Preserves each unrolled pass's requested subgroup size (unrolled_lanes: 64 for wave64 layers, else the original requested size / absent), integrates cleanly with #1886 / #2140 (fsr4_prepare_shaders warms the folded passes before gameplay) and #1989 (tune::suppressed pass-through for forced Lite), keys in-flight jobs by per-creation generation tokens (pending_token), gives worker threads an immutable worker_fn dispatch table initialized in prepare_device(), and handles thread-creation and worker allocation failures with full Vulkan resource rollback.
    • Retiring spirv_unroll_legacy.h: Kept only as the short-term fallback for unmeasured FSR 4 versions. Once Beanstalk verifies FSR 4.1.2 on Linux RADV, Windows RDNA 3 (e.g. RX 7900 XTX), Windows RDNA 4 (RX 9000 series), and FSR 4-capable Steam Deck — and once a subsequent FSR 4.x shader set is checked against spirv_unroll.h — spirv_unroll_legacy.h and the expanded_unroll split can be deleted in a follow-up cleanup PR.
  • gpu/vk/fsr4_tune.h & docs/dev/reference/upscalers.md: Keeps all comments and reference docs aligned with the FSR 4.1.2 / fsr4_compact_builds policy and the !has_plain requirement.

  • tests/test_fsr4_tune.py, tests/test_fsr4_bind_dispatch.py, tests/test_device_policy.py, tests/fsr4_tune/postpass.hlsl, tests/fsr4_tune/postpass.spv: Adds the race-free DXC-compiled postpass miniature fixture, an exact Python SPIR-V interpreter verifying bit-exact output parity across invocations and both continue outcomes for rolled, tail-rewritten, and unrolled+folded layer.spv and postpass.spv, synthetic SPIR-V regression tests (L1–L5, L8–L10, R1–R6), Unicode-safe stdio transport, CXX env handling, DevicePolicy::fsr4_compact_builds coverage across all 24 PC fixtures, and compiled behavioral tests in test_fsr4_bind_dispatch.py exercising create_compute_pipelines, build_unrolled, destroy_pipeline, cmd_bind_pipeline, cmd_dispatch, build_want, expanded_unroll fallback, suppressed pass-through, worker_fn isolation, and handle-reuse token cancellation.

  • Four guards from a cold read of spirv_unroll.h (64318392b; none is reachable with FSR 4.1.2's shaders, whose folded passes are unchanged): a header phi fed by the loop's own test is refused (R7); a counter that would become an out-of-range constant index in a body copy is refused (R8); a loop refused after its constants were made no longer leaves their ids in the constant table for the next loop (R10); DCE keeps a decorated constant composite, BuiltIn WorkgroupSize (R9).

Start review at gpu/vk/spirv_unroll.h (unroll_one, unroll_all, detail::fold_constants, detail::forward_function_allocas, detail::dce), gpu/vk/vk_fsr4.cpp (build_want, build_unrolled, create_compute_pipelines, destroy_pipeline, load), and gpu/vk/device_policy.h (fsr4_compact_builds).

Testing

Tested:

  • This head (9d18a64f5 on main @ be663a08a), Windows 11, RX 6700 XT: the rebase of 64318392b (below) onto main, plus the Guide manifest's device_policy.h hash and one more source check. Every line the PR adds or removes is the same as at 64318392b; the one conflict was beside #2331's Lite log lines in load().
    • Built: LONGSHOT_FSR=1 python -I scripts/dev.py vk (Rust 1.99.1, as mise.toml pins): 0 errors, the exports mkwvk_init and mkwvk_close_asked.
    • Game-free checks: python -I -B tests/run_all.py --changed forge/main: 39 passed, 0 failed, 4 skipped (the same four as below). scripts/check_guide_screenshots.py --review-sources passes.
    • The new source check in tests/test_fsr4_tune.py (load() gives the expanded unroller to FSR 4.1.2 alone, after the last pick_newest() and before l.ok = true) fails with tune::expanded_unroll = true; and with the line deleted, and passes here.
    • Not run in the game: #2286 and #2411 changed the host's side of the renderer (MkwVkHost versions 46 to 48), so this DLL needs a game built at that main, and no nightly has it yet (nightly-805 is 6b928cb4). The numbers below are from 64318392b, whose renderer change is line for line this one.
  • 64318392b on main @ 0e32bc100, Windows 11, AMD Radeon RX 6700 XT, Adrenalin 26.10.1 (driver 0x800161), AMD FSR 4.1.2:
    • In the game: both renderers built with LONGSHOT_FSR=1 python -I scripts/dev.py vk (0 errors, symbols checked) and run in two copies of one nightly-755 game folder that differ only in bin/longshot_vk.dll. Hyrule Field (child), 2560×1440 output, FSR 4 Performance (1280×720): the log says passes unrolled by the expanded unroller; a compact build wants 1 GiB of memory to spare, all 7 passes (pass1, 2, 4, 5, 10, 12, postpass) are bound, and the picture is clean on both sides (a screenshot of the same spot from each; they differ only in where the fairy's light falls).
    • --prepare-shaders warms the folded passes (#1886): from an empty FSR 4 cache at a new folder path, the preparation builds all 7 and ends with SDR pipeline preparation finished (7 optimized layers ready); main builds 3 and leaves pass4, pass5 and pass10 rolled. Times and memory are in Measurements.
    • Warm cache: every later start loads 7 of 7 from the caches (main: 3 of 3).
    • Game-free checks: python -I -B tests/run_all.py --changed forge/main (llvm-mingw clang++, Vulkan SDK 1.4.341.1 spirv-val): 39 passed, 0 failed, 4 skipped (nx2/test_image_arrays.py, tests/test_native_float_atomic_add.py and tests/test_vendor_translation.py are skipped on Windows by their own declaration, tests/test_native_zstd.py wants the zstandard package).
    • The four new unroller cases (R7–R10 in tests/test_fsr4_tune.py) each fail on 09345da7f, the commit before their guards, and pass here.
  • Earlier heads, same PC: standalone parity against AMD's own output (1280×720 → 2560×1440), last run at c8371016: SDR pass1/2/4/5/10/12 bit-exact (0 / 14,745,600 FP16 values differ), with the postpass 6 / 14,745,600 differ by at most 2 ULP (one more FMA contraction across the unrolled 2×2 quad, confirmed with NoContraction); HDR bit-exact. All 13 FSR 4.1.2 shaders passed spirv-val --target-env vulkan1.3. The folded passes have the same word counts on this head (27311, 27487, 44769, 44743, 44634, 27499, 34660), but the outputs were not compared bit for bit again.

Still to test:

  • Windows 11, RX 6700 XT: the standalone bit-for-bit comparison with AMD's output again on this head, SDR and HDR, expecting the figures above (by hand).
  • Linux host build and the full tests/run_all.py --strict on Ubuntu 24.04, expecting no failure that main does not have (@Beanstalk or Linux CI).
  • Linux, RADV, with a Vulkan FSR 4.1.2 library (amd_fidelityfx_upscaler_vk.so): Hyrule Field with FSR 4 on, expecting 7 passes unrolled, each start after the first loading them from the cache, and the same picture as main (by hand).
  • Windows, RDNA 3 (RX 7900 XTX) and RDNA 4 (RX 9000 series), and a Steam Deck that runs FSR 4: the same run, plus the cold build's memory (these compilers keep the 8 GiB limit until it is measured there), expecting no slower fsr4 ffxDispatch than main (by hand).

The hardware runs are by hand because the automatic runs are made without FSR 4 (asked on 2026-11-23, refused for that reason).

Measurements

Verdict: faster where it aims: FSR 4's own GPU time falls 13.4 % (3.854 → 3.336 ms, every run of one side past every run of the other), and a cold preparation of its pipelines takes 3.3 s of builds in place of 131 s, with 1.4 GB of peak commit in place of 4.4 GB. Frame rate is within the spread: 73.7 → 75.4 fps at the median, but the runs overlap.

Setup: Windows 11, AMD Radeon RX 6700 XT, Adrenalin 26.10.1; Hyrule Field (child, dev.py ab's hyrule-field scene), 2560×1440 output, AMD FSR 4.1.2 Performance (1280×720), V-Sync and frame generation off, cap off (HOS_FPS_MAX=1000). Three interleaved pairs (A1, B1, A2, B2, A3, B3) of 60 s after a warm-up pair, each a timing job of the queue run by dev.py ab's own run code, from one pinned options file; fps and frame times from the frame trace (RX_VK_FRAME_TRACE=1), FSR 4's GPU time from RX_VK_PASS_TIMING=1 (on in every run, so it costs both sides alike), the median of each run's 600-present periods. RX_VK_PRECOMPILE=0 in every run, as a development build runs. Both sides use the game binary of nightly-755 (main @ 753fb5af) with the renderer of the commit named; the change is in the renderer alone.

Before: main @ 0e32bc10 After: this PR @ 64318392 Δ
fsr4 ffxDispatch GPU time (run 1 / 2 / 3; median) 3.851 / 3.854 / 3.867; 3.854 ms 3.336 / 3.334 / 3.340; 3.336 ms -0.518 ms (-13.4 %)
fps 73.7 / 74.7 / 73.3; 73.7 73.5 / 76.4 / 75.4; 75.4 +1.7 (+2.3 %), runs overlap
1% low fps 62.5 / 64.4 / 60.1; 62.5 47.2 / 60.6 / 62.5; 60.6 -1.9, runs overlap
Mean frame time 13.56 / 13.38 / 13.64; 13.56 ms 13.61 / 13.08 / 13.27; 13.27 ms -0.29 ms, runs overlap
Median frame time 13.46 / 13.35 / 13.54; 13.46 ms 13.42 / 12.97 / 13.18; 13.18 ms -0.28 ms (-2.1 %), runs overlap
p99 frame time 15.99 / 15.54 / 16.64; 15.99 ms 21.19 / 16.50 / 16.01; 16.50 ms +0.51 ms, runs overlap
Cold --prepare-shaders, FSR 4's part: passes unrolled 3 (pass4, pass5, pass10 left rolled) 7 +4
the same: their builds 131.4 s (44.8 + 44.3 + 42.3) 3.27 s (0.31 to 0.75 each) 40× less
the same: start to preparation finished 133.6 s 13.8 s -119.8 s
the same: the process's peak commit 4,351 MB 1,429 MB -2,922 MB
cache/longshot_fsr4_pipelines.bin 571,168 bytes 718,532 bytes +147 KB
A warm start: unrolling and loading from the cache 0.1 s a pass, 3 passes 0.14 to 0.56 s a pass, 7 passes: 2.2 s +1.9 s on a background thread
  • B1's p99 and 1% low come from one burst: about 30 frames of 21 to 29 ms inside one second, 12 s into that run. Nothing in the log goes with it, and FSR 4's background jobs had ended more than 1,000 presents before the measured stretch. B2 and B3 have no such burst.
  • Peak commit: the preparation process holds about 1.2 GB before FSR 4's work starts on both sides, so the builds add about 0.2 GB here against about 3.1 GB on main.
  • Cold means an empty longshot_fsr4_pipelines.bin in a game folder at a path the driver had not seen.

The log lines:

main @ 0e32bc10, --prepare-shaders from an empty cache:
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass1: its loops unrolled (12275 -> 106544 words), bound in its place from now (44.8 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass12: its loops unrolled (12273 -> 106732 words), bound in its place from now (44.3 s to build)
vk: AMD FSR 4: fsr4_model_v07_fp8_no_scale_pass10 left rolled (13 loops kept: unrolled whole it would pass 120000 words, or they cannot be)
vk: AMD FSR 4: fsr4_model_v07_fp8_no_scale_pass4 left rolled (13 loops kept: unrolled whole it would pass 120000 words, or they cannot be)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass2: its loops unrolled (12261 -> 106720 words), bound in its place from now (42.3 s to build)
vk: AMD FSR 4: fsr4_model_v07_fp8_no_scale_pass5 left rolled (13 loops kept: unrolled whole it would pass 120000 words, or they cannot be)
vk: AMD FSR 4: SDR pipeline preparation finished (3 optimized layers ready)

this PR @ 64318392, the same:
vk: AMD FSR 4: passes unrolled by the expanded unroller; a compact build wants 1 GiB of memory to spare
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass1: its loops unrolled (12275 -> 27311 words), bound in its place from now (0.31 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass2: its loops unrolled (12261 -> 27487 words), bound in its place from now (0.32 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass4: its loops unrolled (21126 -> 44769 words), bound in its place from now (0.60 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass5: its loops unrolled (20988 -> 44743 words), bound in its place from now (0.59 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass10: its loops unrolled (20875 -> 44634 words), bound in its place from now (0.75 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass12: its loops unrolled (12273 -> 27499 words), bound in its place from now (0.34 s to build)
vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_postpass: its loops unrolled (17007 -> 34660 words), bound in its place from now (0.36 s to build)
vk: AMD FSR 4: SDR pipeline preparation finished (7 optimized layers ready)

the timed runs:
dev.py ab: A1: 4424 frames in 60 s, 73.7 fps, median 13.46 ms, p99 15.99 ms, 1% low 62.5 fps, 3 cold frames
dev.py ab: B1: 4408 frames in 60 s, 73.5 fps, median 13.42 ms, p99 21.19 ms, 1% low 47.2 fps, 2 cold frames
dev.py ab: A2: 4483 frames in 60 s, 74.7 fps, median 13.35 ms, p99 15.54 ms, 1% low 64.4 fps, 0 cold frames
dev.py ab: B2: 4585 frames in 60 s, 76.4 fps, median 12.97 ms, p99 16.50 ms, 1% low 60.6 fps, 0 cold frames
dev.py ab: A3: 4398 frames in 60 s, 73.3 fps, median 13.54 ms, p99 16.64 ms, 1% low 60.1 fps, 3 cold frames
dev.py ab: B3: 4521 frames in 60 s, 75.4 fps, median 13.18 ms, p99 16.01 ms, 1% low 62.5 fps, 2 cold frames
A2: vk:   m   3.854 ms     1.0 x   3853.8 us       1.0 items    0.00 MB  fsr4 ffxDispatch (AMD's passes)
B2: vk:   m   3.334 ms     1.0 x   3333.9 us       1.0 items    0.00 MB  fsr4 ffxDispatch (AMD's passes)
B2: vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass4: its loops unrolled (21126 -> 44769 words), bound in its place from now (0.56 s from the caches)
A2: vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass1: its loops unrolled (12275 -> 106544 words), bound in its place from now (0.1 s from the caches)
vk: switches set (11): HOS_AUDIO_MUTE=1 (diag), HOS_CONTROL=... (diag), HOS_DISCORD=0 (kill), HOS_ENV_FILE=... (diag), HOS_FPS_MAX=1000 (player), HOS_OPTIONS_FILE=... (diag), HOS_WINDOW_NOACTIVATE=1 (diag), LONGSHOT_BUILD_NAME=A: main @ 0e32bc10 · hyrule-field (diag), RX_VK_FRAME_TRACE=1 (diag), RX_VK_PASS_TIMING=1 (diag), RX_VK_PRECOMPILE=0 (kill)

Risks

  • Other AMD compilers and other FSR 4 versions: the expanded unroller and the postpass run on FSR 4.1.2 on every AMD GPU; another FSR 4 version keeps spirv_unroll_legacy.h, for the wave64 layers only. Only RDNA 2 on Windows is measured. The 1 GiB build limit (kCompactHeadroom, passes of at most 60,000 words) applies on AMD's older Windows compiler alone (DevicePolicy::fsr4_compact_builds, RDNA 1 and 2); RDNA 3 and 4, RADV and any larger pass keep 8 GiB. A pass whose plain twin could not be made is left rolled everywhere. The transforms refuse what they do not understand, and a pass with any loop left rolled, or past 120,000 words, stays on AMD's pipeline.
  • A cost at every start: unrolling runs again at each start before the cache is asked, on one background thread: 0.14 to 0.56 s a pass here, 2.2 s for the seven, against 0.3 s for main's three. AMD's own pipelines draw until each is bound, so the picture is right throughout and the saving starts about 2 s later.
  • How to turn it off: RX_VK_FSR4_TUNE=0 runs AMD's shaders as they are; a revert restores the previous unroller.
  • What players notice after updating: on an AMD GPU with FSR 4.1.2, the seven folded passes are not in the old cache/longshot_fsr4_pipelines.bin: they are built once, in the update's shader preparation or at the first FSR 4 frame (3.3 s of builds on an RX 6700 XT, against 131 s for main's three), and the file grows by about 150 KB. Saves and longshot_options.ini are untouched.

Checklist

Ready for review

  • One topic, on current main; 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 (the checks that read the changed files pass on Windows; the Guide screenshots check fails on main too, see the comment of 2026-11-23; the full Linux suite is in Still to test).
  • 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 check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) with UTF-8 paths (the Linux build is in Still to test).
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

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 Builds on #1752 (See #744): AMD FSR 4's own GPU time falls 13 % in the game on an RX 6700 XT (3.85 → 3.34 ms), and a cold build of its unrolled pipelines takes 3.3 s in place of 131 s and 1.4 GB of peak commit in place of 4.4 GB, on AMD's Windows RDNA 2 compiler with FSR 4.1.2. On `main`, `spirv_unroll::unroll_all` blindly clones loop bodies containing 576-word `OpStore`s into Function arrays and thousands of local-alloca `OpAccessChain`/`OpLoad`/`OpStore` instructions. That left `pass1`/`pass2`/`pass12` at ~107,000 words (~50 s and ~3 GB commit charge each to build cold), caused `pass4`/`pass5`/`pass10` to exceed 200,000 words (40–55 GB OOM, so they stayed rolled), and left `postpass` (the single slowest FSR 4 pass) rolled because it uses `OpINotEqual`, multi-`OpPhi` live-out loops, `if (oob) continue;`, and wave32. What this changes: - **`gpu/vk/spirv_unroll.h`**: Upgrades `spirv_unroll::unroll_all` to hoist immutable constant-array `OpStore`s once to each function's entry block (scanning past `OpLine`/`OpNoLine` so hoisted stores always follow every Function `OpVariable`), generalize innermost-first loop unrolling (`OpULessThan`, `OpSLessThan`, `OpINotEqual`, multi-`OpPhi` live-out loops, and single top-level `if (cond) continue;` selections), merge adjacent trivial blocks, fold 32-bit scalar/vector integer arithmetic, bitcasts, flat composites, and constant-array loads into immediate constants (guarding `OpAccessChain` against negative or out-of-bounds constant indices across `fold_constants`, `forward_function_allocas`, and live-out loop `exit_alias`), forward intra-block non-escaping plain Function allocas (with bitcasted-vector unpacking, safe dead-store tracking, vector reassembly, and 0-index `OpAccessChain` escape rejection), and run exact fixed-point DCE (removing dead Function variables only after every store and access chain referencing them is gone, plus unused `OpConstantComposite` tables and stripped `OpName`s). Preserves `OpDecorate`/`OpGroupDecorate`/`OpDecorateId`/`OpDecorateString`, places new constants right before the first `OpFunction`, guards operand counts against malformed SPIR-V, refuses non-32-bit `OpSwitch` in block merging and any `OpSwitch`, degenerate `B == M` loop, or non-retargeted selection reaching `continue` (CFG-order-independent) inside unrolled loops, and scans past `OpLine`/`OpNoLine` when checking merge-block `OpPhi`s. Allocation and emission order are deterministic so Vulkan pipeline cache keys stay stable across runs. - **`gpu/vk/vk_fsr4.cpp`**, **`gpu/vk/device_policy.h`**, **`gpu/vk/spirv_unroll_legacy.h`**: - Gates the expanded unroller and postpass unrolling on **FSR 4.1.2** (`tune::expanded_unroll = best[0] == 4 && best[1] == 1 && best[2] == 2;`) across every AMD GPU, removing the single-card/single-driver allow-list. Other FSR 4 versions keep the previous unroller (`spirv_unroll_legacy.h`) for wave64 network layers only. On every configuration, a pass whose plain fallback twin could not be made (`!has_plain`) is left rolled. - Gates the `kCompactHeadroom = 1 GiB` cold-build memory threshold (for compact folded shaders `<= kCompactUnrollWords = 60,000` words) via `DevicePolicy::fsr4_compact_builds` to AMD's older Windows shader compiler (RDNA 1 and 2, matching `nan_bits`'s `"proprietary shader compiler"` check), where compile memory (<60 MB) was measured; every other compiler (RDNA 3/4 LLPC, RADV) and larger shaders up to `120,000` words keep `kBuildHeadroom = 8 GiB` until their compile memory is measured. - Preserves each unrolled pass's requested subgroup size (`unrolled_lanes`: 64 for wave64 layers, else the original requested size / absent), integrates cleanly with `#1886` / `#2140` (`fsr4_prepare_shaders` warms the folded passes before gameplay) and `#1989` (`tune::suppressed` pass-through for forced Lite), keys in-flight jobs by per-creation generation tokens (`pending_token`), gives worker threads an immutable `worker_fn` dispatch table initialized in `prepare_device()`, and handles thread-creation and worker allocation failures with full Vulkan resource rollback. - **Retiring `spirv_unroll_legacy.h`:** Kept only as the short-term fallback for unmeasured FSR 4 versions. Once Beanstalk verifies FSR 4.1.2 on Linux RADV, Windows RDNA 3 (e.g. RX 7900 XTX), Windows RDNA 4 (RX 9000 series), and FSR 4-capable Steam Deck — and once a subsequent FSR 4.x shader set is checked against `spirv_unroll.h` — `spirv_unroll_legacy.h` and the `expanded_unroll` split can be deleted in a follow-up cleanup PR. - **`gpu/vk/fsr4_tune.h`** & **`docs/dev/reference/upscalers.md`**: Keeps all comments and reference docs aligned with the FSR 4.1.2 / `fsr4_compact_builds` policy and the `!has_plain` requirement. - **`tests/test_fsr4_tune.py`**, **`tests/test_fsr4_bind_dispatch.py`**, **`tests/test_device_policy.py`**, **`tests/fsr4_tune/postpass.hlsl`**, **`tests/fsr4_tune/postpass.spv`**: Adds the race-free DXC-compiled `postpass` miniature fixture, an exact Python SPIR-V interpreter verifying bit-exact output parity across invocations and both `continue` outcomes for rolled, tail-rewritten, and unrolled+folded `layer.spv` and `postpass.spv`, synthetic SPIR-V regression tests (`L1`–`L5`, `L8`–`L10`, `R1`–`R6`), Unicode-safe stdio transport, `CXX` env handling, `DevicePolicy::fsr4_compact_builds` coverage across all 24 PC fixtures, and compiled behavioral tests in `test_fsr4_bind_dispatch.py` exercising `create_compute_pipelines`, `build_unrolled`, `destroy_pipeline`, `cmd_bind_pipeline`, `cmd_dispatch`, `build_want`, `expanded_unroll` fallback, `suppressed` pass-through, `worker_fn` isolation, and handle-reuse token cancellation. - **Four guards from a cold read of `spirv_unroll.h`** (`64318392b`; none is reachable with FSR 4.1.2's shaders, whose folded passes are unchanged): a header phi fed by the loop's own test is refused (`R7`); a counter that would become an out-of-range constant index in a body copy is refused (`R8`); a loop refused after its constants were made no longer leaves their ids in the constant table for the next loop (`R10`); DCE keeps a decorated constant composite, `BuiltIn WorkgroupSize` (`R9`). Start review at `gpu/vk/spirv_unroll.h` (`unroll_one`, `unroll_all`, `detail::fold_constants`, `detail::forward_function_allocas`, `detail::dce`), `gpu/vk/vk_fsr4.cpp` (`build_want`, `build_unrolled`, `create_compute_pipelines`, `destroy_pipeline`, `load`), and `gpu/vk/device_policy.h` (`fsr4_compact_builds`). ## Testing **Tested:** - **This head (`9d18a64f5` on `main @ be663a08a`), Windows 11, RX 6700 XT:** the rebase of `64318392b` (below) onto `main`, plus the Guide manifest's `device_policy.h` hash and one more source check. Every line the PR adds or removes is the same as at `64318392b`; the one conflict was beside #2331's Lite log lines in `load()`. - **Built:** `LONGSHOT_FSR=1 python -I scripts/dev.py vk` (Rust 1.99.1, as `mise.toml` pins): 0 errors, the exports `mkwvk_init` and `mkwvk_close_asked`. - **Game-free checks:** `python -I -B tests/run_all.py --changed forge/main`: 39 passed, 0 failed, 4 skipped (the same four as below). `scripts/check_guide_screenshots.py --review-sources` passes. - **The new source check** in `tests/test_fsr4_tune.py` (`load()` gives the expanded unroller to FSR 4.1.2 alone, after the last `pick_newest()` and before `l.ok = true`) fails with `tune::expanded_unroll = true;` and with the line deleted, and passes here. - **Not run in the game:** #2286 and #2411 changed the host's side of the renderer (`MkwVkHost` versions 46 to 48), so this DLL needs a game built at that `main`, and no nightly has it yet (nightly-805 is `6b928cb4`). The numbers below are from `64318392b`, whose renderer change is line for line this one. - **`64318392b` on `main @ 0e32bc100`, Windows 11, AMD Radeon RX 6700 XT, Adrenalin 26.10.1 (driver `0x800161`), AMD FSR 4.1.2:** - **In the game:** both renderers built with `LONGSHOT_FSR=1 python -I scripts/dev.py vk` (0 errors, symbols checked) and run in two copies of one nightly-755 game folder that differ only in `bin/longshot_vk.dll`. Hyrule Field (child), 2560×1440 output, FSR 4 Performance (1280×720): the log says `passes unrolled by the expanded unroller; a compact build wants 1 GiB of memory to spare`, all 7 passes (`pass1, 2, 4, 5, 10, 12, postpass`) are bound, and the picture is clean on both sides (a screenshot of the same spot from each; they differ only in where the fairy's light falls). - **`--prepare-shaders` warms the folded passes (#1886):** from an empty FSR 4 cache at a new folder path, the preparation builds all 7 and ends with `SDR pipeline preparation finished (7 optimized layers ready)`; `main` builds 3 and leaves `pass4`, `pass5` and `pass10` rolled. Times and memory are in Measurements. - **Warm cache:** every later start loads 7 of 7 `from the caches` (`main`: 3 of 3). - **Game-free checks:** `python -I -B tests/run_all.py --changed forge/main` (llvm-mingw `clang++`, Vulkan SDK 1.4.341.1 `spirv-val`): 39 passed, 0 failed, 4 skipped (`nx2/test_image_arrays.py`, `tests/test_native_float_atomic_add.py` and `tests/test_vendor_translation.py` are skipped on Windows by their own declaration, `tests/test_native_zstd.py` wants the `zstandard` package). - **The four new unroller cases** (`R7`–`R10` in `tests/test_fsr4_tune.py`) each fail on `09345da7f`, the commit before their guards, and pass here. - **Earlier heads, same PC:** standalone parity against AMD's own output (1280×720 → 2560×1440), last run at `c8371016`: SDR `pass1/2/4/5/10/12` bit-exact (`0 / 14,745,600` FP16 values differ), with the postpass `6 / 14,745,600` differ by at most 2 ULP (one more FMA contraction across the unrolled 2×2 quad, confirmed with `NoContraction`); HDR bit-exact. All 13 FSR 4.1.2 shaders passed `spirv-val --target-env vulkan1.3`. The folded passes have the same word counts on this head (`27311, 27487, 44769, 44743, 44634, 27499, 34660`), but the outputs were not compared bit for bit again. **Still to test:** - Windows 11, RX 6700 XT: the standalone bit-for-bit comparison with AMD's output again on this head, SDR and HDR, expecting the figures above (`by hand`). - Linux host build and the full `tests/run_all.py --strict` on Ubuntu 24.04, expecting no failure that `main` does not have (`@Beanstalk` or Linux CI). - Linux, RADV, with a Vulkan FSR 4.1.2 library (`amd_fidelityfx_upscaler_vk.so`): Hyrule Field with FSR 4 on, expecting 7 passes unrolled, each start after the first loading them from the cache, and the same picture as `main` (`by hand`). - Windows, RDNA 3 (RX 7900 XTX) and RDNA 4 (RX 9000 series), and a Steam Deck that runs FSR 4: the same run, plus the cold build's memory (these compilers keep the 8 GiB limit until it is measured there), expecting no slower `fsr4 ffxDispatch` than `main` (`by hand`). The hardware runs are by hand because the automatic runs are made without FSR 4 (asked on 2026-11-23, refused for that reason). ## Measurements **Verdict:** faster where it aims: FSR 4's own GPU time falls 13.4 % (3.854 → 3.336 ms, every run of one side past every run of the other), and a cold preparation of its pipelines takes 3.3 s of builds in place of 131 s, with 1.4 GB of peak commit in place of 4.4 GB. Frame rate is within the spread: 73.7 → 75.4 fps at the median, but the runs overlap. Setup: Windows 11, AMD Radeon RX 6700 XT, Adrenalin 26.10.1; Hyrule Field (child, `dev.py ab`'s `hyrule-field` scene), 2560×1440 output, AMD FSR 4.1.2 Performance (1280×720), V-Sync and frame generation off, cap off (`HOS_FPS_MAX=1000`). Three interleaved pairs (A1, B1, A2, B2, A3, B3) of 60 s after a warm-up pair, each a `timing` job of the queue run by `dev.py ab`'s own run code, from one pinned options file; fps and frame times from the frame trace (`RX_VK_FRAME_TRACE=1`), FSR 4's GPU time from `RX_VK_PASS_TIMING=1` (on in every run, so it costs both sides alike), the median of each run's 600-present periods. `RX_VK_PRECOMPILE=0` in every run, as a development build runs. Both sides use the game binary of nightly-755 (`main @ 753fb5af`) with the renderer of the commit named; the change is in the renderer alone. | | Before: main @ 0e32bc10 | After: this PR @ 64318392 | Δ | |---|---|---|---| | `fsr4 ffxDispatch` GPU time (run 1 / 2 / 3; median) | 3.851 / 3.854 / 3.867; 3.854 ms | 3.336 / 3.334 / 3.340; 3.336 ms | -0.518 ms (-13.4 %) | | fps | 73.7 / 74.7 / 73.3; 73.7 | 73.5 / 76.4 / 75.4; 75.4 | +1.7 (+2.3 %), runs overlap | | 1% low fps | 62.5 / 64.4 / 60.1; 62.5 | 47.2 / 60.6 / 62.5; 60.6 | -1.9, runs overlap | | Mean frame time | 13.56 / 13.38 / 13.64; 13.56 ms | 13.61 / 13.08 / 13.27; 13.27 ms | -0.29 ms, runs overlap | | Median frame time | 13.46 / 13.35 / 13.54; 13.46 ms | 13.42 / 12.97 / 13.18; 13.18 ms | -0.28 ms (-2.1 %), runs overlap | | p99 frame time | 15.99 / 15.54 / 16.64; 15.99 ms | 21.19 / 16.50 / 16.01; 16.50 ms | +0.51 ms, runs overlap | | Cold `--prepare-shaders`, FSR 4's part: passes unrolled | 3 (`pass4`, `pass5`, `pass10` left rolled) | 7 | +4 | | the same: their builds | 131.4 s (44.8 + 44.3 + 42.3) | 3.27 s (0.31 to 0.75 each) | 40× less | | the same: start to `preparation finished` | 133.6 s | 13.8 s | -119.8 s | | the same: the process's peak commit | 4,351 MB | 1,429 MB | -2,922 MB | | `cache/longshot_fsr4_pipelines.bin` | 571,168 bytes | 718,532 bytes | +147 KB | | A warm start: unrolling and loading from the cache | 0.1 s a pass, 3 passes | 0.14 to 0.56 s a pass, 7 passes: 2.2 s | +1.9 s on a background thread | - **B1's p99 and 1% low** come from one burst: about 30 frames of 21 to 29 ms inside one second, 12 s into that run. Nothing in the log goes with it, and FSR 4's background jobs had ended more than 1,000 presents before the measured stretch. B2 and B3 have no such burst. - **Peak commit:** the preparation process holds about 1.2 GB before FSR 4's work starts on both sides, so the builds add about 0.2 GB here against about 3.1 GB on `main`. - **Cold** means an empty `longshot_fsr4_pipelines.bin` in a game folder at a path the driver had not seen. The log lines: ``` main @ 0e32bc10, --prepare-shaders from an empty cache: vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass1: its loops unrolled (12275 -> 106544 words), bound in its place from now (44.8 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass12: its loops unrolled (12273 -> 106732 words), bound in its place from now (44.3 s to build) vk: AMD FSR 4: fsr4_model_v07_fp8_no_scale_pass10 left rolled (13 loops kept: unrolled whole it would pass 120000 words, or they cannot be) vk: AMD FSR 4: fsr4_model_v07_fp8_no_scale_pass4 left rolled (13 loops kept: unrolled whole it would pass 120000 words, or they cannot be) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass2: its loops unrolled (12261 -> 106720 words), bound in its place from now (42.3 s to build) vk: AMD FSR 4: fsr4_model_v07_fp8_no_scale_pass5 left rolled (13 loops kept: unrolled whole it would pass 120000 words, or they cannot be) vk: AMD FSR 4: SDR pipeline preparation finished (3 optimized layers ready) this PR @ 64318392, the same: vk: AMD FSR 4: passes unrolled by the expanded unroller; a compact build wants 1 GiB of memory to spare vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass1: its loops unrolled (12275 -> 27311 words), bound in its place from now (0.31 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass2: its loops unrolled (12261 -> 27487 words), bound in its place from now (0.32 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass4: its loops unrolled (21126 -> 44769 words), bound in its place from now (0.60 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass5: its loops unrolled (20988 -> 44743 words), bound in its place from now (0.59 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass10: its loops unrolled (20875 -> 44634 words), bound in its place from now (0.75 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass12: its loops unrolled (12273 -> 27499 words), bound in its place from now (0.34 s to build) vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_postpass: its loops unrolled (17007 -> 34660 words), bound in its place from now (0.36 s to build) vk: AMD FSR 4: SDR pipeline preparation finished (7 optimized layers ready) the timed runs: dev.py ab: A1: 4424 frames in 60 s, 73.7 fps, median 13.46 ms, p99 15.99 ms, 1% low 62.5 fps, 3 cold frames dev.py ab: B1: 4408 frames in 60 s, 73.5 fps, median 13.42 ms, p99 21.19 ms, 1% low 47.2 fps, 2 cold frames dev.py ab: A2: 4483 frames in 60 s, 74.7 fps, median 13.35 ms, p99 15.54 ms, 1% low 64.4 fps, 0 cold frames dev.py ab: B2: 4585 frames in 60 s, 76.4 fps, median 12.97 ms, p99 16.50 ms, 1% low 60.6 fps, 0 cold frames dev.py ab: A3: 4398 frames in 60 s, 73.3 fps, median 13.54 ms, p99 16.64 ms, 1% low 60.1 fps, 3 cold frames dev.py ab: B3: 4521 frames in 60 s, 75.4 fps, median 13.18 ms, p99 16.01 ms, 1% low 62.5 fps, 2 cold frames A2: vk: m 3.854 ms 1.0 x 3853.8 us 1.0 items 0.00 MB fsr4 ffxDispatch (AMD's passes) B2: vk: m 3.334 ms 1.0 x 3333.9 us 1.0 items 0.00 MB fsr4 ffxDispatch (AMD's passes) B2: vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass4: its loops unrolled (21126 -> 44769 words), bound in its place from now (0.56 s from the caches) A2: vk: AMD FSR 4: tuned fsr4_model_v07_fp8_no_scale_pass1: its loops unrolled (12275 -> 106544 words), bound in its place from now (0.1 s from the caches) vk: switches set (11): HOS_AUDIO_MUTE=1 (diag), HOS_CONTROL=... (diag), HOS_DISCORD=0 (kill), HOS_ENV_FILE=... (diag), HOS_FPS_MAX=1000 (player), HOS_OPTIONS_FILE=... (diag), HOS_WINDOW_NOACTIVATE=1 (diag), LONGSHOT_BUILD_NAME=A: main @ 0e32bc10 · hyrule-field (diag), RX_VK_FRAME_TRACE=1 (diag), RX_VK_PASS_TIMING=1 (diag), RX_VK_PRECOMPILE=0 (kill) ``` ## Risks - **Other AMD compilers and other FSR 4 versions:** the expanded unroller and the postpass run on FSR 4.1.2 on every AMD GPU; another FSR 4 version keeps `spirv_unroll_legacy.h`, for the wave64 layers only. Only RDNA 2 on Windows is measured. The 1 GiB build limit (`kCompactHeadroom`, passes of at most 60,000 words) applies on AMD's older Windows compiler alone (`DevicePolicy::fsr4_compact_builds`, RDNA 1 and 2); RDNA 3 and 4, RADV and any larger pass keep 8 GiB. A pass whose plain twin could not be made is left rolled everywhere. The transforms refuse what they do not understand, and a pass with any loop left rolled, or past 120,000 words, stays on AMD's pipeline. - **A cost at every start:** unrolling runs again at each start before the cache is asked, on one background thread: 0.14 to 0.56 s a pass here, 2.2 s for the seven, against 0.3 s for `main`'s three. AMD's own pipelines draw until each is bound, so the picture is right throughout and the saving starts about 2 s later. - **How to turn it off:** `RX_VK_FSR4_TUNE=0` runs AMD's shaders as they are; a revert restores the previous unroller. - **What players notice after updating:** on an AMD GPU with FSR 4.1.2, the seven folded passes are not in the old `cache/longshot_fsr4_pipelines.bin`: they are built once, in the update's shader preparation or at the first FSR 4 frame (3.3 s of builds on an RX 6700 XT, against 131 s for `main`'s three), and the file grows by about 150 KB. Saves and `longshot_options.ini` are untouched. ## Checklist ### Ready for review - [x] One topic, on current `main`; 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 (the checks that read the changed files pass on Windows; the Guide screenshots check fails on `main` too, see the comment of 2026-11-23; the full Linux suite is in Still to test). - [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 check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) with UTF-8 paths (the Linux build is in Still to test). - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### 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(vk): fold constants and local arrays when unrolling AMD FSR 4, and unroll the postpass
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
PR description / Description follows the template (pull_request_target) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 14s
Third-party parts / As their notes say (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Website build and checks (pull_request) Failing after 28s
de6ab96897
Assisted-by: Gemini (Antigravity)
Author
Member

Tested in game: Windows 11, AMD Radeon RX 6700 XT (Adrenalin 26.10.1), Hyrule Field (child), 2560x1440 output, AMD FSR 4.1.2 Performance 50% (1280x720), V-Sync Off, FG Off, cap 1000. All 7 passes (pass1, 2, 4, 5, 10, 12, postpass) unrolled and compiled cold in 3.43 s total (vs 147.0 s for 3 passes on main), saved to cache/longshot_fsr4_pipelines.bin (208 KB), loaded 7/7 from cache on restarts, and cut fsr4 ffxDispatch GPU time from 4.542 ms to 3.699 ms (-18.6%) across 3 interleaved 30 s pairs.

Tested in game: Windows 11, AMD Radeon RX 6700 XT (Adrenalin 26.10.1), Hyrule Field (child), 2560x1440 output, AMD FSR 4.1.2 Performance 50% (1280x720), V-Sync Off, FG Off, cap 1000. All 7 passes (pass1, 2, 4, 5, 10, 12, postpass) unrolled and compiled cold in 3.43 s total (vs 147.0 s for 3 passes on main), saved to cache/longshot_fsr4_pipelines.bin (208 KB), loaded 7/7 from cache on restarts, and cut fsr4 ffxDispatch GPU time from 4.542 ms to 3.699 ms (-18.6%) across 3 interleaved 30 s pairs.
BeanBot requested changes 2026-11-21 03:52:17 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The RX 6700 XT runs show a substantial FSR 4 GPU-time saving. The rewrite can change shader results or emit invalid SPIR-V for valid inputs, and the lower cold-build memory guard also admits shader and driver combinations outside the measured range.

Folds weights and local scratch storage into the unrolled FSR 4 shaders, adds the postpass to the background rebuilds, and caches the replacements. This could cut first-run compilation and steady-state GPU time. The cost is a larger shader optimizer with more correctness obligations and more pipelines competing for resources during startup.

@fix will do (21)

  1. L1 gpu/vk/spirv_unroll.h:466: The composite tracking treats constructor operands as lanes, but SPIR-V vector constructors can mix vectors and scalars. (more on the line)
  2. L2 gpu/vk/spirv_unroll.h:1255: Unrolling now accepts decorated loop results, then drops their OpDecorate instructions without cloning them. (more on the line)
  3. L3 gpu/vk/spirv_unroll.h:891: Forwarding deletes the load before DCE can record its result as removed, while apply_aliases skips OpName and OpDecorate. (more on the line)
  4. L4 gpu/vk/spirv_unroll.h:248: New constants are inserted after the last recognized constant, which can precede the declaration of their type. (more on the line)
  5. L5 gpu/vk/spirv_unroll.h:949: DCE can remove a Function variable while leaving a store that still uses it. (more on the line)
  6. L6 gpu/vk/spirv_unroll.h:943: The eight-round DCE limit can leave a surviving chain rooted at a deleted variable. (more on the line)
  7. L7 gpu/vk/spirv_unroll.h:1022: Block merging reads every OpSwitch case as a 32-bit literal and label. (more on the line)
  8. L8 gpu/vk/spirv_unroll.h:1225: A continue that misses the narrow pattern is still cloned. (more on the line)
  9. L9 gpu/vk/spirv_unroll.h:1276: The merge-block check inspects one instruction immediately after OpLabel. (more on the line)
  10. L10 gpu/vk/spirv_unroll.h:211: The parser checks instruction framing but the new scans assume opcode-specific operands exist. (more on the line)
  11. L11 gpu/vk/vk_fsr4.cpp:299: The 1 GiB guard covers every admitted cold compile, while the size limit still admits up to 120,000 words. (more on the line)
  12. L12 gpu/vk/vk_fsr4.cpp:826: The expanded job path counts a worker and allocates its Vulkan layouts before constructing the thread. (more on the line)
  13. L13 gpu/vk/vk_fsr4.cpp:821: The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. (more on the line)
  14. L14 gpu/vk/vk_fsr4.cpp:674: The extra background job reads plain driver function pointers that device_proc rewrites. (more on the line)
  15. L15 tests/test_fsr4_tune.py:319: Validation and instruction counts would pass if a fold selected the wrong weight or returned a stale accumulator. (more on the line)
  16. L16 (minor) tests/test_fsr4_tune.py:204: The subgroup checks match specific source strings. (more on the line)
  17. L17 (minor) tests/test_fsr4_tune.py:27: The normal runner skips the expanded test on Windows even when spirv-val is installed, and the direct invocation ignores CXX unless --cxx is supplied. The driver also opens paths through narrow argv and streams, which can fail for a checkout or temp directory outside the Windows code page. Use tool availability to gate the test, honor CXX, and pass fixture and output paths through a Unicode-capable interface.
  18. L18 (minor): The checklist claims the full suite passed and the host code built on Linux. Testing reports a changed-file subset and a Windows build. Record the full suite and the Linux build with the supported compilers, or mark those checks pending. The three named baseline failures can stay listed.
  19. L19 (its part an edit can do): Log time to the first playable frame separately from background compilation and cache hits, and report the per-run frame-time percentiles and peak memory.
  20. L20 (its part an edit can do): Keep the measured shader and driver combinations on the new cold path while retaining the existing fallback on combinations awaiting coverage.
  21. L21 (minor) docs/dev/reference/upscalers.md:26: The cache paragraph says the layers and postpass are unrolled, although six layers stay rolled in the reported setup and eligibility also depends on the module, driver, and headroom. (more on the line)

For the author (2) (a run, a measurement or a decision)

  • L19 (minor): Repeat the comparison on the merge base and corrected head. The supplied Performance-preset run establishes a GPU-time gain on the earlier pair, while FPS overlaps and median and p99 frame times are missing. Include Auto's chosen quality preset and a heavy scene, paste the source log lines, and report cold and warm time to the first playable frame, peak RAM and VRAM, and cache size. The current cold total measures background jobs.
  • L20 (minor): The default reaches RADV and newer Adrenalin models, while the reported runs cover one Windows RDNA 2 card. Finish the listed Linux RADV and Windows RDNA 4 runs, and cover FSR 4-capable Steam Deck configurations. Check cold commit and pacing, warm cache hits, and output parity on odd dimensions and during SDR/HDR or context changes.

Checks: Still running: CI / Website build and checks (pull_request), PR description / Description follows the template (pull_request_target), CI / Conventional Commit title (pull_request), CI / Workflow lint (actionlint) (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request).

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

Does it help: Unproven on the review head. The reported Windows RX 6700 XT comparison at afc4d1ad versus b79edcc7 shows 4.542 to 3.699 ms FSR 4 GPU time across three interleaved pairs with no overlap. It also reports 147.0 to 3.43 s of cold background builds and roughly 3 GB to under 60 MB peak commit. Mean FPS and 1% lows overlap, and one pair's 1% low fell from 25.84 to 20.81 FPS. Equal shader word counts after the rebase establish neither equal shader bytes nor equal driver behavior.

Other systems: The rewrite runs through the optional FSR 4 runtime and the AMD-only tuning policy. NVIDIA, Intel, and other upscalers bypass it. FSR 4 Quality, native AA, HDR, frame generation with FSR 4 input, other Adrenalin models, RADV, and Steam Deck configurations that load FSR 4 still need coverage. The standalone HDR comparison reported exact output on the tested card. Cold jobs share the renderer's compute compilation gate, and the tested dedicated cache grew from about 60 to 208 KB. The diff leaves save, input, audio, and renderer API code alone.

Switches: No setting or switch is added or removed. The existing RX_VK_FSR4_TUNE default is on for AMD and off elsewhere, with =0 selecting the vendor shaders. Its switch-table row covers the expanded path, but the wider default still needs affected Tier 1 coverage. The internal cold-build threshold falls from 8 GiB to 1 GiB. Only the reported RX 6700 XT setup supports the lower value so far.

Reviewed: de6ab96897 against f1f2dc5bd2: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, the development standards, the full seven-file diff and commit, and the full text of spirv_unroll.h, vk_fsr4.cpp, fsr4_tune.h, upscalers.md, test_fsr4_tune.py, and postpass.hlsl. Traced the operand table, device policy, cache and close callers, and related test harnesses. Skimmed the generated SPIR-V blob and the supplied run reports and CI status. The checkout had no review-checklist file. Fixture regeneration and recorded shader bytes from the benchmark were unverified.; nothing run (a code review).

Checked and fine:

  • The commit has an Assisted-by trailer and a Conventional Commit title. The HLSL fixture uses authored weights, and the diff contains no apparent game-derived material or vendor runtime.
  • The change stays on the FSR 4 topic and leaves third_party and the versioned renderer interface alone. The added fixture includes its DXC generation command.
  • The job captures the requested numeric lane count before moving Plain. A non-wave64 pass with no explicit request keeps a null subgroup-size chain.
  • Cache probing still precedes the cold-build headroom check. Bind and dispatch still remember which pipeline was actually bound if a worker publishes between them.
  • The scalar folds guard divide-by-zero, signed division overflow, and oversized shifts. Trip counts use widened arithmetic and reject the checked wrap cases.
  • The diff adds no downloads, external service calls, or build and CI script changes.

Testing: Read-only review. git diff --check passed. The author reports a Windows build, fixture and cache checks, three interleaved in-game pairs, and standalone SDR/HDR parity with six SDR values differing by at most 2 ULP. CI was still running in the supplied status. No builds or tests were executed for this review.

Overlaps and merge order: The prerequisite FSR 4 changes #2798 and #1752 are already in the base. No other overlap found in the supplied material or local history.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The RX 6700 XT runs show a substantial FSR 4 GPU-time saving. The rewrite can change shader results or emit invalid SPIR-V for valid inputs, and the lower cold-build memory guard also admits shader and driver combinations outside the measured range. Folds weights and local scratch storage into the unrolled FSR 4 shaders, adds the postpass to the background rebuilds, and caches the replacements. This could cut first-run compilation and steady-state GPU time. The cost is a larger shader optimizer with more correctness obligations and more pipelines competing for resources during startup. **`@fix` will do (21)** 1. **L1** `gpu/vk/spirv_unroll.h:466`: The composite tracking treats constructor operands as lanes, but SPIR-V vector constructors can mix vectors and scalars. (more on the line) 2. **L2** `gpu/vk/spirv_unroll.h:1255`: Unrolling now accepts decorated loop results, then drops their OpDecorate instructions without cloning them. (more on the line) 3. **L3** `gpu/vk/spirv_unroll.h:891`: Forwarding deletes the load before DCE can record its result as removed, while apply_aliases skips OpName and OpDecorate. (more on the line) 4. **L4** `gpu/vk/spirv_unroll.h:248`: New constants are inserted after the last recognized constant, which can precede the declaration of their type. (more on the line) 5. **L5** `gpu/vk/spirv_unroll.h:949`: DCE can remove a Function variable while leaving a store that still uses it. (more on the line) 6. **L6** `gpu/vk/spirv_unroll.h:943`: The eight-round DCE limit can leave a surviving chain rooted at a deleted variable. (more on the line) 7. **L7** `gpu/vk/spirv_unroll.h:1022`: Block merging reads every OpSwitch case as a 32-bit literal and label. (more on the line) 8. **L8** `gpu/vk/spirv_unroll.h:1225`: A continue that misses the narrow pattern is still cloned. (more on the line) 9. **L9** `gpu/vk/spirv_unroll.h:1276`: The merge-block check inspects one instruction immediately after OpLabel. (more on the line) 10. **L10** `gpu/vk/spirv_unroll.h:211`: The parser checks instruction framing but the new scans assume opcode-specific operands exist. (more on the line) 11. **L11** `gpu/vk/vk_fsr4.cpp:299`: The 1 GiB guard covers every admitted cold compile, while the size limit still admits up to 120,000 words. (more on the line) 12. **L12** `gpu/vk/vk_fsr4.cpp:826`: The expanded job path counts a worker and allocates its Vulkan layouts before constructing the thread. (more on the line) 13. **L13** `gpu/vk/vk_fsr4.cpp:821`: The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. (more on the line) 14. **L14** `gpu/vk/vk_fsr4.cpp:674`: The extra background job reads plain driver function pointers that device_proc rewrites. (more on the line) 15. **L15** `tests/test_fsr4_tune.py:319`: Validation and instruction counts would pass if a fold selected the wrong weight or returned a stale accumulator. (more on the line) 16. **L16** (minor) `tests/test_fsr4_tune.py:204`: The subgroup checks match specific source strings. (more on the line) 17. **L17** (minor) `tests/test_fsr4_tune.py:27`: The normal runner skips the expanded test on Windows even when spirv-val is installed, and the direct invocation ignores CXX unless --cxx is supplied. The driver also opens paths through narrow argv and streams, which can fail for a checkout or temp directory outside the Windows code page. Use tool availability to gate the test, honor CXX, and pass fixture and output paths through a Unicode-capable interface. 18. **L18** (minor): The checklist claims the full suite passed and the host code built on Linux. Testing reports a changed-file subset and a Windows build. Record the full suite and the Linux build with the supported compilers, or mark those checks pending. The three named baseline failures can stay listed. 19. **L19** (its part an edit can do): Log time to the first playable frame separately from background compilation and cache hits, and report the per-run frame-time percentiles and peak memory. 20. **L20** (its part an edit can do): Keep the measured shader and driver combinations on the new cold path while retaining the existing fallback on combinations awaiting coverage. 21. **L21** (minor) `docs/dev/reference/upscalers.md:26`: The cache paragraph says the layers and postpass are unrolled, although six layers stay rolled in the reported setup and eligibility also depends on the module, driver, and headroom. (more on the line) **For the author (2)** (a run, a measurement or a decision) - **L19** (minor): Repeat the comparison on the merge base and corrected head. The supplied Performance-preset run establishes a GPU-time gain on the earlier pair, while FPS overlaps and median and p99 frame times are missing. Include Auto's chosen quality preset and a heavy scene, paste the source log lines, and report cold and warm time to the first playable frame, peak RAM and VRAM, and cache size. The current cold total measures background jobs. - **L20** (minor): The default reaches RADV and newer Adrenalin models, while the reported runs cover one Windows RDNA 2 card. Finish the listed Linux RADV and Windows RDNA 4 runs, and cover FSR 4-capable Steam Deck configurations. Check cold commit and pacing, warm cache hits, and output parity on odd dimensions and during SDR/HDR or context changes. **Checks:** Still running: `CI / Website build and checks (pull_request)`, `PR description / Description follows the template (pull_request_target)`, `CI / Conventional Commit title (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the review head. The reported Windows RX 6700 XT comparison at afc4d1ad versus b79edcc7 shows 4.542 to 3.699 ms FSR 4 GPU time across three interleaved pairs with no overlap. It also reports 147.0 to 3.43 s of cold background builds and roughly 3 GB to under 60 MB peak commit. Mean FPS and 1% lows overlap, and one pair's 1% low fell from 25.84 to 20.81 FPS. Equal shader word counts after the rebase establish neither equal shader bytes nor equal driver behavior. **Other systems:** The rewrite runs through the optional FSR 4 runtime and the AMD-only tuning policy. NVIDIA, Intel, and other upscalers bypass it. FSR 4 Quality, native AA, HDR, frame generation with FSR 4 input, other Adrenalin models, RADV, and Steam Deck configurations that load FSR 4 still need coverage. The standalone HDR comparison reported exact output on the tested card. Cold jobs share the renderer's compute compilation gate, and the tested dedicated cache grew from about 60 to 208 KB. The diff leaves save, input, audio, and renderer API code alone. **Switches:** No setting or switch is added or removed. The existing RX_VK_FSR4_TUNE default is on for AMD and off elsewhere, with =0 selecting the vendor shaders. Its switch-table row covers the expanded path, but the wider default still needs affected Tier 1 coverage. The internal cold-build threshold falls from 8 GiB to 1 GiB. Only the reported RX 6700 XT setup supports the lower value so far. **Reviewed:** de6ab9689789 against f1f2dc5bd282: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, the development standards, the full seven-file diff and commit, and the full text of spirv_unroll.h, vk_fsr4.cpp, fsr4_tune.h, upscalers.md, test_fsr4_tune.py, and postpass.hlsl. Traced the operand table, device policy, cache and close callers, and related test harnesses. Skimmed the generated SPIR-V blob and the supplied run reports and CI status. The checkout had no review-checklist file. Fixture regeneration and recorded shader bytes from the benchmark were unverified.; nothing run (a code review). **Checked and fine:** - The commit has an Assisted-by trailer and a Conventional Commit title. The HLSL fixture uses authored weights, and the diff contains no apparent game-derived material or vendor runtime. - The change stays on the FSR 4 topic and leaves third_party and the versioned renderer interface alone. The added fixture includes its DXC generation command. - The job captures the requested numeric lane count before moving Plain. A non-wave64 pass with no explicit request keeps a null subgroup-size chain. - Cache probing still precedes the cold-build headroom check. Bind and dispatch still remember which pipeline was actually bound if a worker publishes between them. - The scalar folds guard divide-by-zero, signed division overflow, and oversized shifts. Trip counts use widened arithmetic and reject the checked wrap cases. - The diff adds no downloads, external service calls, or build and CI script changes. **Testing:** Read-only review. git diff --check passed. The author reports a Windows build, fixture and cache checks, three interleaved in-game pairs, and standalone SDR/HDR parity with six SDR values differing by at most 2 ULP. CI was still running in the supplied status. No builds or tests were executed for this review. **Overlaps and merge order:** The prerequisite FSR 4 changes #2798 and #1752 are already in the base. No other overlap found in the supplied material or local history. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -24,3 +24,3 @@
the menu offers only the engines that can.
AMD FSR 4's layers are unrolled and built into a pipeline cache of their own, `cache/longshot_fsr4_pipelines.bin`
AMD FSR 4's layers and postpass are unrolled and built into a pipeline cache of their own, `cache/longshot_fsr4_pipelines.bin`
Member

L21 (minor): The cache paragraph says the layers and postpass are unrolled, although six layers stay rolled in the reported setup and eligibility also depends on the module, driver, and headroom. Say that eligible weight-table passes are rebuilt and cached. Label the shorter standalone compile times separately from the 0.33–0.69 s in-game times in the source notes.

**L21** (minor): The cache paragraph says the layers and postpass are unrolled, although six layers stay rolled in the reported setup and eligibility also depends on the module, driver, and headroom. Say that eligible weight-table passes are rebuilt and cached. Label the shorter standalone compile times separately from the 0.33–0.69 s in-game times in the source notes.
@ -135,0 +208,4 @@
composite[in[2]].assign(in.begin() + 3, in.end());
id_type[in[2]] = in[1];
last_global_const = k;
} else if (op == kConstantTrue || op == kConstantFalse) {
Member

L10: The parser checks instruction framing but the new scans assume opcode-specific operands exist. A one-word OpConstantTrue passes the framing check and TypeInfo::scan then accesses words 1 and 2. Driver module creation can defer inspection until pipeline creation. Validate the operand counts the rewrite relies on and fail back to the existing pipeline before indexing malformed input.

**L10**: The parser checks instruction framing but the new scans assume opcode-specific operands exist. A one-word OpConstantTrue passes the framing check and TypeInfo::scan then accesses words 1 and 2. Driver module creation can defer inspection until pipeline creation. Validate the operand counts the rewrite relies on and fail back to the existing pipeline before indexing malformed input.
@ -135,0 +245,4 @@
inline void insert_new_consts(Module& m, size_t after_idx, std::vector<Ins>& new_consts) {
if (new_consts.empty()) return;
m.ins.insert(m.ins.begin() + (ptrdiff_t)after_idx + 1, new_consts.begin(), new_consts.end());
Member

L4: New constants are inserted after the last recognized constant, which can precede the declaration of their type. For example, a signed int type declared after the last unsigned constant can first be used by an in-function bitcast of that constant. Folding creates a signed constant above its type declaration. Emit new constants after all their types and before the first function.

**L4**: New constants are inserted after the last recognized constant, which can precede the declaration of their type. For example, a signed int type declared after the last unsigned constant can first be used by an in-function bitcast of that constant. Folding creates a signed constant above its type declaration. Emit new constants after all their types and before the first function.
@ -135,0 +463,4 @@
}
if (op == kCompositeConstruct && in.size() >= 4) {
id_ty[in[2]] = in[1];
comp_elems[in[2]].assign(in.begin() + 3, in.end());
Member

L1: The composite tracking treats constructor operands as lanes, but SPIR-V vector constructors can mix vectors and scalars. In a four-lane construct from a two-lane vector followed by two scalars, extracting lane 1 can return the first scalar, which belongs to lane 2. The same assumption maps the wrong element after a store at line 804. Flatten vector operands by their actual lane count or refuse mixed constructors in both passes, and check the extracted value.

**L1**: The composite tracking treats constructor operands as lanes, but SPIR-V vector constructors can mix vectors and scalars. In a four-lane construct from a two-lane vector followed by two scalars, extracting lane 1 can return the first scalar, which belongs to lane 2. The same assumption maps the wrong element after a store at line 804. Flatten vector operands by their actual lane count or refuse mixed constructors in both passes, and check the extracted value.
@ -135,0 +888,4 @@
}
}
}
if (!forwarded) rebuilt.push_back(std::move(in));
Member

L3: Forwarding deletes the load before DCE can record its result as removed, while apply_aliases skips OpName and OpDecorate. A forwarded load outside the cloned loop that has an OpName therefore leaves a reference to an undefined result. Account for all annotation uses before deleting a result, remove debug names with the definition, and preserve or reject semantic annotations.

**L3**: Forwarding deletes the load before DCE can record its result as removed, while apply_aliases skips OpName and OpDecorate. A forwarded load outside the cloned loop that has an OpName therefore leaves a reference to an undefined result. Account for all annotation uses before deleting a result, remove debug names with the definition, and preserve or reject semantic annotations.
@ -135,0 +940,4 @@
}
std::unordered_set<uint32_t> dead_fvars;
for (uint32_t v : fvars) if (!live_fvars.count(v)) dead_fvars.insert(v);
Member

L6: The eight-round DCE limit can leave a surviving chain rooted at a deleted variable. A write-only local can have enough successive access chains that each round removes only the last surviving chain, even across the cleanup calls for a single-loop module. Use a dependency worklist or defer deletion of the root until its remaining references are gone.

**L6**: The eight-round DCE limit can leave a surviving chain rooted at a deleted variable. A write-only local can have enough successive access chains that each round removes only the last surviving chain, even across the cleanup calls for a single-loop module. Use a dependency worklist or defer deletion of the root until its remaining references are gone.
@ -135,0 +946,4 @@
bool changed = false;
for (Ins& in : m.ins) {
const uint32_t op = in[0] & 0xffff;
if (op == kVariable && in.size() >= 4 && in[3] == 7 && dead_fvars.count(in[2])) {
Member

L5: DCE can remove a Function variable while leaving a store that still uses it. The non-escape scan accepts a store with memory operands, but DCE only removes three-word stores. A write-only local with an Aligned store leaves an undefined pointer in the emitted shader. Exclude locals with qualified accesses from this elimination, and remove pointer definitions only after all their remaining users are gone.

**L5**: DCE can remove a Function variable while leaving a store that still uses it. The non-escape scan accepts a store with memory operands, but DCE only removes three-word stores. A write-only local with an Aligned store leaves an undefined pointer in the emitted shader. Exclude locals with qualified accesses from this elimination, and remove pointer definitions only after all their remaining users are gone.
@ -135,0 +1019,4 @@
} else if (op == kSwitch) {
has_merge_before_term[cur_lbl] = cur_has_merge;
pinned.insert(in[2]);
for (size_t j = 4; j < in.size(); j += 2) pinned.insert(in[j]);
Member

L7: Block merging reads every OpSwitch case as a 32-bit literal and label. With a 64-bit selector and two cases, it misses the first case target. If the previous block falls through to that target via an unconditional branch, merging can delete a label still referenced by the switch. Decode switch operands using the selector type in the merger and the ID walker, or decline transforms involving unsupported switches.

**L7**: Block merging reads every OpSwitch case as a 32-bit literal and label. With a 64-bit selector and two cases, it misses the first case target. If the previous block falls through to that target via an unconditional branch, merging can delete a label still referenced by the switch. Decode switch operands using the selector type in the merger and the ID walker, or decline transforms involving unsupported switches.
@ -176,0 +1222,4 @@
if (top_level && !cont_has_phi && !cont_targeted_by_sel && skip_blocks.empty() && t_lbl != f_lbl &&
(f_lbl == sm || t_lbl == sm)) {
const uint32_t cand_skip = (f_lbl == sm) ? t_lbl : f_lbl;
for (size_t j = k + 2; j + 1 < ci; j++) {
Member

L8: A continue that misses the narrow pattern is still cloned. For example, a selection arm that writes a value and then continues keeps an edge to the old continue target after the loop construct is removed. That edge is neither the selection's merge nor a structured loop exit anymore. Check every incoming edge to the continue block and refuse the loop unless the replacement preserves structured control flow.

**L8**: A continue that misses the narrow pattern is still cloned. For example, a selection arm that writes a value and then continues keeps an edge to the old continue target after the loop construct is removed. That edge is neither the selection's merge nor a structured loop exit anymore. Check every incoming edge to the continue block and refuse the loop unless the replacement preserves structured control flow.
@ -178,1 +1252,4 @@
if (k >= hi && k < mi) continue;
Ins tmp = I[k];
const uint32_t op = tmp[0] & 0xffff;
if (op == kName || op == kDecorate) continue;
Member

L2: Unrolling now accepts decorated loop results, then drops their OpDecorate instructions without cloning them. An OpFMul carrying NoContraction loses that restriction in every copy. The same metadata needs consideration when folding replaces a decorated result. Preserve semantic decorations for the appropriate new IDs or leave those operations and loops alone.

**L2**: Unrolling now accepts decorated loop results, then drops their OpDecorate instructions without cloning them. An OpFMul carrying NoContraction loses that restriction in every copy. The same metadata needs consideration when folding replaces a decorated result. Preserve semantic decorations for the appropriate new IDs or leave those operations and loops alone.
@ -194,3 +1275,2 @@
}
if (!ok || (mi + 1 < I.size() && (I[mi + 1][0] & 0xffff) == kPhi)) { refused.insert(key); continue; }
// the counter's values as constants (new ones after the last constant)
if (!ok || (mi + 1 < I.size() && (I[mi + 1][0] & 0xffff) == kPhi)) {
Member

L9: The merge-block check inspects one instruction immediately after OpLabel. A debug line instruction before an OpPhi hides the phi, which can still list the old header as its incoming predecessor after that edge is replaced. Skip debug line instructions when checking for phis or check the merge block's predecessors explicitly.

**L9**: The merge-block check inspects one instruction immediately after OpLabel. A debug line instruction before an OpPhi hides the phi, which can still list the old header as its incoming predecessor after that edge is replaced. Skip debug line instructions when checking for phis or check the merge block's predecessors explicitly.
@ -298,2 +298,2 @@
constexpr size_t kUnrollWords = 120000; // (a layer unrolled to more than this is left rolled)
constexpr uint64_t kBuildHeadroom = 8ull << 30; // (memory to spare before a build starts)
constexpr size_t kUnrollWords = 120000; // (a pass still above this after folding is left rolled)
constexpr uint64_t kBuildHeadroom = 1ull << 30; // (memory to spare before a cold build starts; folded builds take <60 MB)
Member

L11: The 1 GiB guard covers every admitted cold compile, while the size limit still admits up to 120,000 words. A vendor shader whose scratch operations survive folding can reach the roughly 107,000-word size that previously needed about 3 GB on the tested driver. A machine with 1–3 GiB free now attempts that compile under pressure. Keep the conservative guard for unverified outputs and drivers, or limit the low threshold to a measured shader and driver range. Keep the cache lookup first.

**L11**: The 1 GiB guard covers every admitted cold compile, while the size limit still admits up to 120,000 words. A vendor shader whose scratch operations survive folding can reach the roughly 107,000-word size that previously needed about 3 GB on the tested driver. A machine with 1–3 GiB free now attempts that compile under pressure. Keep the conservative guard for unverified outputs and drivers, or limit the low threshold to a measured shader and driver range. Keep the cache lookup first.
@ -673,15 +673,17 @@ void build_unrolled(VkPipeline original, std::shared_ptr<const std::vector<uint3
VkShaderModule module = VK_NULL_HANDLE;
if (real_csm(dev.device, &mci, nullptr, &module) == VK_SUCCESS) {
Member

L14: The extra background job reads plain driver function pointers that device_proc rewrites. If a resize or HDR change creates a context and AMD asks for vkCreateShaderModule or vkDestroyShaderModule while a postpass job uses it, the reads race with the writes even when Vulkan returns the same address. Give the worker an immutable dispatch table initialized before the SDK hooks are exposed.

**L14**: The extra background job reads plain driver function pointers that device_proc rewrites. If a resize or HDR change creates a context and AMD asks for vkCreateShaderModule or vkDestroyShaderModule while a postpass job uses it, the reads race with the writes even when Vulkan returns the same address. Give the worker an immutable dispatch table initialized before the SDK hooks are exposed.
@ -816,8 +821,9 @@ VKAPI_ATTR VkResult VKAPI_CALL create_compute_pipelines(VkDevice d, VkPipelineCa
pending.insert(p[i]);
Member

L13: The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. If a context is destroyed with a job queued and the driver reuses that handle, the newer job can run first and consume the old job's cancellation. The old job can then publish its shader for the new context. Carry a per-creation job token and check it against the live token before publishing.

**L13**: The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. If a context is destroyed with a job queued and the driver reuses that handle, the newer job can run first and consume the old job's cancellation. The old job can then publish its shader for the new context. Carry a per-creation job token and check it against the live token before publishing.
@ -819,2 +824,3 @@
const uint32_t req_lanes = (kind[i] & 1) ? 64u : orig_lanes;
{ std::lock_guard jl(jobs().mu); jobs().running++; }
std::thread(build_unrolled, p[i], code[i], entry[i], job, layout, std::move(sets)).detach(); // (counted: fsr4_close)
std::thread(build_unrolled, p[i], code[i], entry[i], job, req_lanes, layout, std::move(sets)).detach(); // (counted: fsr4_close)
Member

L12: The expanded job path counts a worker and allocates its Vulkan layouts before constructing the thread. If thread creation fails under resource pressure, the exception escapes the callback and the count, pending entry, and layouts have no rollback. Worker allocation failures in the expanded rewrite can also escape the thread and terminate the process. Use an owned worker queue or handle both failure paths with cleanup and keep the existing pipeline.

**L12**: The expanded job path counts a worker and allocates its Vulkan layouts before constructing the thread. If thread creation fails under resource pressure, the exception escapes the callback and the count, pending entry, and layouts have no rollback. Worker allocation failures in the expanded rewrite can also escape the thread and terminate the process. Use an owned worker queue or handle both failure paths with cleanup and keep the existing pipeline.
@ -193,9 +201,15 @@ def source_problems():
problems.append("an unroll thread is started without being counted (fsr4_close waits for the count)")
if "closing" not in pipes:
problems.append("create_compute_pipelines starts unroll jobs after the window closed")
if "!(kind[i] & 1) || !(kind[i] & 2)" in pipes:
Member

L16 (minor): The subgroup checks match specific source strings. Putting the wave64 gate back elsewhere, or passing 64 to the worker while leaving the expected assignment in place, still passes. Use a fake pipeline creation callback to check that the postpass is queued and arrives with its requested 32 lanes, that a missing requirement stays absent, and that a wave64 layer still requests 64.

**L16** (minor): The subgroup checks match specific source strings. Putting the wave64 gate back elsewhere, or passing 64 to the worker while leaving the expected assignment in place, still passes. Use a fake pipeline creation callback to check that the postpass is queued and arrives with its requested 32 lanes, that a missing requirement stays absent, and that a wave64 layer still requests 64.
@ -283,0 +316,4 @@
problems.append("postpass.spv's 2 loops (OpINotEqual, multi-phi, continue) were not all unrolled deterministically: "
"done %s, before %s, left %s, det %s" % (pdone, pbefore, pleft, pdet))
else:
valid(t / "postpass_unrolled.spv", "the unrolled postpass")
Member

L15: Validation and instruction counts would pass if a fold selected the wrong weight or returned a stale accumulator. Add a game-free result check for the rolled and rewritten shaders with known inputs, both continue outcomes, and distinct accumulator values. Use disjoint input and output locations or a single active invocation, since the current HLSL lets neighboring invocations read and write overlapping scratch words.

**L15**: Validation and instruction counts would pass if a fold selected the wrong weight or returned a stale accumulator. Add a game-free result check for the rolled and rewritten shaders with known inputs, both continue outcomes, and distinct accumulator values. Use disjoint input and output locations or a single active invocation, since the current HLSL lets neighboring invocations read and write overlapping scratch words.
madebyjordan left a comment

Not ready to merge. This is a comment because the PR is my own. I read the code at de6ab968 and ran nothing.

New and blocking

  1. A dead-store removal can delete the wrong instruction (gpu/vk/spirv_unroll.h:800). forward_function_allocas records the store's position, then may add OpBitcasts before the store itself (line 828). The recorded position then points at the first bitcast. If the same location is stored again in that block, that bitcast is deleted and the old store stays. A load already forwarded to that bitcast now names an id that no longer exists, and that invalid shader goes to the driver, since nothing validates it at run time. Example: store asuint(float2(a, b)) to p, read p[0], store to p again. Fix: record the position after the bitcasts are added, and add this case to the test.

New and minor

  1. kISub is 129, which is OpFAdd; OpISub is 130 (gpu/vk/spirv_unroll.h:130). The picture isn't affected, because the fold requires an integer result type, but integer subtraction is never folded. Correcting it means replacing the literal case 130: in is_pure_op with case 129:, or the switch has a duplicate case and float adds stop being removable. It can change the emitted shaders, so it belongs before the final measurement.

BeanBot's points, checked against the code

  • L1, L2, L3, L4, L5 and L8 are real at this head and should block. L1 can silently give a wrong value for a constructor as ordinary as float4(v.xy, a, b).
  • L2 is a guard this PR removed: main refuses a loop whose results are decorated. It may also explain the 6 differing SDR postpass values, though I haven't shown that. If the fix is to refuse those loops, check that the postpass and passes 4, 5 and 10 still unroll, because a refused loop leaves its pass rolled and loses the gain. Copying the decorations onto each clone would keep it.
  • L6, L7, L9 and L10 are real but need shapes DXC doesn't normally emit. The guards are cheap.
  • L12, L13 and L14 exist on main in the same form. This PR adds one more job through them, so they don't need to block it.
  • L11 and L15 stand. The fixture proves the output is valid, not that its values are right.

Merge state

  • It merges cleanly into current main (40bfceb0).
  • The two failing checks (Website, Guide screenshots) fail the same way on #1927, which has the same base, and pass on #2013. This PR doesn't touch the website, so a rebase should clear them.
  • It conflicts in gpu/vk/vk_fsr4.cpp with #1886 and #1989. Whichever lands second needs a rebase.

Checked and fine: the lanes[i].pNext guard does nothing for the postpass, but has_plain already limits the job to a chain holding at most a lane count, so no structure is lost.

**Not ready to merge.** This is a comment because the PR is my own. I read the code at `de6ab968` and ran nothing. **New and blocking** 1. **A dead-store removal can delete the wrong instruction** (`gpu/vk/spirv_unroll.h:800`). `forward_function_allocas` records the store's position, then may add `OpBitcast`s before the store itself (line 828). The recorded position then points at the first bitcast. If the same location is stored again in that block, that bitcast is deleted and the old store stays. A load already forwarded to that bitcast now names an id that no longer exists, and that invalid shader goes to the driver, since nothing validates it at run time. Example: store `asuint(float2(a, b))` to `p`, read `p[0]`, store to `p` again. Fix: record the position after the bitcasts are added, and add this case to the test. **New and minor** 2. **`kISub` is 129, which is `OpFAdd`; `OpISub` is 130** (`gpu/vk/spirv_unroll.h:130`). The picture isn't affected, because the fold requires an integer result type, but integer subtraction is never folded. Correcting it means replacing the literal `case 130:` in `is_pure_op` with `case 129:`, or the switch has a duplicate case and float adds stop being removable. It can change the emitted shaders, so it belongs before the final measurement. **BeanBot's points, checked against the code** - **L1, L2, L3, L4, L5 and L8 are real at this head and should block.** L1 can silently give a wrong value for a constructor as ordinary as `float4(v.xy, a, b)`. - **L2 is a guard this PR removed:** main refuses a loop whose results are decorated. It may also explain the 6 differing SDR postpass values, though I haven't shown that. If the fix is to refuse those loops, check that the postpass and passes 4, 5 and 10 still unroll, because a refused loop leaves its pass rolled and loses the gain. Copying the decorations onto each clone would keep it. - **L6, L7, L9 and L10 are real** but need shapes DXC doesn't normally emit. The guards are cheap. - **L12, L13 and L14 exist on main in the same form.** This PR adds one more job through them, so they don't need to block it. - **L11 and L15 stand.** The fixture proves the output is valid, not that its values are right. **Merge state** - It merges cleanly into current main (`40bfceb0`). - The two failing checks (Website, Guide screenshots) fail the same way on https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1927, which has the same base, and pass on https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2013. This PR doesn't touch the website, so a rebase should clear them. - It conflicts in `gpu/vk/vk_fsr4.cpp` with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1886 and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1989. Whichever lands second needs a rebase. **Checked and fine:** the `lanes[i].pNext` guard does nothing for the postpass, but `has_plain` already limits the job to a chain holding at most a lane count, so no structure is lost.
@ -117,0 +127,4 @@
kFunction = 54, kFunctionEnd = 56, kFunctionCall = 57,
kVariable = 59, kLoad = 61, kStore = 62, kAccessChain = 65, kDecorate = 71,
kVectorShuffle = 79, kCompositeConstruct = 80, kCompositeExtract = 81, kCompositeInsert = 82, kCopyObject = 83,
kBitcast = 124, kIAdd = 128, kISub = 129, kIMul = 132, kUDiv = 134, kSDiv = 135, kUMod = 137,
Author
Member

129 is OpFAdd; OpISub is 130. Correcting it also means changing the literal case 130 in is_pure_op to 129.

129 is OpFAdd; OpISub is 130. Correcting it also means changing the literal case 130 in is_pure_op to 129.
@ -135,0 +797,4 @@
++it;
}
}
sm[loc.path] = rebuilt.size();
Author
Member

The position recorded here goes stale when the bitcasts below (line 828) are added before the store, so a later overwrite deletes a bitcast that a forwarded load may use. Record it after they are added.

The position recorded here goes stale when the bitcasts below (line 828) are added before the store, so a later overwrite deletes a bitcast that a forwarded load may use. Record it after they are added.
fix(vk): address review findings in FSR 4 unroller, worker lifecycle, and tests
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 24s
CI / Workflow lint (actionlint) (pull_request) Successful in 45s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 48s
Third-party parts / As their notes say (pull_request) Successful in 53s
CI / Website build and checks (pull_request) Failing after 25s
PR description / Description follows the template (pull_request_target) Has been cancelled
c8371016fd
Assisted-by: Gemini (Antigravity)
Author
Member

Addressed all code, test, and doc findings from review #2050 (L1–L18, L21, and the code-side guards of L19–L20):

gpu/vk/spirv_unroll.h

  • L1: Added is_flat_construct() so vector OpCompositeConstruct tracking in both fold_constants and forward_function_allocas verifies in.size() - 3 == count and scalar element types (rejecting mixed vector+scalar packing).
  • L2: TypeInfo::scan records all IDs targeted by OpDecorate; unroll_one refuses loops whose made set contains a decorated ID, fold_constants refuses to alias decorated results, and forward_function_allocas refuses to forward decorated loads.
  • L3: forward_function_allocas tracks alias-forwarded loads and calls strip_annotations(m, removed_loads, false) to strip their OpNames without touching OpDecorate.
  • L4: TypeInfo::scan records first_func; insert_new_consts and unroll_one insert new OpConstants immediately before the first OpFunction (after all OpType* and prior constants), and fold_constants scans from first_func.
  • L5: find_non_escaping_fvars requires plain 4-word OpLoad and plain 3-word OpStore, excluding any Function variable with memory-operand-qualified accesses from forwarding and DCE.
  • L6: dce iterates to exact fixed point and only deletes a dead Function OpVariable once !used.count(in[2]) (after every store and chained OpAccessChain referencing it has been removed).
  • L7: merge_trivial_blocks refuses modules containing any OpSwitch whose selector is not a known 32-bit integer or whose operand count is odd; unroll_one refuses loops containing OpSwitch.
  • L8: unroll_one tracks open_sel_merges and refuses any branch/conditional branch targeting cont from inside a non-retargeted selection.
  • L9: unroll_one scans the entire merge block [mi + 1 .. terminator/next_label) for OpPhi so OpLine/OpNoLine cannot hide a merge-block phi.
  • L10: Added operand-count bounds checks across TypeInfo::scan, for_each_id (M Aligned / L LoopControl), merge_trivial_blocks, and unroll_one.

gpu/vk/vk_fsr4.cpp

  • L11 & L20 (code guard): Restored kBuildHeadroom = 8 GiB for larger/unverified shaders (> kCompactUnrollWords = 60,000) and gated the 1 GiB threshold (kCompactHeadroom) strictly to compact folded shaders (<= 60,000 words; all 7 measured FSR 4.1.2 passes fold to 27–45K words and peak <60 MB).
  • L12: Wrapped std::thread(build_unrolled, ...).detach() in try/catch with full rollback of jobs().running, pending_token, and copied Vulkan layouts (passing sets by value so catch always owns every handle), and wrapped build_unrolled in try/catch with an RAII Cleanup guard so allocation failures never terminate the process or leak handles.
  • L13: Replaced pending/cancelled handle sets with pending_token keyed by a monotonic per-creation uint64_t token (next_job_token), so a destroyed and driver-reused VkPipeline handle never publishes a stale build.
  • L14: Added an immutable worker_fn dispatch table initialized once in prepare_device() before device_proc is exposed; build_unrolled uses worker_fn.* exclusively.

Tests & Docs

  • L15: Updated tests/fsr4_tune/postpass.hlsl & postpass.spv to read from a separate InBuffer and write disjoint ScratchBuffer words; added a Python SPIR-V interpreter in tests/test_fsr4_tune.py verifying bit-exact output parity across invocations (including both continue outcomes) for rolled, tail-rewritten, and unrolled+folded layer.spv and postpass.spv, plus synthetic spirv-val + semantic regression cases for L1–L5 and L8–L10.
  • L16: Replaced brittle subgroup source-string checks in tests/test_fsr4_tune.py with compiled behavioral tests in tests/test_fsr4_bind_dispatch.py exercising the real create_compute_pipelines, build_unrolled, destroy_pipeline, cmd_bind_pipeline, and cmd_dispatch hooks against recording fake callbacks (wave64 layer -> 64 lanes, postpass -> 32 lanes and null pNext with ALLOW_VARYING preserved, two-tier headroom, worker_fn isolation, and handle-reuse token cancellation).
  • L17: Removed RUN_ALL_SKIP on Windows from tests/test_fsr4_tune.py (now gated automatically by {spirv_val}), honored CXX env var, and switched the test driver to binary stdin/stdout so Python's Path handles all Unicode paths natively.
  • L18, L19, L20, L21: Updated gpu/vk/fsr4_tune.h, gpu/vk/vk_fsr4.cpp, docs/dev/reference/upscalers.md, and the PR description/checklist to distinguish standalone vs in-game compile times, report median and p99 frame times from the recorded interleaved A/B runs, and list the Linux build/full suite and remaining hardware/scenario coverage explicitly under Still to test.

Re-verified on updated head

  • tests/run_all.py fsr4 (Windows, no --no-skip): 3/3 passed, 0 skipped (test_fsr4_tune.py, test_fsr4_own_cache.py, test_fsr4_bind_dispatch.py).
  • All 13 real FSR 4.1.2 SPIR-V shaders: identical folded word counts (27311–44769), det=1, 13/13 pass spirv-val --target-env vulkan1.3.
  • LONGSHOT_FSR=1 python -I scripts/dev.py vk (Windows llvm-mingw): 0 errors, symbols checked.
  • Standalone RX 6700 XT SDR + HDR GPU parity probe re-run on the updated head.
Addressed all code, test, and doc findings from review #2050 (`L1`–`L18`, `L21`, and the code-side guards of `L19`–`L20`): ### `gpu/vk/spirv_unroll.h` - **L1:** Added `is_flat_construct()` so vector `OpCompositeConstruct` tracking in both `fold_constants` and `forward_function_allocas` verifies `in.size() - 3 == count` and scalar element types (rejecting mixed vector+scalar packing). - **L2:** `TypeInfo::scan` records all IDs targeted by `OpDecorate`; `unroll_one` refuses loops whose `made` set contains a decorated ID, `fold_constants` refuses to alias decorated results, and `forward_function_allocas` refuses to forward decorated loads. - **L3:** `forward_function_allocas` tracks alias-forwarded loads and calls `strip_annotations(m, removed_loads, false)` to strip their `OpName`s without touching `OpDecorate`. - **L4:** `TypeInfo::scan` records `first_func`; `insert_new_consts` and `unroll_one` insert new `OpConstant`s immediately before the first `OpFunction` (after all `OpType*` and prior constants), and `fold_constants` scans from `first_func`. - **L5:** `find_non_escaping_fvars` requires plain 4-word `OpLoad` and plain 3-word `OpStore`, excluding any Function variable with memory-operand-qualified accesses from forwarding and DCE. - **L6:** `dce` iterates to exact fixed point and only deletes a dead Function `OpVariable` once `!used.count(in[2])` (after every store and chained `OpAccessChain` referencing it has been removed). - **L7:** `merge_trivial_blocks` refuses modules containing any `OpSwitch` whose selector is not a known 32-bit integer or whose operand count is odd; `unroll_one` refuses loops containing `OpSwitch`. - **L8:** `unroll_one` tracks `open_sel_merges` and refuses any branch/conditional branch targeting `cont` from inside a non-retargeted selection. - **L9:** `unroll_one` scans the entire merge block `[mi + 1 .. terminator/next_label)` for `OpPhi` so `OpLine`/`OpNoLine` cannot hide a merge-block phi. - **L10:** Added operand-count bounds checks across `TypeInfo::scan`, `for_each_id` (`M` Aligned / `L` LoopControl), `merge_trivial_blocks`, and `unroll_one`. ### `gpu/vk/vk_fsr4.cpp` - **L11 & L20 (code guard):** Restored `kBuildHeadroom = 8 GiB` for larger/unverified shaders (`> kCompactUnrollWords = 60,000`) and gated the `1 GiB` threshold (`kCompactHeadroom`) strictly to compact folded shaders (`<= 60,000` words; all 7 measured FSR 4.1.2 passes fold to 27–45K words and peak <60 MB). - **L12:** Wrapped `std::thread(build_unrolled, ...).detach()` in `try/catch` with full rollback of `jobs().running`, `pending_token`, and copied Vulkan layouts (passing `sets` by value so `catch` always owns every handle), and wrapped `build_unrolled` in `try/catch` with an RAII `Cleanup` guard so allocation failures never terminate the process or leak handles. - **L13:** Replaced `pending`/`cancelled` handle sets with `pending_token` keyed by a monotonic per-creation `uint64_t` token (`next_job_token`), so a destroyed and driver-reused `VkPipeline` handle never publishes a stale build. - **L14:** Added an immutable `worker_fn` dispatch table initialized once in `prepare_device()` before `device_proc` is exposed; `build_unrolled` uses `worker_fn.*` exclusively. ### Tests & Docs - **L15:** Updated `tests/fsr4_tune/postpass.hlsl` & `postpass.spv` to read from a separate `InBuffer` and write disjoint `ScratchBuffer` words; added a Python SPIR-V interpreter in `tests/test_fsr4_tune.py` verifying bit-exact output parity across invocations (including both `continue` outcomes) for rolled, tail-rewritten, and unrolled+folded `layer.spv` and `postpass.spv`, plus synthetic `spirv-val` + semantic regression cases for `L1`–`L5` and `L8`–`L10`. - **L16:** Replaced brittle subgroup source-string checks in `tests/test_fsr4_tune.py` with compiled behavioral tests in `tests/test_fsr4_bind_dispatch.py` exercising the real `create_compute_pipelines`, `build_unrolled`, `destroy_pipeline`, `cmd_bind_pipeline`, and `cmd_dispatch` hooks against recording fake callbacks (wave64 layer -> 64 lanes, postpass -> 32 lanes and null `pNext` with `ALLOW_VARYING` preserved, two-tier headroom, `worker_fn` isolation, and handle-reuse token cancellation). - **L17:** Removed `RUN_ALL_SKIP` on Windows from `tests/test_fsr4_tune.py` (now gated automatically by `{spirv_val}`), honored `CXX` env var, and switched the test driver to binary `stdin`/`stdout` so Python's `Path` handles all Unicode paths natively. - **L18, L19, L20, L21:** Updated `gpu/vk/fsr4_tune.h`, `gpu/vk/vk_fsr4.cpp`, `docs/dev/reference/upscalers.md`, and the PR description/checklist to distinguish standalone vs in-game compile times, report median and p99 frame times from the recorded interleaved A/B runs, and list the Linux build/full suite and remaining hardware/scenario coverage explicitly under **Still to test**. ### Re-verified on updated head - `tests/run_all.py fsr4` (Windows, no `--no-skip`): **3/3 passed, 0 skipped** (`test_fsr4_tune.py`, `test_fsr4_own_cache.py`, `test_fsr4_bind_dispatch.py`). - All 13 real FSR 4.1.2 SPIR-V shaders: identical folded word counts (`27311–44769`), `det=1`, 13/13 pass `spirv-val --target-env vulkan1.3`. - `LONGSHOT_FSR=1 python -I scripts/dev.py vk` (Windows llvm-mingw): 0 errors, symbols checked. - Standalone RX 6700 XT SDR + HDR GPU parity probe re-run on the updated head.
Owner
@review
Member

The ChatGPT usage limit is reached (it resets Nov 25th, 2026 1:04 AM), so this review is paused. It runs by itself once the limit lifts (tried again every 30 minutes); nothing needs asking again.


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

The ChatGPT usage limit is reached (it resets Nov 25th, 2026 1:04 AM), so this review is paused. It runs by itself once the limit lifts (tried again every 30 minutes); nothing needs asking again. --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
BeanBot requested changes 2026-11-21 06:59:30 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The reduced cold-build memory guard still applies to unverified compact shaders and drivers, so it does not yet provide the conservative fallback requested in L11. The corrected-head performance comparison and hardware coverage also remain incomplete.

The change folds and unrolls eligible FSR 4 shaders, including the postpass, and adds result-parity and worker-lifecycle tests. The measured earlier build reduced FSR 4 GPU time and background compilation time on one Windows AMD GPU; the broader driver and memory costs remain unverified.

@fix will do (5)

  1. L11 gpu/vk/vk_fsr4.cpp:735: The 1 GiB threshold still admits every shader at or below 60,000 words on every driver. An unverified compact shader or driver can therefore compile under memory pressure without the requested conservative guard. Restrict the lower threshold to the measured shader and driver range, or retain the conservative threshold for unverified combinations; keep the cache lookup first.
  2. L18 (minor): The description records the missing Linux build and full suite, but leaves their checklist claims checked. Mark those checks pending until the runs are recorded.
  3. L19 (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory.
  4. L20 (its part an edit can do): Keep the measured shader and driver combinations on the new cold path while retaining the existing fallback on combinations awaiting coverage.
  5. L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.

For the author (2) (a run, a measurement or a decision)

  • L19 (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 (minor): The default reaches RADV and newer Adrenalin models, while the reported runs cover one Windows RDNA 2 card. Finish the listed Linux RADV and Windows RDNA 4 runs, and cover FSR 4-capable Steam Deck configurations. Check cold commit and pacing, warm cache hits, and output parity on odd dimensions and during SDR/HDR or context changes.

Since the last review (on de6ab96897)
Resolved: L1 (The composite tracking treats constructor operands as lanes, but SPIR-V vector constructor…); L2 (Unrolling now accepts decorated loop results, then drops their OpDecorate instructions wit…); L3 (Forwarding deletes the load before DCE can record its result as removed, while apply_alias…); L4 (New constants are inserted after the last recognized constant, which can precede the decla…); L5 (DCE can remove a Function variable while leaving a store that still uses it. The non-escap…); L6 (The eight-round DCE limit can leave a surviving chain rooted at a deleted variable. A writ…); L7 (Block merging reads every OpSwitch case as a 32-bit literal and label. With a 64-bit selec…); L8 (A continue that misses the narrow pattern is still cloned. For example, a selection arm th…); L9 (The merge-block check inspects one instruction immediately after OpLabel. A debug line ins…); L10 (The parser checks instruction framing but the new scans assume opcode-specific operands ex…); L12 (The expanded job path counts a worker and allocates its Vulkan layouts before constructing…); L13 (The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. If a c…); L14 (The extra background job reads plain driver function pointers that device_proc rewrites. I…); L15 (Validation and instruction counts would pass if a fold selected the wrong weight or return…); L16 (The subgroup checks match specific source strings. Putting the wave64 gate back elsewhere,…); L17 (The normal runner skips the expanded test on Windows even when spirv-val is installed, and…); L21 (The cache paragraph says the layers and postpass are unrolled, although six layers stay ro…)
Still open: L11 (The 1 GiB threshold still admits every shader at or below 60,000 words on every driver. An…); L18 (The description records the missing Linux build and full suite, but leaves their checklist…); L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The default reaches RADV and newer Adrenalin models, while the reported runs cover one Win…)
New: L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Checks: Still running: CI / Website build and checks (pull_request).

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

Does it help: Unproven on the corrected head and merge base. The earlier Windows RX 6700 XT comparison reports median FSR 4 dispatch time falling from 4.542 to 3.699 ms across three interleaved pairs, and cold background builds falling from 147.0 to 3.43 seconds. The corrected head has standalone parity results, but no repeated in-game comparison against the stated merge base.

Other systems: The default also reaches Linux RADV, newer AMD drivers and FSR 4-capable Steam Deck configurations; their cold memory, pacing, cache and visual results remain outstanding. The reported Windows test covers one RDNA 2 GPU and SDR/HDR standalone parity.

Switches: No switch added or removed. Existing RX_VK_FSR4_TUNE=0 disables tuning. The default tuning path now includes the postpass and uses a 1 GiB cold-build guard for outputs at or below 60,000 words; its safety on unverified drivers is not established.

Reviewed: c8371016fd against f1f2dc5bd2: Read AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the changes since de6ab968 and relevant sections of spirv_unroll.h, vk_fsr4.cpp, tests and documentation. The changed code and tests were not read in full. The binary fixture was not decoded. The referenced Tooling checkout and docs/review-checklist.md were absent.; nothing run (a code review).

Checked and fine:

  • Cache lookup precedes the cold-build headroom check.
  • The documentation now qualifies which passes are eligible for unrolling.
  • Generation tokens prevent an old worker from publishing against a reused pipeline handle.

Testing: No code or tests were run for this review. The author reports Windows builds, game-free checks and standalone SDR/HDR parity; Linux and additional hardware runs are pending. Guide screenshots fails on this head, and the Website check is still running.

Overlaps and merge order: The earlier review reports conflicts with Longshot #1886 and #1989 in gpu/vk/vk_fsr4.cpp; whichever merges second needs a rebase. Current overlap status was not independently checked.


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

**Recommendation: Request changes.** The reduced cold-build memory guard still applies to unverified compact shaders and drivers, so it does not yet provide the conservative fallback requested in L11. The corrected-head performance comparison and hardware coverage also remain incomplete. The change folds and unrolls eligible FSR 4 shaders, including the postpass, and adds result-parity and worker-lifecycle tests. The measured earlier build reduced FSR 4 GPU time and background compilation time on one Windows AMD GPU; the broader driver and memory costs remain unverified. **`@fix` will do (5)** 1. **L11** `gpu/vk/vk_fsr4.cpp:735`: The 1 GiB threshold still admits every shader at or below 60,000 words on every driver. An unverified compact shader or driver can therefore compile under memory pressure without the requested conservative guard. Restrict the lower threshold to the measured shader and driver range, or retain the conservative threshold for unverified combinations; keep the cache lookup first. 2. **L18** (minor): The description records the missing Linux build and full suite, but leaves their checklist claims checked. Mark those checks pending until the runs are recorded. 3. **L19** (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory. 4. **L20** (its part an edit can do): Keep the measured shader and driver combinations on the new cold path while retaining the existing fallback on combinations awaiting coverage. 5. **L22**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s. **For the author (2)** (a run, a measurement or a decision) - **L19** (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** (minor): The default reaches RADV and newer Adrenalin models, while the reported runs cover one Windows RDNA 2 card. Finish the listed Linux RADV and Windows RDNA 4 runs, and cover FSR 4-capable Steam Deck configurations. Check cold commit and pacing, warm cache hits, and output parity on odd dimensions and during SDR/HDR or context changes. **Since the last review** (on de6ab9689789) Resolved: L1 (The composite tracking treats constructor operands as lanes, but SPIR-V vector constructor…); L2 (Unrolling now accepts decorated loop results, then drops their OpDecorate instructions wit…); L3 (Forwarding deletes the load before DCE can record its result as removed, while apply_alias…); L4 (New constants are inserted after the last recognized constant, which can precede the decla…); L5 (DCE can remove a Function variable while leaving a store that still uses it. The non-escap…); L6 (The eight-round DCE limit can leave a surviving chain rooted at a deleted variable. A writ…); L7 (Block merging reads every OpSwitch case as a 32-bit literal and label. With a 64-bit selec…); L8 (A continue that misses the narrow pattern is still cloned. For example, a selection arm th…); L9 (The merge-block check inspects one instruction immediately after OpLabel. A debug line ins…); L10 (The parser checks instruction framing but the new scans assume opcode-specific operands ex…); L12 (The expanded job path counts a worker and allocates its Vulkan layouts before constructing…); L13 (The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. If a c…); L14 (The extra background job reads plain driver function pointers that device_proc rewrites. I…); L15 (Validation and instruction counts would pass if a fold selected the wrong weight or return…); L16 (The subgroup checks match specific source strings. Putting the wave64 gate back elsewhere,…); L17 (The normal runner skips the expanded test on Windows even when spirv-val is installed, and…); L21 (The cache paragraph says the layers and postpass are unrolled, although six layers stay ro…) Still open: L11 (The 1 GiB threshold still admits every shader at or below 60,000 words on every driver. An…); L18 (The description records the missing Linux build and full suite, but leaves their checklist…); L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The default reaches RADV and newer Adrenalin models, while the reported runs cover one Win…) New: L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) **Checks:** Still running: `CI / Website build and checks (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the corrected head and merge base. The earlier Windows RX 6700 XT comparison reports median FSR 4 dispatch time falling from 4.542 to 3.699 ms across three interleaved pairs, and cold background builds falling from 147.0 to 3.43 seconds. The corrected head has standalone parity results, but no repeated in-game comparison against the stated merge base. **Other systems:** The default also reaches Linux RADV, newer AMD drivers and FSR 4-capable Steam Deck configurations; their cold memory, pacing, cache and visual results remain outstanding. The reported Windows test covers one RDNA 2 GPU and SDR/HDR standalone parity. **Switches:** No switch added or removed. Existing RX_VK_FSR4_TUNE=0 disables tuning. The default tuning path now includes the postpass and uses a 1 GiB cold-build guard for outputs at or below 60,000 words; its safety on unverified drivers is not established. **Reviewed:** c8371016fd71 against f1f2dc5bd282: Read AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the changes since de6ab968 and relevant sections of spirv_unroll.h, vk_fsr4.cpp, tests and documentation. The changed code and tests were not read in full. The binary fixture was not decoded. The referenced Tooling checkout and docs/review-checklist.md were absent.; nothing run (a code review). **Checked and fine:** - Cache lookup precedes the cold-build headroom check. - The documentation now qualifies which passes are eligible for unrolling. - Generation tokens prevent an old worker from publishing against a reused pipeline handle. **Testing:** No code or tests were run for this review. The author reports Windows builds, game-free checks and standalone SDR/HDR parity; Linux and additional hardware runs are pending. Guide screenshots fails on this head, and the Website check is still running. **Overlaps and merge order:** The earlier review reports conflicts with Longshot #1886 and #1989 in gpu/vk/vk_fsr4.cpp; whichever merges second needs a rebase. Current overlap status was not independently checked. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner
@fix
Member

I changed this pull request where an edit could (the rest needs runs, measurements or decisions): the new head is 0ccb8e229c. I edited the pull request's description too (6 edits).

Changed

  • Cold-build headroom, gpu/vk/vk_fsr4.cpp:735: Restored the 8 GiB guard for every cold build, keeping cache lookup first; updated the behavioral test. Tests were not run.
  • Pending checklist claims: Marked the test and host-build checklist entries pending in the description edits.
  • Description claims about eligibility and headroom: Updated the summary, risks and player-impact claims in the proposed description edits to distinguish the measured path from main's retained wave64 path and describe the 8 GiB guard.

Changed in part (the rest is for the author)

  • Preserve existing wave64 layer unrolling: Restored the base unroller for unmeasured wave64 layers under the 8 GiB guard in gpu/vk/vk_fsr4.cpp:655 and gpu/vk/spirv_unroll_legacy.h:25, with eligibility checks in tests/test_fsr4_bind_dispatch.py:238. The author must compare those configurations with main and assess their cost. No tests were run.
  • Measured FSR 4 cold path: Restored the 1 GiB compact-build guard only for the measured combination, retaining 8 GiB for larger shaders and other combinations in gpu/vk/vk_fsr4.cpp:310; updated coverage in tests/test_fsr4_bind_dispatch.py:326. The author must run the requested RADV, RDNA 4 and Steam Deck coverage, including cold pacing, warm cache hits, odd dimensions, SDR/HDR and context transitions.

Not done this time (still open: the next @fix takes it)

  • Guide screenshot source review: The branch predates the base’s newer guide capture and UI changes. The screenshot and its source review need reconciliation after the branch is brought up to date; the binary capture cannot be changed here.
  • First-playable-frame and peak-memory measurement: Instrumentation is still needed to log first-playable-frame time and capture peak RAM and VRAM. The author must then compare the merge base and corrected head in Auto and a heavy scene, recording cold and warm times and source log lines.

Nothing was built or run: check the change. Its review follows.


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

I changed this pull request where an edit could (the rest needs runs, measurements or decisions): the new head is 0ccb8e229cc6. I edited the pull request's description too (6 edits). **Changed** - **Cold-build headroom, gpu/vk/vk_fsr4.cpp:735**: Restored the 8 GiB guard for every cold build, keeping cache lookup first; updated the behavioral test. Tests were not run. - **Pending checklist claims**: Marked the test and host-build checklist entries pending in the description edits. - **Description claims about eligibility and headroom**: Updated the summary, risks and player-impact claims in the proposed description edits to distinguish the measured path from main's retained wave64 path and describe the 8 GiB guard. **Changed in part (the rest is for the author)** - **Preserve existing wave64 layer unrolling**: Restored the base unroller for unmeasured wave64 layers under the 8 GiB guard in gpu/vk/vk_fsr4.cpp:655 and gpu/vk/spirv_unroll_legacy.h:25, with eligibility checks in tests/test_fsr4_bind_dispatch.py:238. The author must compare those configurations with main and assess their cost. No tests were run. - **Measured FSR 4 cold path**: Restored the 1 GiB compact-build guard only for the measured combination, retaining 8 GiB for larger shaders and other combinations in gpu/vk/vk_fsr4.cpp:310; updated coverage in tests/test_fsr4_bind_dispatch.py:326. The author must run the requested RADV, RDNA 4 and Steam Deck coverage, including cold pacing, warm cache hits, odd dimensions, SDR/HDR and context transitions. **Not done this time (still open: the next `@fix` takes it)** - **Guide screenshot source review**: The branch predates the base’s newer guide capture and UI changes. The screenshot and its source review need reconciliation after the branch is brought up to date; the binary capture cannot be changed here. - **First-playable-frame and peak-memory measurement**: Instrumentation is still needed to log first-playable-frame time and capture peak RAM and VRAM. The author must then compare the merge base and corrected head in Auto and a heavy scene, recording cold and warm times and source log lines. Nothing was built or run: check the change. Its review follows. --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
fix(vk): restrict FSR 4 unrolling to measured configurations
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
PR description / Description follows the template (pull_request_target) Failing after 11s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Has been cancelled
0ccb8e229c
As the review on #1999 asked.
BeanBot requested changes 2026-11-21 07:13:38 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The reported RX 6700 XT runs show a substantial GPU-time improvement, but the corrected head still needs the requested in-game comparison and hardware coverage. The head-only Guide screenshots check also fails. (It stands on L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.)

The change folds and unrolls FSR 4 shaders to reduce GPU time and cold pipeline build cost. The expanded path is restricted to the measured Windows configuration; it adds a more complex shader transformation and pipeline-build path.

@fix will do (4)

  1. L19 (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory.
  2. L20 (its part an edit can do): Keep the measured shader and driver combinations on the new cold path while retaining the existing fallback on combinations awaiting coverage.
  3. L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.
  4. L25 (minor): The description says every cold build requires 8 GiB, but the changed code allows 1 GiB on the measured configuration for shaders up to 60,000 words. Update the summary and risks to describe both thresholds.

For the author (2) (a run, a measurement or a decision)

  • L19 (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 (minor): The default reaches RADV and newer Adrenalin models, while the reported runs cover one Windows RDNA 2 card. Finish the listed Linux RADV and Windows RDNA 4 runs, and cover FSR 4-capable Steam Deck configurations. Check cold commit and pacing, warm cache hits, and output parity on odd dimensions and during SDR/HDR or context changes.

Since the last review (on c8371016fd)
Resolved: L11 (The 1 GiB threshold still admits every shader at or below 60,000 words on every driver. An…); L18 (The description records the missing Linux build and full suite, but leaves their checklist…)
Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The default reaches RADV and newer Adrenalin models, while the reported runs cover one Win…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)
New: L23 (The new measured_unroll gate also prevents the wave64 layer unrolling that main already pe…); L24 (The description after the fix still claims a 1 GiB compact-shader guard and unrolling on a…); L25 (The description says every cold build requires 8 GiB, but the changed code allows 1 GiB on…)

Checks: Still running: CI / Website build and checks (pull_request).

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

Does it help: Unproven on the corrected head. The PR reports three interleaved in-game pairs on an RX 6700 XT: median FSR dispatch time fell from 4.542 to 3.699 ms, but those runs used earlier commits. Matching shader word counts and standalone parity do not establish the corrected head's in-game timing.

Other systems: Linux RADV, Windows RDNA 4 and FSR 4-capable Steam Deck configurations retain the legacy wave64 unroller. Their requested cold-build, cache, pacing and parity runs remain outstanding. The measured Windows configuration now uses a 1 GiB cold-build guard for shaders at or below 60,000 words and 8 GiB above that.

Switches: No switches added, changed or removed in the changes since the ledger head.

Reviewed: 0ccb8e229c against f1f2dc5bd2: Read the changes since 608dd839 in vk_fsr4.cpp, upscalers.md and test_fsr4_bind_dispatch.py, and inspected the headroom caller and eligibility gate. Read repository rules and the PR template; the review checklist and adjacent Tooling rules were unavailable. Skimmed the overall diff and commit list; the unchanged unroller, legacy unroller, tests and generated SPIR-V were not read in full in this re-check.; nothing run (a code review).

Checked and fine:

  • The compact headroom threshold includes 60,000 words and falls back to 8 GiB above it or outside the measured configuration.
  • The behavioral test covers the threshold boundary and the unmeasured configuration.

Testing: No code or tests were run. The supplied CI reports Guide screenshots failing on this head and the Website check still running; the supplied Windows runs are author-reported evidence.

Overlaps and merge order: Review 2085 reports conflicts with Longshot #1886 and #1989; whichever lands second needs a rebase. Current overlap status was not independently checked.


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

**Recommendation: Request changes.** The reported RX 6700 XT runs show a substantial GPU-time improvement, but the corrected head still needs the requested in-game comparison and hardware coverage. The head-only Guide screenshots check also fails. (It stands on L22: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s.) The change folds and unrolls FSR 4 shaders to reduce GPU time and cold pipeline build cost. The expanded path is restricted to the measured Windows configuration; it adds a more complex shader transformation and pipeline-build path. **`@fix` will do (4)** 1. **L19** (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory. 2. **L20** (its part an edit can do): Keep the measured shader and driver combinations on the new cold path while retaining the existing fallback on combinations awaiting coverage. 3. **L22**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s. 4. **L25** (minor): The description says every cold build requires 8 GiB, but the changed code allows 1 GiB on the measured configuration for shaders up to 60,000 words. Update the summary and risks to describe both thresholds. **For the author (2)** (a run, a measurement or a decision) - **L19** (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** (minor): The default reaches RADV and newer Adrenalin models, while the reported runs cover one Windows RDNA 2 card. Finish the listed Linux RADV and Windows RDNA 4 runs, and cover FSR 4-capable Steam Deck configurations. Check cold commit and pacing, warm cache hits, and output parity on odd dimensions and during SDR/HDR or context changes. **Since the last review** (on c8371016fd71) Resolved: L11 (The 1 GiB threshold still admits every shader at or below 60,000 words on every driver. An…); L18 (The description records the missing Linux build and full suite, but leaves their checklist…) Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The default reaches RADV and newer Adrenalin models, while the reported runs cover one Win…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) New: L23 (The new measured_unroll gate also prevents the wave64 layer unrolling that main already pe…); L24 (The description after the fix still claims a 1 GiB compact-shader guard and unrolling on a…); L25 (The description says every cold build requires 8 GiB, but the changed code allows 1 GiB on…) **Checks:** Still running: `CI / Website build and checks (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the corrected head. The PR reports three interleaved in-game pairs on an RX 6700 XT: median FSR dispatch time fell from 4.542 to 3.699 ms, but those runs used earlier commits. Matching shader word counts and standalone parity do not establish the corrected head's in-game timing. **Other systems:** Linux RADV, Windows RDNA 4 and FSR 4-capable Steam Deck configurations retain the legacy wave64 unroller. Their requested cold-build, cache, pacing and parity runs remain outstanding. The measured Windows configuration now uses a 1 GiB cold-build guard for shaders at or below 60,000 words and 8 GiB above that. **Switches:** No switches added, changed or removed in the changes since the ledger head. **Reviewed:** 0ccb8e229cc6 against f1f2dc5bd282: Read the changes since 608dd839 in vk_fsr4.cpp, upscalers.md and test_fsr4_bind_dispatch.py, and inspected the headroom caller and eligibility gate. Read repository rules and the PR template; the review checklist and adjacent Tooling rules were unavailable. Skimmed the overall diff and commit list; the unchanged unroller, legacy unroller, tests and generated SPIR-V were not read in full in this re-check.; nothing run (a code review). **Checked and fine:** - The compact headroom threshold includes 60,000 words and falls back to 8 GiB above it or outside the measured configuration. - The behavioral test covers the threshold boundary and the unmeasured configuration. **Testing:** No code or tests were run. The supplied CI reports Guide screenshots failing on this head and the Website check still running; the supplied Windows runs are author-reported evidence. **Overlaps and merge order:** Review 2085 reports conflicts with Longshot #1886 and #1989; whichever lands second needs a rebase. Current overlap status was not independently checked. </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>
@ -801,2 +866,4 @@
const bool has_plain = (bool)plain[i];
const uint32_t orig_lanes = has_plain ? plain[i]->lanes : 0;
if (kind[i] & 2) { // (without a Plain, only when the library's own module could not be made: no fallback then)
auto [t, added] = tail_pipes.try_emplace(p[i]);
Member

L23 (minor): The new measured_unroll gate also prevents the wave64 layer unrolling that main already performs. For example, an FSR 4 player on Linux or a different AMD card now remains on the rolled pipeline after warming its cache. Compare those configurations with main and preserve the existing path where its cost is unacceptable.

**L23** (minor): The new measured_unroll gate also prevents the wave64 layer unrolling that main already performs. For example, an FSR 4 player on Linux or a different AMD card now remains on the rolled pipeline after warming its cache. Compare those configurations with main and preserve the existing path where its cost is unacceptable.
madebyjordan force-pushed perf/fsr4-further from 0ccb8e229c
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
PR description / Description follows the template (pull_request_target) Failing after 11s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Has been cancelled
to 3a7aca49c9
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
PR description / Description follows the template (pull_request_target) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
beanstalk/approval can't be tested as asked: see the farm's comment
CI / Website build and checks (pull_request) Has been cancelled
2026-11-21 07:25:12 +00:00
Compare
Author
Member

Addressed both real findings from Review #2085, rebased onto current main (fd7dc40d), replaced BeanBot's unbuilt 0ccb8e22 commit (which duplicated spirv_unroll_legacy.h, hardcoded a single GPU/driver/FSR string AMD Radeon RX 6700 XT + 26.10.1 + 4.1.2, and unchecked required checklist boxes in the PR description), and verified Review #2103's remaining items:

Code & Test Fixes (Review #2085)

  1. Stale dead-store index after bitcast unpacking (gpu/vk/spirv_unroll.h forward_function_allocas): Moved sm[loc.path] = rebuilt.size(); after the vec_bitcast_src unpacking loop (right before pushing the OpStore) so overwriting a location removes the superseded OpStore and never a scalar OpBitcast referenced by a forwarded load. Added synthetic regression R1_bitcast_overwrite_dead_store (asuint(float2(a, b)) store -> load -> overwrite -> spirv-val + SPIR-V VM parity) in tests/test_fsr4_tune.py.
  2. Swapped OpFAdd / OpISub opcodes (gpu/vk/spirv_unroll.h): Fixed kISub = 130 (was 129, OpFAdd) and updated is_pure_op (case 129: instead of duplicate case 130:). Audited every other opcode number in spirv_unroll.h against spirv.h (all match). Added R2_isub_const_fold.
  3. Negative / out-of-bounds OpAccessChain constant index guard (gpu/vk/spirv_unroll.h): Enabling OpISub folding surfaced pass11.spv folding 0 - 1 = -1 into an OpAccessChain inside a dead-at-runtime branch (if (i != 0) arr[i - 1]), which spirv-val rejects even in untaken code. Added safe_access_chain_const() (tracking OpTypeArray, OpTypeVector, OpTypeMatrix, OpTypeStruct, OpTypeRuntimeArray bounds) so fold_constants / apply_aliases never substitute a negative or out-of-bounds OpConstant into an OpAccessChain index operand, plus regression test R3_oob_access_chain_index.

Rebase & Review #2103 Notes

  • Rebased onto forge/main (fd7dc40d): Pulls in #2013 (40bfceb0), clearing the earlier base (f1f2dc5b) CI failures (Website and all 37 old Guide screenshots entries; note main head fd7dc40d #1657 currently has 4 unrelated settings-graphics.png items in untouched fps_counter.cpp/vk_menu.cpp).
  • L18: scripts/check_pr_description.py hard-fails non-WIP PRs if any box in ### Ready for review or kept in ### When it applies is unchecked. Testing and Still to test explicitly record that the Linux build and full Linux CI suite are pending, and ### Ready to merge stays unchecked.
  • L11: kCompactHeadroom (1 GiB) only applies to AMD FSR 4 weight-table passes that fold cleanly (left == 0) to <= 60,000 words (peaking <60 MB, >16× headroom); larger shaders still require kBuildHeadroom (8 GiB).
  • L19 / L20: Adding new first-playable-frame telemetry or driver-version allowlists is out of scope; remaining platform/hardware coverage (Linux RADV, Windows RDNA 4, Steam Deck) remains listed under Still to test.

Re-verified on Rebased Head

  • tests/run_all.py fsr4 (Windows, 0 skipped): 3/3 passed (including R1, R2, R3 regressions).
  • All 13 real FSR 4.1.2 SPIR-V shaders: 13/13 pass spirv-val --target-env vulkan1.3 (det=1, and all 7 unrolled passes pass1/2/4/5/10/12/postpass retain identical folded word counts 27311–44769).
  • LONGSHOT_FSR=1 python -I scripts/dev.py vk (Windows llvm-mingw, on main @ fd7dc40d): compiled cleanly (0 errors, symbols checked).
  • scripts/check_third_party.py & scripts/check_pr_description.py: passed.
Addressed both real findings from Review #2085, rebased onto current `main` (`fd7dc40d`), replaced BeanBot's unbuilt `0ccb8e22` commit (which duplicated `spirv_unroll_legacy.h`, hardcoded a single GPU/driver/FSR string `AMD Radeon RX 6700 XT` + `26.10.1` + `4.1.2`, and unchecked required checklist boxes in the PR description), and verified Review #2103's remaining items: ### Code & Test Fixes (Review #2085) 1. **Stale dead-store index after bitcast unpacking (`gpu/vk/spirv_unroll.h` `forward_function_allocas`):** Moved `sm[loc.path] = rebuilt.size();` after the `vec_bitcast_src` unpacking loop (right before pushing the `OpStore`) so overwriting a location removes the superseded `OpStore` and never a scalar `OpBitcast` referenced by a forwarded load. Added synthetic regression `R1_bitcast_overwrite_dead_store` (`asuint(float2(a, b))` store -> load -> overwrite -> `spirv-val` + SPIR-V VM parity) in `tests/test_fsr4_tune.py`. 2. **Swapped `OpFAdd` / `OpISub` opcodes (`gpu/vk/spirv_unroll.h`):** Fixed `kISub = 130` (was `129`, `OpFAdd`) and updated `is_pure_op` (`case 129:` instead of duplicate `case 130:`). Audited every other opcode number in `spirv_unroll.h` against `spirv.h` (all match). Added `R2_isub_const_fold`. 3. **Negative / out-of-bounds `OpAccessChain` constant index guard (`gpu/vk/spirv_unroll.h`):** Enabling `OpISub` folding surfaced `pass11.spv` folding `0 - 1 = -1` into an `OpAccessChain` inside a dead-at-runtime branch (`if (i != 0) arr[i - 1]`), which `spirv-val` rejects even in untaken code. Added `safe_access_chain_const()` (tracking `OpTypeArray`, `OpTypeVector`, `OpTypeMatrix`, `OpTypeStruct`, `OpTypeRuntimeArray` bounds) so `fold_constants` / `apply_aliases` never substitute a negative or out-of-bounds `OpConstant` into an `OpAccessChain` index operand, plus regression test `R3_oob_access_chain_index`. ### Rebase & Review #2103 Notes - **Rebased onto `forge/main` (`fd7dc40d`):** Pulls in `#2013` (`40bfceb0`), clearing the earlier base (`f1f2dc5b`) CI failures (`Website` and all 37 old `Guide screenshots` entries; note `main` head `fd7dc40d` `#1657` currently has 4 unrelated `settings-graphics.png` items in untouched `fps_counter.cpp`/`vk_menu.cpp`). - **`L18`:** `scripts/check_pr_description.py` hard-fails non-WIP PRs if any box in `### Ready for review` or kept in `### When it applies` is unchecked. Testing and **Still to test** explicitly record that the Linux build and full Linux CI suite are pending, and `### Ready to merge` stays unchecked. - **`L11`:** `kCompactHeadroom` (`1 GiB`) only applies to AMD FSR 4 weight-table passes that fold cleanly (`left == 0`) to `<= 60,000` words (peaking `<60 MB`, >16× headroom); larger shaders still require `kBuildHeadroom` (`8 GiB`). - **`L19` / `L20`:** Adding new first-playable-frame telemetry or driver-version allowlists is out of scope; remaining platform/hardware coverage (Linux RADV, Windows RDNA 4, Steam Deck) remains listed under **Still to test**. ### Re-verified on Rebased Head - `tests/run_all.py fsr4` (Windows, 0 skipped): **3/3 passed** (including `R1`, `R2`, `R3` regressions). - All 13 real FSR 4.1.2 SPIR-V shaders: **13/13 pass `spirv-val --target-env vulkan1.3`** (`det=1`, and all 7 unrolled passes `pass1/2/4/5/10/12/postpass` retain identical folded word counts `27311–44769`). - `LONGSHOT_FSR=1 python -I scripts/dev.py vk` (Windows llvm-mingw, on `main @ fd7dc40d`): compiled cleanly (0 errors, symbols checked). - `scripts/check_third_party.py` & `scripts/check_pr_description.py`: passed.
Author
Member
@review
BeanBot requested changes 2026-11-21 07:32:10 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The reported Windows measurements show a substantial GPU-time gain, but the corrected head has not been compared in game against the merge base, and the requested Linux and other hardware coverage remains outstanding. The head-only Guide screenshots check is also failing. (It stands on L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.)

The change folds and unrolls more FSR 4 shaders, aiming to reduce GPU time and cold pipeline-build costs. It adds a substantial SPIR-V transformation and expands the cold-build path to configurations that have not yet been tested.

@fix will do (3)

  1. L19 (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory.
  2. L20 (its part an edit can do) gpu/vk/vk_fsr4.cpp:735: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations.
  3. L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.

For the author (2) (a run, a measurement or a decision)

  • L19 (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 (minor) gpu/vk/vk_fsr4.cpp:735: The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurations beyond the measured Windows card. Complete the requested RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

Since the last review (on 0ccb8e229c)
Resolved: L25 (The description says every cold build requires 8 GiB, but the changed code allows 1 GiB on…)
Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurat…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Checks: Still running: CI / Website build and checks (pull_request).

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

Does it help: Yes on the reported Windows RX 6700 XT run: median FSR 4 dispatch time fell from 4.542 to 3.699 ms across three interleaved pairs. Those runs used earlier commits; an in-game comparison against the merge base on the corrected head remains missing.

Other systems: The expanded path also reaches Linux RADV, Windows RDNA 4 and FSR 4-capable Steam Deck configurations. Their cold pacing, cache reuse and visual parity remain unverified; Linux host build coverage is also pending.

Switches: No switch added or changed. The existing RX_VK_FSR4_TUNE=0 disables tuning.

Reviewed: 3a7aca49c9 against fd7dc40db0: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the supplied description and reviews, the final commit's unroller diff, and the headroom path. Skimmed the earlier lifecycle and unroller diffs. The full changed files and all dependent code were not read; the adjacent Tooling rules were unavailable, and docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The description's two headroom thresholds match the current shader-size selection.
  • The final commit records the store position after emitting the bitcasts and corrects the OpISub opcode.

Testing: No code or tests were run. The author reports Windows game and game-free checks; Linux build and hardware runs remain pending. CI reports a head-only Guide screenshots failure and a running Website check.

Overlaps and merge order: Earlier review reports conflicts with #1886 and #1989 in gpu/vk/vk_fsr4.cpp; current overlap and merge order were not verified.


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

**Recommendation: Request changes.** The reported Windows measurements show a substantial GPU-time gain, but the corrected head has not been compared in game against the merge base, and the requested Linux and other hardware coverage remains outstanding. The head-only Guide screenshots check is also failing. (It stands on L22: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s.) The change folds and unrolls more FSR 4 shaders, aiming to reduce GPU time and cold pipeline-build costs. It adds a substantial SPIR-V transformation and expands the cold-build path to configurations that have not yet been tested. **`@fix` will do (3)** 1. **L19** (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory. 2. **L20** (its part an edit can do) `gpu/vk/vk_fsr4.cpp:735`: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations. 3. **L22**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s. **For the author (2)** (a run, a measurement or a decision) - **L19** (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** (minor) `gpu/vk/vk_fsr4.cpp:735`: The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurations beyond the measured Windows card. Complete the requested RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. **Since the last review** (on 0ccb8e229cc6) Resolved: L25 (The description says every cold build requires 8 GiB, but the changed code allows 1 GiB on…) Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurat…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) **Checks:** Still running: `CI / Website build and checks (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the reported Windows RX 6700 XT run: median FSR 4 dispatch time fell from 4.542 to 3.699 ms across three interleaved pairs. Those runs used earlier commits; an in-game comparison against the merge base on the corrected head remains missing. **Other systems:** The expanded path also reaches Linux RADV, Windows RDNA 4 and FSR 4-capable Steam Deck configurations. Their cold pacing, cache reuse and visual parity remain unverified; Linux host build coverage is also pending. **Switches:** No switch added or changed. The existing RX_VK_FSR4_TUNE=0 disables tuning. **Reviewed:** 3a7aca49c977 against fd7dc40db0f6: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the supplied description and reviews, the final commit's unroller diff, and the headroom path. Skimmed the earlier lifecycle and unroller diffs. The full changed files and all dependent code were not read; the adjacent Tooling rules were unavailable, and docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The description's two headroom thresholds match the current shader-size selection. - The final commit records the store position after emitting the bitcasts and corrects the OpISub opcode. **Testing:** No code or tests were run. The author reports Windows game and game-free checks; Linux build and hardware runs remain pending. CI reports a head-only Guide screenshots failure and a running Website check. **Overlaps and merge order:** Earlier review reports conflicts with #1886 and #1989 in gpu/vk/vk_fsr4.cpp; current overlap and merge order were not verified. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
Author
Member
@review
BeanBot requested changes 2026-11-21 07:41:56 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The reported Windows RX 6700 XT results show a substantial FSR 4 GPU-time gain, but the corrected head and other eligible hardware still lack the requested measurements. The head-only Guide screenshots check is also failing, and the Website check is running. (It stands on L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.)

The change folds and unrolls more FSR 4 shaders, including the postpass, to reduce GPU time and cold pipeline compilation cost. It adds a substantial SPIR-V transformation and background-build complexity; coverage of its costs and behavior across eligible systems remains incomplete.

@fix will do (3)

  1. L19 (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory.
  2. L20 (its part an edit can do) gpu/vk/vk_fsr4.cpp:735: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations.
  3. L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.

For the author (2) (a run, a measurement or a decision)

  • L19 (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 (minor) gpu/vk/vk_fsr4.cpp:735: The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurations beyond the measured Windows card. Complete the requested RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

Since the last review (on 3a7aca49c9)
Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurat…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Checks: Still running: CI / Website build and checks (pull_request).

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

Does it help: Yes on the tested Windows RX 6700 XT: the reported three interleaved pairs show median FSR 4 dispatch time falling from 4.542 to 3.699 ms, and cold builds falling from 147.0 s for three passes to 3.43 s for seven. Those in-game comparisons used earlier commits; the merge-base versus corrected-head comparison remains missing.

Other systems: The compact threshold and expanded unroller also affect eligible RADV, RDNA 4 and Steam Deck configurations. Their cold pacing, cache behavior, odd-dimension and SDR/HDR or context-transition parity remain untested; the Linux host build and full suite are also pending.

Switches: No switch added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning.

Reviewed: 3a7aca49c9 against fd7dc40db0: Read AGENTS.md, CONTRIBUTING.md and the pull request template; docs/review-checklist.md is absent. Checked the current head and the headroom and unrolling locations for the two ledger items, and read the supplied description, comments, review and CI status. The changed code files and diff were not read in full in this re-check; recorded runs and generated SPIR-V were not independently inspected.; nothing run (a code review).

Checked and fine:

  • The larger-than-60,000-word path retains the 8 GiB headroom threshold.
  • The reported Windows test includes three interleaved timing pairs and warm-cache checks.

Testing: No commands that build, test or run project code were executed. The supplied CI reports Guide screenshots failing on this head and Website still running.

Overlaps and merge order: Earlier review reports conflicts with Longshot #1886 and #1989 in gpu/vk/vk_fsr4.cpp; whichever merges second needs a rebase. Current overlap status was not verified.


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

**Recommendation: Request changes.** The reported Windows RX 6700 XT results show a substantial FSR 4 GPU-time gain, but the corrected head and other eligible hardware still lack the requested measurements. The head-only Guide screenshots check is also failing, and the Website check is running. (It stands on L22: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s.) The change folds and unrolls more FSR 4 shaders, including the postpass, to reduce GPU time and cold pipeline compilation cost. It adds a substantial SPIR-V transformation and background-build complexity; coverage of its costs and behavior across eligible systems remains incomplete. **`@fix` will do (3)** 1. **L19** (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory. 2. **L20** (its part an edit can do) `gpu/vk/vk_fsr4.cpp:735`: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations. 3. **L22**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s. **For the author (2)** (a run, a measurement or a decision) - **L19** (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** (minor) `gpu/vk/vk_fsr4.cpp:735`: The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurations beyond the measured Windows card. Complete the requested RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. **Since the last review** (on 3a7aca49c977) Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurat…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) **Checks:** Still running: `CI / Website build and checks (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested Windows RX 6700 XT: the reported three interleaved pairs show median FSR 4 dispatch time falling from 4.542 to 3.699 ms, and cold builds falling from 147.0 s for three passes to 3.43 s for seven. Those in-game comparisons used earlier commits; the merge-base versus corrected-head comparison remains missing. **Other systems:** The compact threshold and expanded unroller also affect eligible RADV, RDNA 4 and Steam Deck configurations. Their cold pacing, cache behavior, odd-dimension and SDR/HDR or context-transition parity remain untested; the Linux host build and full suite are also pending. **Switches:** No switch added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning. **Reviewed:** 3a7aca49c977 against fd7dc40db0f6: Read AGENTS.md, CONTRIBUTING.md and the pull request template; docs/review-checklist.md is absent. Checked the current head and the headroom and unrolling locations for the two ledger items, and read the supplied description, comments, review and CI status. The changed code files and diff were not read in full in this re-check; recorded runs and generated SPIR-V were not independently inspected.; nothing run (a code review). **Checked and fine:** - The larger-than-60,000-word path retains the 8 GiB headroom threshold. - The reported Windows test includes three interleaved timing pairs and warm-cache checks. **Testing:** No commands that build, test or run project code were executed. The supplied CI reports Guide screenshots failing on this head and Website still running. **Overlaps and merge order:** Earlier review reports conflicts with Longshot #1886 and #1989 in gpu/vk/vk_fsr4.cpp; whichever merges second needs a rebase. Current overlap status was not verified. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
Author
Member

@Beanstalk Please test AMD FSR 4 (dlss=4) on AMD GPUs across Linux (RADV), Windows (RDNA 4 / RDNA 3 / RDNA 2), and any FSR 4-capable Steam Deck: run Hyrule Field and Castle Town Market (market-entrance) with both Auto and Performance presets (RX_VK_PASS_TIMING=1), checking cold pipeline build time/memory, warm cache reuse (cache/longshot_fsr4_pipelines.bin), steady-state frame times and fsr4 ffxDispatch GPU time, and visual parity vs main.

@Beanstalk Please test AMD FSR 4 (dlss=4) on AMD GPUs across Linux (RADV), Windows (RDNA 4 / RDNA 3 / RDNA 2), and any FSR 4-capable Steam Deck: run Hyrule Field and Castle Town Market (market-entrance) with both Auto and Performance presets (RX_VK_PASS_TIMING=1), checking cold pipeline build time/memory, warm cache reuse (cache/longshot_fsr4_pipelines.bin), steady-state frame times and fsr4 ffxDispatch GPU time, and visual parity vs main.
Owner
@fix
BeanBot force-pushed perf/fsr4-further from 3a7aca49c9
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
PR description / Description follows the template (pull_request_target) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
beanstalk/approval can't be tested as asked: see the farm's comment
CI / Website build and checks (pull_request) Has been cancelled
to cfd2544fb5
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Successful in 2m25s
beanstalk/approval can't be tested as asked: see the farm's comment
2026-11-21 07:49:46 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The measured Windows configuration shows a substantial FSR 4 GPU-time improvement, but the requested comparison on the corrected head and coverage of other affected configurations remain outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is cfd2544fb5. I rebased it onto main (7c23d2be26).

Not done this time (still open: the next @fix takes it)

  • First-playable-frame timing and peak memory: The measurement tooling needs launch-to-playable timing and startup RAM/VRAM peak capture. The author must then run the cold and warm merge-base versus corrected-head comparison, including Auto and a heavy scene, and retain the source log lines.
  • gpu/vk/vk_fsr4.cpp:703 hardware coverage and fallback: The measured configuration needs a reliable eligibility check, and other configurations need the merge-base behavior preserved without reintroducing its unroller soundness defects. The author must also run the requested RADV, RDNA 4 and Steam Deck coverage.

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

Folds and unrolls more FSR 4 shader passes, including the postpass, and reduces cold pipeline compilation time on the tested Windows system. The expanded path and lower memory threshold also reach configurations that have not yet been tested.

@fix will do (2)

  1. L19 (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory.
  2. L20 (its part an edit can do) gpu/vk/vk_fsr4.cpp:735: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations.

Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)

  • L19 (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 (minor) gpu/vk/vk_fsr4.cpp:735: The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurations beyond the measured Windows card. Complete the requested RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

Since the last review (on 3a7aca49c9)
Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurat…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Checks: they run again on this head (Guide screenshots / Guide images and local UI source review (pull_request) failed on the last one); a failure shows on the pull request.

Also noticed (1; not asked for, not blocking)
  • The checkout is at rebased commit cfd2544f; 7c23d2be is its current base, consistent with the supplied range-diff.
More: does it help, other systems, switches, what was read

Does it help: Yes on the tested RX 6700 XT: the author's three interleaved in-game pairs report median FSR 4 dispatch time falling from 4.542 ms to 3.699 ms. Those measurements predate the corrected head; the requested corrected-head comparison remains open.

Other systems: Linux RADV, Windows RDNA 4 and FSR 4-capable Steam Deck configurations can use the expanded path; cold pacing, cache reuse and visual parity on those configurations remain unverified.

Switches: No switch added, changed or removed. Existing RX_VK_FSR4_TUNE defaults on for AMD GPUs and can disable tuning.

Reviewed: cfd2544fb5 against 7c23d2be26: Re-check focused on the ledger, recorded runs, the vk_fsr4.cpp diff and the headroom and eligibility code at HEAD. Other changed code, tests, generated fixture and repository rules were not read in full during this re-check.; nothing run (a code review).

Checked and fine:

  • The compact threshold remains limited to shaders of at most 60,000 words; larger eligible shaders retain the 8 GiB threshold.
  • The supplied range-diff reports no pull request changes since the ledger head.

Testing: No commands from the project or tests were run. The author reports Windows in-game, shader validation and behavioral test results; CI has not run on this head.

Overlaps and merge order: Earlier review reports conflicts with Longshot #1886 and #1989 in gpu/vk/vk_fsr4.cpp; current overlap was not independently verified.


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 measured Windows configuration shows a substantial FSR 4 GPU-time improvement, but the requested comparison on the corrected head and coverage of other affected configurations remain outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is cfd2544fb55f. I rebased it onto `main` (7c23d2be2613). **Not done this time (still open: the next `@fix` takes it)** - **First-playable-frame timing and peak memory**: The measurement tooling needs launch-to-playable timing and startup RAM/VRAM peak capture. The author must then run the cold and warm merge-base versus corrected-head comparison, including Auto and a heavy scene, and retain the source log lines. - **gpu/vk/vk_fsr4.cpp:703 hardware coverage and fallback**: The measured configuration needs a reliable eligibility check, and other configurations need the merge-base behavior preserved without reintroducing its unroller soundness defects. The author must also run the requested RADV, RDNA 4 and Steam Deck coverage. Nothing was built or run: the checks run again on the new head. Folds and unrolls more FSR 4 shader passes, including the postpass, and reduces cold pipeline compilation time on the tested Windows system. The expanded path and lower memory threshold also reach configurations that have not yet been tested. **`@fix` will do (2)** 1. **L19** (its part an edit can do): Log first-playable-frame time separately from background compilation and cache hits, and capture peak memory. 2. **L20** (its part an edit can do) `gpu/vk/vk_fsr4.cpp:735`: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations. **Before merging, for the author (2)** (a run, a measurement or a decision; it doesn't hold the recommendation) - **L19** (minor): Repeat the in-game comparison on the merge base and corrected head, including Auto and a heavy scene, source log lines, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** (minor) `gpu/vk/vk_fsr4.cpp:735`: The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurations beyond the measured Windows card. Complete the requested RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. **Since the last review** (on 3a7aca49c977) Still open: L19 (Repeat the in-game comparison on the merge base and corrected head, including Auto and a h…); L20 (The compact 1 GiB cold-build threshold and expanded unroller now reach eligible configurat…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) **Checks:** they run again on this head (`Guide screenshots / Guide images and local UI source review (pull_request)` failed on the last one); a failure shows on the pull request. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The checkout is at rebased commit cfd2544f; 7c23d2be is its current base, consistent with the supplied range-diff. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested RX 6700 XT: the author's three interleaved in-game pairs report median FSR 4 dispatch time falling from 4.542 ms to 3.699 ms. Those measurements predate the corrected head; the requested corrected-head comparison remains open. **Other systems:** Linux RADV, Windows RDNA 4 and FSR 4-capable Steam Deck configurations can use the expanded path; cold pacing, cache reuse and visual parity on those configurations remain unverified. **Switches:** No switch added, changed or removed. Existing RX_VK_FSR4_TUNE defaults on for AMD GPUs and can disable tuning. **Reviewed:** cfd2544fb55f against 7c23d2be2613: Re-check focused on the ledger, recorded runs, the vk_fsr4.cpp diff and the headroom and eligibility code at HEAD. Other changed code, tests, generated fixture and repository rules were not read in full during this re-check.; nothing run (a code review). **Checked and fine:** - The compact threshold remains limited to shaders of at most 60,000 words; larger eligible shaders retain the 8 GiB threshold. - The supplied range-diff reports no pull request changes since the ledger head. **Testing:** No commands from the project or tests were run. The author reports Windows in-game, shader validation and behavioral test results; CI has not run on this head. **Overlaps and merge order:** Earlier review reports conflicts with Longshot #1886 and #1989 in gpu/vk/vk_fsr4.cpp; current overlap was not independently verified. </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>
Owner

@fix
@beanstalk

@fix @beanstalk
HumanBean added this to the WIP project 2026-11-21 15:52:22 +00:00
BeanBot force-pushed perf/fsr4-further from cfd2544fb5
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Successful in 2m25s
beanstalk/approval can't be tested as asked: see the farm's comment
to 10b8e9f2e7
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / Website build and checks (pull_request) Successful in 2m51s
beanstalk/approval not approved yet
PR description / Description follows the template (pull_request_target) Successful in 7s
2026-11-21 15:57:00 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The measured RX 6700 XT configuration shows a substantial FSR 4 GPU-time gain, while other configurations retain the previous unroller. The requested startup, memory and hardware runs remain outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 10b8e9f2e7. I rebased it onto main (9dd41326e7). I edited its description to match the change.

Changed in part (the rest is for the author)

  • First playable frame and memory measurements: scripts/devtools/ab.py:89 records peak process working set; :569 records the first playable state and includes FSR cache and build lines in the report. Peak VRAM capture remains to be implemented. The author must run cold and warm comparisons on the merge base and corrected head, including Auto and a heavy scene, and record peak RAM and VRAM. Nothing was run here.
  • Unmeasured FSR 4 configurations, gpu/vk/vk_fsr4.cpp:872: Restored the base unroller and 8 GiB guard for unmeasured configurations, restricted the expanded path to the reported Windows combination, and updated the hook fixture and documentation. The author must arrange RADV, RDNA 4 and Steam Deck runs covering cold pacing, warm cache hits, and parity across odd dimensions and SDR/HDR or context changes.

Left for the author

  • @​beanstalk: The author must request the hardware runs from Beanstalk on the pull request. This checkout has no available Test Farm interface and network access is closed.

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

The change folds and unrolls additional FSR 4 shaders on one measured Windows configuration, reducing GPU time and cold pipeline build time there. It adds a separate legacy unroller and configuration gate to preserve the previous path elsewhere.

Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)

  • L19 (minor): Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source logs, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 (minor) gpu/vk/vk_fsr4.cpp:735: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

Since the last review (on cfd2544fb5)
Still open: L19 (Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source…); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)
New: L26 (The PR description says the expanded unroller and postpass apply generally to eligible con…)

Checks: they run again on this head (Guide screenshots / Guide images and local UI source review (pull_request) failed on the last one); a failure shows on the pull request.

Also noticed (4; not asked for, not blocking)
  • The playable-state timestamp is observed after the bridge reports a presented frame and connects, so it is an estimate rather than an exact first-playable-frame timestamp.
  • The requested Beanstalk submission could not be made: no Test Farm interface is available and network access is closed; the existing PR comment already requests the hardware runs.
  • The pull request already contains a Beanstalk request covering the named hardware; no Test Farm interface is available in this environment.
  • The supplied base diff also includes changes outside the listed FSR 4 files.
More: does it help, other systems, switches, what was read

Does it help: Yes, on the reported Windows RX 6700 XT configuration: three interleaved in-game pairs show median FSR 4 dispatch time falling from 4.542 to 3.699 ms, and cold background builds from 147.0 s for three passes to 3.43 s for seven. Corrected-head Auto and heavy-scene comparisons, startup times and peak memory remain unmeasured.

Other systems: Linux RADV, RDNA 4 and Steam Deck retain the legacy unroller and 8 GiB build threshold, but the requested platform runs have not been reported. Worker lifecycle changes still affect those paths.

Switches: No switch was added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables FSR 4 tuning.

Reviewed: 10b8e9f2e7 against 9dd41326e7: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the ledger-related portions of vk_fsr4.cpp and ab.py, and spirv_unroll_legacy.h. Skimmed the relevant diff and hook tests; the remaining changed code, recorded runs and generated files were not read in full. docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The compact headroom threshold is used only for the expanded path and shaders at or below 60,000 words.
  • The postpass remains ineligible for background unrolling outside the measured configuration.

Testing: No commands from the project or tests were run. The author reports Windows builds, shader validation, parity checks and in-game measurements; Linux coverage and CI on this head are pending.

Overlaps and merge order: Earlier review reports conflicts with #1886 and #1989 in vk_fsr4.cpp; the later merge would need a rebase.


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 measured RX 6700 XT configuration shows a substantial FSR 4 GPU-time gain, while other configurations retain the previous unroller. The requested startup, memory and hardware runs remain outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 10b8e9f2e727. I rebased it onto `main` (9dd41326e710). I edited its description to match the change. **Changed in part (the rest is for the author)** - **First playable frame and memory measurements**: scripts/devtools/ab.py:89 records peak process working set; :569 records the first playable state and includes FSR cache and build lines in the report. Peak VRAM capture remains to be implemented. The author must run cold and warm comparisons on the merge base and corrected head, including Auto and a heavy scene, and record peak RAM and VRAM. Nothing was run here. - **Unmeasured FSR 4 configurations, gpu/vk/vk_fsr4.cpp:872**: Restored the base unroller and 8 GiB guard for unmeasured configurations, restricted the expanded path to the reported Windows combination, and updated the hook fixture and documentation. The author must arrange RADV, RDNA 4 and Steam Deck runs covering cold pacing, warm cache hits, and parity across odd dimensions and SDR/HDR or context changes. **Left for the author** - **@​beanstalk**: The author must request the hardware runs from Beanstalk on the pull request. This checkout has no available Test Farm interface and network access is closed. Nothing was built or run: the checks run again on the new head. The change folds and unrolls additional FSR 4 shaders on one measured Windows configuration, reducing GPU time and cold pipeline build time there. It adds a separate legacy unroller and configuration gate to preserve the previous path elsewhere. **Before merging, for the author (2)** (a run, a measurement or a decision; it doesn't hold the recommendation) - **L19** (minor): Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source logs, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** (minor) `gpu/vk/vk_fsr4.cpp:735`: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. **Since the last review** (on cfd2544fb55f) Still open: L19 (Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source…); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) New: L26 (The PR description says the expanded unroller and postpass apply generally to eligible con…) **Checks:** they run again on this head (`Guide screenshots / Guide images and local UI source review (pull_request)` failed on the last one); a failure shows on the pull request. <details> <summary>Also noticed (4; not asked for, not blocking)</summary> - The playable-state timestamp is observed after the bridge reports a presented frame and connects, so it is an estimate rather than an exact first-playable-frame timestamp. - The requested Beanstalk submission could not be made: no Test Farm interface is available and network access is closed; the existing PR comment already requests the hardware runs. - The pull request already contains a Beanstalk request covering the named hardware; no Test Farm interface is available in this environment. - The supplied base diff also includes changes outside the listed FSR 4 files. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes, on the reported Windows RX 6700 XT configuration: three interleaved in-game pairs show median FSR 4 dispatch time falling from 4.542 to 3.699 ms, and cold background builds from 147.0 s for three passes to 3.43 s for seven. Corrected-head Auto and heavy-scene comparisons, startup times and peak memory remain unmeasured. **Other systems:** Linux RADV, RDNA 4 and Steam Deck retain the legacy unroller and 8 GiB build threshold, but the requested platform runs have not been reported. Worker lifecycle changes still affect those paths. **Switches:** No switch was added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables FSR 4 tuning. **Reviewed:** 10b8e9f2e727 against 9dd41326e710: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the ledger-related portions of vk_fsr4.cpp and ab.py, and spirv_unroll_legacy.h. Skimmed the relevant diff and hook tests; the remaining changed code, recorded runs and generated files were not read in full. docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The compact headroom threshold is used only for the expanded path and shaders at or below 60,000 words. - The postpass remains ineligible for background unrolling outside the measured configuration. **Testing:** No commands from the project or tests were run. The author reports Windows builds, shader validation, parity checks and in-game measurements; Linux coverage and CI on this head are pending. **Overlaps and merge order:** Earlier review reports conflicts with #1886 and #1989 in vk_fsr4.cpp; the later merge would need a rebase. </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>
@ -1036,2 +1118,4 @@
}
logf("vk: AMD FSR 4: upscalers %s; using %u.%u.%u", listed.c_str(), best[0], best[1], best[2]);
#ifdef _WIN32
tune::measured_unroll = dev.props.vendorID == 0x1002 && dev.props.deviceID == 0x73df &&
Member

L26 (minor): The PR description says the expanded unroller and postpass apply generally to eligible configurations, but this gate limits them to one Windows GPU, driver and FSR version. Update the summary, risks and measurement scope to describe the fallback and its eligibility.

**L26** (minor): The PR description says the expanded unroller and postpass apply generally to eligible configurations, but this gate limits them to one Windows GPU, driver and FSR version. Update the summary, risks and measurement scope to describe the fallback and its eligibility.
Author
Member

I built and tested BeanBot's 10b8e9f2, which was pushed without being built.

  • Build: dev.py vk passes on Windows.
  • Checks: of the 20 game-free checks that read the changed files, 15 pass. The other 5 (test_dev_ab, test_dev_packs, test_upscaler_rows, test_pass_barrier, test_recorder_sync) fail on main @ 9dd41326 too.
  • The gate's values match this PC in vulkaninfo (RX 6700 XT, 0x73df, driver 2.0.353, 26.10.1). This head has not been run in the game yet.
  • L26: the description already scopes the summary, risks and measurements to the gated configuration.

The gate leaves two problems, so I have not asked the farm for L20's runs yet:

  1. Those runs can't test the new path. On RADV, RDNA 4 and the Steam Deck the gate picks the old unroller and skips the postpass, so a pass there only shows main's path again.
  2. It is tied to one exact driver. The next Adrenalin release turns the gain off, on this card too.

A switch that is off by default and forces the new path would let the farm test it on those GPUs, and the gate could then widen on that evidence.

I built and tested BeanBot's `10b8e9f2`, which was pushed without being built. - **Build:** `dev.py vk` passes on Windows. - **Checks:** of the 20 game-free checks that read the changed files, 15 pass. The other 5 (`test_dev_ab`, `test_dev_packs`, `test_upscaler_rows`, `test_pass_barrier`, `test_recorder_sync`) fail on `main @ 9dd41326` too. - **The gate's values** match this PC in `vulkaninfo` (RX 6700 XT, `0x73df`, driver 2.0.353, 26.10.1). This head has not been run in the game yet. - **L26:** the description already scopes the summary, risks and measurements to the gated configuration. **The gate leaves two problems, so I have not asked the farm for L20's runs yet:** 1. **Those runs can't test the new path.** On RADV, RDNA 4 and the Steam Deck the gate picks the old unroller and skips the postpass, so a pass there only shows main's path again. 2. **It is tied to one exact driver.** The next Adrenalin release turns the gain off, on this card too. A switch that is off by default and forces the new path would let the farm test it on those GPUs, and the gate could then widen on that evidence.
HumanBean left a comment

Recommendation: Request changes. The unroller work looks careful, and the RX 6700 XT numbers are a real FSR 4 GPU-time cut. But the head (BeanBot's 10b8e9f2, made by @fix) turns all of it on for exactly one card, one driver build and one FSR 4 version. Every other AMD player keeps main's behaviour. That includes the RX 7900 XTX in #1319, so this PR does not change that issue; to be fair, it never claims to (it says "See #744"). A default that is right for one card and wrong by omission for every other one isn't a sensible default. The branch also conflicts with main now, and the head has not run in the game.

I read the code only (nothing built or run). I went through vk_fsr4.cpp closely and spirv_unroll.h's folding and forwarding at spot depth. I did not audit all 1,479 lines of the unroller.

Blocking

  1. The gate is one configuration, not a per-platform default (gpu/vk/vk_fsr4.cpp:1121, load()). measured_unroll needs Windows, vendor 0x1002, device 0x73df, the AMD proprietary driver at driverVersion == 0x800161, the name "AMD Radeon RX 6700 XT", "26.10.1" in the driver info, and FSR 4.1.2. That has three effects:

    • Every other RDNA 2 card (6600, 6800, 6900), all of RDNA 3 and RDNA 4, and RADV get the legacy unroller.
    • The measured card itself drops back silently at its next Adrenalin update.
    • The name check and the driver-string check repeat the device-ID check and the driverVersion check.

    The thing that decides whether the folded SPIR-V is right is the FSR 4 shader set (4.1.2), plus the driver's compile memory. That points to gating on FSR 4's version and on vendor/architecture (RDNA 2 measured: on; RDNA 3, RDNA 4 and RADV: measured on Beanstalk first), with today's path as the fallback for an FSR 4 version nobody has measured. A device-and-driver-build allow-list is not that.

  2. Two unrollers (gpu/vk/spirv_unroll_legacy.h, 277 lines, a copy of main's; vk_fsr4.cpp:40, build_unrolled). This is only acceptable as a short step until Beanstalk numbers widen the gate. Say in the PR which runs retire it, or the copy stays forever.

  3. The branch conflicts with main in gpu/vk/vk_fsr4.cpp. #1886 ("warm FSR 4 pipelines during shader preparation") changed build_unrolled's cache save and create_compute_pipelines. After the rebase:

    • Check that the warm-up also warms the folded passes.
    • Measure the cold-start figures again; #1886 changes when the builds happen.
  4. The head has not run in the game (the author says so in the 16:21 comment). The in-game numbers come from b79edcc7, before the gate existed. One A/B on the 6700 XT at the rebased head is needed: GPU time, the cold build lines, and the cache at 7/7.

Should fix

  1. scripts/devtools/ab.py is a second topic (peak_working_set, the first-playable line, the FSR 4 cache log lines). It's useful, but it belongs in its own PR with its own check.
  2. "Other configurations retain the previous unroller" is not quite true. vk_fsr4.cpp:875 adds !has_plain for every configuration: on a non-measured card, a layer without a plain twin is no longer unrolled. It's a safe change, but say so.
  3. The docs read as if the expanded unroller is the rule. The comments at vk_fsr4.cpp:177 and fsr4_tune.h:14 say "every pass with constant weight tables … unrolled and folded" with no mention of the gate. docs/dev/reference/upscalers.md does say it. Make all three agree with each other and with the code.

#1319: what the reporter's logs show (none of it is touched here)

The forge has three of the reporter's logs:

  • nightly-397, native, no profiling.
  • nightly-402: one run that switched from FSR 3.1 Quality 67% to Off. With RX_VK_PASS_TIMING on, it is the cleanest A/B available.

The FSR 4 capture (2026-11-16_22-06-15.zip) was never uploaded, so the FSR 4 number can't be read from a log yet.

  • The frame waits on the CPU, not the GPU. At Kakariko, about 3,750 draws a frame:
    • GPU time: 8.9 ms a frame with FSR 3.1 at 1440p, 9.1–9.2 ms at native 4K.
    • The render thread (replay): 20.1 ms a frame, of which 18.2 ms are its jobs. The replay's "submit" is 16.3 ms: draw 7.75, descriptors 2.9, commands 2.4, programs 1.3, queue submit 1.4.
    • Dropping to 67% saves only about 1 ms of GPU time that nothing was waiting on.
  • No pass runs at output size when it should run at render size. Every heavy pass in the FSR 3.1 window is 2560x1440. The only 3840x2160 span is a 0.057 ms single draw, the final composite.
  • Why the upscaler costs fps anyway: the replay's CPU time stays the same (16.3 vs 16.1 ms; dispatch +0.17 ms). What grows is the game's own wait for the GPU:
    • nvn: GPU waits in 5 s: 1,866–1,988 ms with FSR 3.1, 1,588–1,592 ms native.
    • Host timeline waits: 8.2–8.7 ms a frame with FSR 3.1, 6.9–7.3 ms native.
    • That is about +1.3 ms a frame. The upscaler runs inside the game's own upscale network (temporal_rejected_network, gpu/vk/vk_draw.cpp:9690, followed by a full_barrier), ahead of the fence the game waits on each frame. Its GPU time lands on the frame time even though the GPU is idle half of it.
    • Result: 49.9 fps with FSR 3.1 against 51.9 native. An FSR 4 network of about 5 ms on RDNA 3 at 1440p→4K would, by the same mechanism, give the reported 51 → 40. The missing FSR 4 log would confirm or refute that.
  • What would help #1319:
    • Anything that cuts the upscaler's own GPU time: this PR on RDNA 3 once it is measured there, or #1989's Lite model (about 2x on RDNA 2).
    • Cutting the replay's CPU time per draw.
    • Lowering the render resolution does not help on this PC.
  • The reporter's profiled numbers are perturbed. With pass timing on, the replay's "slot wait" is 3.2 ms a frame, against 0.1 ms in the unprofiled nightly-397 run. The actual wait, st_wait_ns ("GPU-bound wait"), is 0.1 ms in both. The extra 3 ms is gpu_time_collect and gprof_collect, which run inside begin_recording's PROF(PROF_SLOTWAIT) scope (gpu/vk/vk_replay.cpp:918). Native was about 60 fps unprofiled on 397 and about 52 fps profiled on 402. Read their fps as relative only.
**Recommendation: Request changes.** The unroller work looks careful, and the RX 6700 XT numbers are a real FSR 4 GPU-time cut. But the head (BeanBot's `10b8e9f2`, made by `@fix`) turns all of it on for exactly one card, one driver build and one FSR 4 version. Every other AMD player keeps `main`'s behaviour. That includes the RX 7900 XTX in #1319, so this PR does not change that issue; to be fair, it never claims to (it says "See #744"). A default that is right for one card and wrong by omission for every other one isn't a sensible default. The branch also conflicts with `main` now, and the head has not run in the game. I read the code only (nothing built or run). I went through `vk_fsr4.cpp` closely and `spirv_unroll.h`'s folding and forwarding at spot depth. I did not audit all 1,479 lines of the unroller. ### Blocking 1. **The gate is one configuration, not a per-platform default** (`gpu/vk/vk_fsr4.cpp:1121`, `load()`). `measured_unroll` needs Windows, vendor 0x1002, device 0x73df, the AMD proprietary driver at `driverVersion == 0x800161`, the name "AMD Radeon RX 6700 XT", "26.10.1" in the driver info, and FSR 4.1.2. That has three effects: - Every other RDNA 2 card (6600, 6800, 6900), all of RDNA 3 and RDNA 4, and RADV get the legacy unroller. - The measured card itself drops back silently at its next Adrenalin update. - The name check and the driver-string check repeat the device-ID check and the `driverVersion` check. The thing that decides whether the folded SPIR-V is right is the FSR 4 shader set (4.1.2), plus the driver's compile memory. That points to gating on FSR 4's version and on vendor/architecture (RDNA 2 measured: on; RDNA 3, RDNA 4 and RADV: measured on Beanstalk first), with today's path as the fallback for an FSR 4 version nobody has measured. A device-and-driver-build allow-list is not that. 2. **Two unrollers** (`gpu/vk/spirv_unroll_legacy.h`, 277 lines, a copy of `main`'s; `vk_fsr4.cpp:40`, `build_unrolled`). This is only acceptable as a short step until Beanstalk numbers widen the gate. Say in the PR which runs retire it, or the copy stays forever. 3. **The branch conflicts with `main`** in `gpu/vk/vk_fsr4.cpp`. #1886 ("warm FSR 4 pipelines during shader preparation") changed `build_unrolled`'s cache save and `create_compute_pipelines`. After the rebase: - Check that the warm-up also warms the folded passes. - Measure the cold-start figures again; #1886 changes when the builds happen. 4. **The head has not run in the game** (the author says so in the 16:21 comment). The in-game numbers come from `b79edcc7`, before the gate existed. One A/B on the 6700 XT at the rebased head is needed: GPU time, the cold build lines, and the cache at 7/7. ### Should fix 5. **`scripts/devtools/ab.py` is a second topic** (`peak_working_set`, the first-playable line, the FSR 4 cache log lines). It's useful, but it belongs in its own PR with its own check. 6. **"Other configurations retain the previous unroller" is not quite true.** `vk_fsr4.cpp:875` adds `!has_plain` for every configuration: on a non-measured card, a layer without a plain twin is no longer unrolled. It's a safe change, but say so. 7. **The docs read as if the expanded unroller is the rule.** The comments at `vk_fsr4.cpp:177` and `fsr4_tune.h:14` say "every pass with constant weight tables … unrolled and folded" with no mention of the gate. `docs/dev/reference/upscalers.md` does say it. Make all three agree with each other and with the code. ### #1319: what the reporter's logs show (none of it is touched here) The forge has three of the reporter's logs: - nightly-397, native, no profiling. - nightly-402: one run that switched from FSR 3.1 Quality 67% to Off. With `RX_VK_PASS_TIMING` on, it is the cleanest A/B available. **The FSR 4 capture (`2026-11-16_22-06-15.zip`) was never uploaded**, so the FSR 4 number can't be read from a log yet. - **The frame waits on the CPU, not the GPU.** At Kakariko, about 3,750 draws a frame: - GPU time: 8.9 ms a frame with FSR 3.1 at 1440p, 9.1–9.2 ms at native 4K. - The render thread (replay): 20.1 ms a frame, of which 18.2 ms are its jobs. The replay's "submit" is 16.3 ms: draw 7.75, descriptors 2.9, commands 2.4, programs 1.3, queue submit 1.4. - Dropping to 67% saves only about 1 ms of GPU time that nothing was waiting on. - **No pass runs at output size when it should run at render size.** Every heavy pass in the FSR 3.1 window is 2560x1440. The only 3840x2160 span is a 0.057 ms single draw, the final composite. - **Why the upscaler costs fps anyway:** the replay's CPU time stays the same (16.3 vs 16.1 ms; dispatch +0.17 ms). What grows is the game's own wait for the GPU: - `nvn: GPU waits in 5 s`: 1,866–1,988 ms with FSR 3.1, 1,588–1,592 ms native. - Host timeline waits: 8.2–8.7 ms a frame with FSR 3.1, 6.9–7.3 ms native. - That is about +1.3 ms a frame. The upscaler runs inside the game's own upscale network (`temporal_rejected_network`, `gpu/vk/vk_draw.cpp:9690`, followed by a `full_barrier`), ahead of the fence the game waits on each frame. Its GPU time lands on the frame time even though the GPU is idle half of it. - Result: 49.9 fps with FSR 3.1 against 51.9 native. An FSR 4 network of about 5 ms on RDNA 3 at 1440p→4K would, by the same mechanism, give the reported 51 → 40. The missing FSR 4 log would confirm or refute that. - **What would help #1319:** - Anything that cuts the upscaler's own GPU time: this PR on RDNA 3 once it is measured there, or #1989's Lite model (about 2x on RDNA 2). - Cutting the replay's CPU time per draw. - Lowering the render resolution does not help on this PC. - **The reporter's profiled numbers are perturbed.** With pass timing on, the replay's "slot wait" is 3.2 ms a frame, against 0.1 ms in the unprofiled nightly-397 run. The actual wait, `st_wait_ns` ("GPU-bound wait"), is 0.1 ms in both. The extra 3 ms is `gpu_time_collect` and `gprof_collect`, which run inside `begin_recording`'s `PROF(PROF_SLOTWAIT)` scope (`gpu/vk/vk_replay.cpp:918`). Native was about 60 fps unprofiled on 397 and about 52 fps profiled on 402. Read their fps as relative only.
@ -37,6 +37,7 @@
#include "fsr4_tune.h"
#include "spirv_unroll.h"
#include "spirv_unroll_legacy.h"
Owner

spirv_unroll_legacy.h is a 277-line copy of main's unroller kept next to the new one. That's fine as a short step, but please name in the description which Beanstalk runs widen the gate and let this copy be deleted. Otherwise both unrollers stay forever.

`spirv_unroll_legacy.h` is a 277-line copy of main's unroller kept next to the new one. That's fine as a short step, but please name in the description which Beanstalk runs widen the gate and let this copy be deleted. Otherwise both unrollers stay forever.
@ -181,0 +174,4 @@
/// AMD's passes tuned as the library makes them (fsr4_tune.h: measured gains on Adrenalin 26.10.1): the device functions it
/// is handed are ours where it makes and destroys buffers, layouts, shader modules and compute pipelines, writes descriptors
/// and records binds and dispatches. At once: the network's layers 64 lanes wide, and the weights the layers and the postpass
/// copy into per-thread arrays (scratch memory) read from a tail of the library's storage buffer instead. Later: every pass
Owner

This comment (like fsr4_tune.h:14) says every pass with weight tables is unrolled and folded, and gives the RX 6700 XT figures, without saying that this happens only on the gated configuration. docs/dev/reference/upscalers.md does say it; please make all three agree with the code.

This comment (like `fsr4_tune.h:14`) says every pass with weight tables is unrolled and folded, and gives the RX 6700 XT figures, without saying that this happens only on the gated configuration. `docs/dev/reference/upscalers.md` does say it; please make all three agree with the code.
@ -811,0 +872,4 @@
// folded, its weights become immediate constants and its local scratch arrays disappear. Passes without tables gain
// nothing: pass 3, 0.07 ms either way. Only one whose creation carried nothing else: no specialization, no other
// structures beyond a lane count)
if (!(kind[i] & 2) || (!measured_unroll && !(kind[i] & 1)) || !has_plain || closing || ci[i].stage.pSpecializationInfo || lanes[i].pNext || ci[i].pNext) continue;
Owner

!has_plain applies to every configuration, not only the measured one: on any other AMD card, a layer whose plain twin failed is no longer unrolled. That's a safe change, but the description says other configurations keep the previous behaviour, so please mention it there.

`!has_plain` applies to every configuration, not only the measured one: on any other AMD card, a layer whose plain twin failed is no longer unrolled. That's a safe change, but the description says other configurations keep the previous behaviour, so please mention it there.
@ -1036,2 +1118,4 @@
}
logf("vk: AMD FSR 4: upscalers %s; using %u.%u.%u", listed.c_str(), best[0], best[1], best[2]);
#ifdef _WIN32
tune::measured_unroll = dev.props.vendorID == 0x1002 && dev.props.deviceID == 0x73df &&
Owner

This gate matches one card, one driver build and one FSR 4 version: device 0x73df, driverVersion 0x800161, the name string and "26.10.1" (the last two only repeat the first two). Every other RDNA 2 card, all of RDNA 3 and RDNA 4 (the #1319 card included) and RADV get the legacy path. The measured card also drops back at its next Adrenalin update. Gate on what decides correctness and cost instead: FSR 4's version (the shader set the folding was checked against) and vendor/architecture, from measurements. RDNA 2 is measured, so on; RDNA 3, RDNA 4 and RADV go to Beanstalk; today's path stays the fallback for an FSR 4 version nobody has measured.

This gate matches one card, one driver build and one FSR 4 version: device 0x73df, `driverVersion 0x800161`, the name string and "26.10.1" (the last two only repeat the first two). Every other RDNA 2 card, all of RDNA 3 and RDNA 4 (the #1319 card included) and RADV get the legacy path. The measured card also drops back at its next Adrenalin update. Gate on what decides correctness and cost instead: FSR 4's version (the shader set the folding was checked against) and vendor/architecture, from measurements. RDNA 2 is measured, so on; RDNA 3, RDNA 4 and RADV go to Beanstalk; today's path stays the fallback for an FSR 4 version nobody has measured.
@ -85,6 +86,41 @@ def say(text):
common.say(WHO, text)
def peak_working_set(pid):
Owner

peak_working_set, the first-playable line and the FSR 4 cache log lines are useful, but they're a second topic in an FSR 4 shader PR. Please move them to their own PR, with a check under tests/ for the new log lines.

`peak_working_set`, the first-playable line and the FSR 4 cache log lines are useful, but they're a second topic in an FSR 4 shader PR. Please move them to their own PR, with a check under tests/ for the new log lines.
madebyjordan force-pushed perf/fsr4-further from 10b8e9f2e7
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / Website build and checks (pull_request) Successful in 2m51s
beanstalk/approval not approved yet
PR description / Description follows the template (pull_request_target) Successful in 7s
to b97a4c7984
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
CI / Website build and checks (pull_request) Failing after 29s
beanstalk/approval not approved yet
PR description / Description follows the template (pull_request_target) Successful in 5s
2026-11-22 08:43:59 +00:00
Compare
Author
Member

Addressed Review #2249 (plus a full audit of spirv_unroll.h and rebase onto main @ a2dc53859), pushed as b97a4c798:

Review #2249 items addressed

  1. Gate by FSR 4 version and compiler, not one card/driver (gpu/vk/vk_fsr4.cpp, gpu/vk/device_policy.h):
    • Replaced measured_unroll (the single-GPU/single-driver allow-list) with tune::expanded_unroll = best[0] == 4 && best[1] == 1 && best[2] == 2; so FSR 4.1.2 uses the expanded unroller and postpass on every AMD GPU (allowing Beanstalk to actually test RDNA 3, RDNA 4, RADV, and Steam Deck), while any other FSR 4 version retains spirv_unroll_legacy.h for wave64 layers only.
    • Added DevicePolicy::fsr4_compact_builds (f.windows && f.driver_id == VK_DRIVER_ID_AMD_PROPRIETARY && f.driver_info && std::strstr(f.driver_info, "proprietary shader compiler"), matching nan_bits) so the 1 GiB compact-build headroom applies on AMD's older Windows shader compiler (RDNA 1 & 2, where compile memory was measured) while every other compiler keeps 8 GiB until measured. Fixed the startup log line to print 8 GiB whenever expanded_unroll is false.
  2. Retirement plan for spirv_unroll_legacy.h: Documented in the PR description — once Beanstalk verifies FSR 4.1.2 on Linux RADV, Windows RDNA 3, Windows RDNA 4, and FSR 4-capable Steam Deck (and once a future FSR 4.x shader set is checked against spirv_unroll.h), spirv_unroll_legacy.h and the expanded_unroll branch can be removed.
  3. Rebased onto current main @ a2dc53859: Resolved conflicts cleanly with #1886 (fsr4_prepare_shaders warm-up), #1989 (FSR 4 model selection plumbing, tune::suppressed pass-through, prepare_device()), #2140 (fsr4_prepare_shaders model forwarding), #2148 (bc_small_runs), #2169, and #2171.
  4. Dropped unrelated scripts/devtools/ab.py changes: Removed from this PR (second topic).
  5. Documented !has_plain and aligned all comments/docs: Updated gpu/vk/vk_fsr4.cpp, gpu/vk/fsr4_tune.h, docs/dev/reference/upscalers.md, and the PR description so all four agree on the FSR 4.1.2 / fsr4_compact_builds gate and note that a layer without a plain twin is left rolled on every configuration.

Additional soundness fixes from auditing gpu/vk/spirv_unroll.h

  • hoist_const_var_stores: Scans past OpLine/OpNoLine to find the last Function OpVariable in the entry block before inserting hoisted OpStores (fixes invalid OpStore before OpVariable when debug line info appears between variables; regression R4_hoist_var_with_opline).
  • forward_function_allocas: Guards constant load forwarding and apply_aliases with safe_access_chain_const so negative or out-of-bounds constants stored into local variables are never forward-substituted into OpAccessChain (regression R5_forward_neg_access_chain).
  • find_non_escaping_fvars: Treats 4-word 0-index OpAccessChain as escaping so aliased Function variables are not dropped or mis-forwarded (regression R6_zero_index_access_chain).
  • TypeInfo::scan & apply_aliases/fold_constants: Also tracks and preserves OpGroupDecorate, OpDecorateId, and OpDecorateString.
  • unroll_one: Guards degenerate B == M loops, makes non-retargeted selection-continue rejection CFG-order-independent, and refuses if a live-out phi exit_alias would substitute a negative/OOB constant into an outside OpAccessChain.
  • tests/test_fsr4_tune.py & tests/test_fsr4_bind_dispatch.py: Fixed OpNoLine opcode in the test VM (317, was 9), added R4–R6, and added suppressed pass-through and build_want coverage.

Verification on b97a4c798

  • LONGSHOT_FSR=1 python -I scripts/dev.py vk built cleanly on Windows llvm-mingw (0 errors, symbols checked) on both b97a4c798 and baseline main @ a2dc53859.
  • All FSR 4, device policy, barrier, recorder sync, doc anchor, UTF-8 path, and third-party checks pass (clang++ and g++ where C++ is compiled).
  • Re-running the in-game --prepare-shaders warm-up and RX 6700 XT A/B on b97a4c798 vs main @ a2dc53859 is next once the local nightly-745-a2dc5385 build finishes.
Addressed Review #2249 (plus a full audit of `spirv_unroll.h` and rebase onto `main @ a2dc53859`), pushed as `b97a4c798`: ### Review #2249 items addressed 1. **Gate by FSR 4 version and compiler, not one card/driver (`gpu/vk/vk_fsr4.cpp`, `gpu/vk/device_policy.h`):** - Replaced `measured_unroll` (the single-GPU/single-driver allow-list) with `tune::expanded_unroll = best[0] == 4 && best[1] == 1 && best[2] == 2;` so FSR 4.1.2 uses the expanded unroller and postpass on every AMD GPU (allowing Beanstalk to actually test RDNA 3, RDNA 4, RADV, and Steam Deck), while any other FSR 4 version retains `spirv_unroll_legacy.h` for wave64 layers only. - Added `DevicePolicy::fsr4_compact_builds` (`f.windows && f.driver_id == VK_DRIVER_ID_AMD_PROPRIETARY && f.driver_info && std::strstr(f.driver_info, "proprietary shader compiler")`, matching `nan_bits`) so the `1 GiB` compact-build headroom applies on AMD's older Windows shader compiler (RDNA 1 & 2, where compile memory was measured) while every other compiler keeps `8 GiB` until measured. Fixed the startup log line to print `8 GiB` whenever `expanded_unroll` is false. 2. **Retirement plan for `spirv_unroll_legacy.h`:** Documented in the PR description — once Beanstalk verifies FSR 4.1.2 on Linux RADV, Windows RDNA 3, Windows RDNA 4, and FSR 4-capable Steam Deck (and once a future FSR 4.x shader set is checked against `spirv_unroll.h`), `spirv_unroll_legacy.h` and the `expanded_unroll` branch can be removed. 3. **Rebased onto current `main @ a2dc53859`:** Resolved conflicts cleanly with `#1886` (`fsr4_prepare_shaders` warm-up), `#1989` (FSR 4 model selection plumbing, `tune::suppressed` pass-through, `prepare_device()`), `#2140` (`fsr4_prepare_shaders` model forwarding), `#2148` (`bc_small_runs`), `#2169`, and `#2171`. 4. **Dropped unrelated `scripts/devtools/ab.py` changes:** Removed from this PR (second topic). 5. **Documented `!has_plain` and aligned all comments/docs:** Updated `gpu/vk/vk_fsr4.cpp`, `gpu/vk/fsr4_tune.h`, `docs/dev/reference/upscalers.md`, and the PR description so all four agree on the FSR 4.1.2 / `fsr4_compact_builds` gate and note that a layer without a plain twin is left rolled on every configuration. ### Additional soundness fixes from auditing `gpu/vk/spirv_unroll.h` - **`hoist_const_var_stores`:** Scans past `OpLine`/`OpNoLine` to find the last Function `OpVariable` in the entry block before inserting hoisted `OpStore`s (fixes invalid `OpStore` before `OpVariable` when debug line info appears between variables; regression `R4_hoist_var_with_opline`). - **`forward_function_allocas`:** Guards constant load forwarding and `apply_aliases` with `safe_access_chain_const` so negative or out-of-bounds constants stored into local variables are never forward-substituted into `OpAccessChain` (regression `R5_forward_neg_access_chain`). - **`find_non_escaping_fvars`:** Treats 4-word 0-index `OpAccessChain` as escaping so aliased Function variables are not dropped or mis-forwarded (regression `R6_zero_index_access_chain`). - **`TypeInfo::scan` & `apply_aliases`/`fold_constants`:** Also tracks and preserves `OpGroupDecorate`, `OpDecorateId`, and `OpDecorateString`. - **`unroll_one`:** Guards degenerate `B == M` loops, makes non-retargeted selection-continue rejection CFG-order-independent, and refuses if a live-out phi `exit_alias` would substitute a negative/OOB constant into an outside `OpAccessChain`. - **`tests/test_fsr4_tune.py` & `tests/test_fsr4_bind_dispatch.py`:** Fixed `OpNoLine` opcode in the test VM (`317`, was `9`), added `R4`–`R6`, and added `suppressed` pass-through and `build_want` coverage. ### Verification on `b97a4c798` - `LONGSHOT_FSR=1 python -I scripts/dev.py vk` built cleanly on Windows llvm-mingw (`0` errors, symbols checked) on both `b97a4c798` and baseline `main @ a2dc53859`. - All FSR 4, device policy, barrier, recorder sync, doc anchor, UTF-8 path, and third-party checks pass (`clang++` and `g++` where C++ is compiled). - Re-running the in-game `--prepare-shaders` warm-up and RX 6700 XT A/B on `b97a4c798` vs `main @ a2dc53859` is next once the local `nightly-745-a2dc5385` build finishes.
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The earlier RX 6700 XT measurements show a substantial FSR 4 GPU-time gain, but the rebased head has not been measured in game. The requested startup, memory and other-platform runs are also still missing. Recommend approval; not approved on the forge.

The change folds and unrolls eligible FSR 4.1.2 shaders to reduce GPU time and cold pipeline compilation cost. It adds a substantial SPIR-V transformation and retains a second unroller for other FSR versions, with a documented retirement plan.

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

  • L19: Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source logs, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 gpu/vk/vk_fsr4.cpp:735: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

Since the last review (on 10b8e9f2e7)
Still open: L19 (Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source…); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Checks: Failing on this head, which is behind its base, where they pass: Guide screenshots / Guide images and local UI source review (pull_request), CI / Website build and checks (pull_request). @rebase (or @fix) brings it up to date and runs them again; not held against it.

Also noticed (1; not asked for, not blocking)
  • The rebased head's RX 6700 XT warm-up, cache and interleaved in-game comparison remain listed for testing.
More: does it help, other systems, switches, what was read

Does it help: Unproven on this head. On the earlier head, three interleaved RX 6700 XT runs reported median FSR 4 GPU time falling from 4.542 ms to 3.699 ms and cold builds from 147.0 s for three passes to 3.43 s for seven; the rebase changed warm-up and has not been re-measured.

Other systems: FSR 4.1.2 enables the expanded path across AMD GPUs. Linux RADV, Windows RDNA 3 and 4, and an FSR 4-capable Steam Deck remain untested; other FSR versions use the legacy unroller. The 1 GiB compact-build threshold is limited to the older AMD Windows compiler, with 8 GiB elsewhere.

Switches: No switch added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning; the new FSR-version and compiler policies select the default path automatically, pending the requested hardware measurements.

Reviewed: b97a4c7984 against a2dc538590: Read AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the commit summary, changed policy and pipeline paths, and portions of the changed unroller. The large unroller, remaining changed code and tests were not read in full; the supplied runs and binary fixture were not independently verified.; nothing run (a code review).

Checked and fine:

  • FSR 4 versions other than 4.1.2 retain the legacy unroller.
  • The compact memory threshold requires both the expanded path and the older AMD Windows compiler policy.
  • Passes without a plain fallback twin are excluded from unrolling.

Testing: No commands from the project were run. The author reports Windows builds and targeted checks passing, plus earlier in-game RX 6700 XT measurements; Linux and the listed hardware runs remain pending.

Overlaps and merge order: The description reports integration with merged warm-up and model-selection changes; no current overlapping pull request was established.


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

**Recommendation: Approve.** The code is ready: only testing is left. The earlier RX 6700 XT measurements show a substantial FSR 4 GPU-time gain, but the rebased head has not been measured in game. The requested startup, memory and other-platform runs are also still missing. Recommend approval; not approved on the forge. The change folds and unrolls eligible FSR 4.1.2 shaders to reduce GPU time and cold pipeline compilation cost. It adds a substantial SPIR-V transformation and retains a second unroller for other FSR versions, with a documented retirement plan. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L19**: Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source logs, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** `gpu/vk/vk_fsr4.cpp:735`: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. **Since the last review** (on 10b8e9f2e727) Still open: L19 (Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source…); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) **Checks:** Failing on this head, which is behind its base, where they pass: `Guide screenshots / Guide images and local UI source review (pull_request)`, `CI / Website build and checks (pull_request)`. `@rebase` (or `@fix`) brings it up to date and runs them again; not held against it. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The rebased head's RX 6700 XT warm-up, cache and interleaved in-game comparison remain listed for testing. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on this head. On the earlier head, three interleaved RX 6700 XT runs reported median FSR 4 GPU time falling from 4.542 ms to 3.699 ms and cold builds from 147.0 s for three passes to 3.43 s for seven; the rebase changed warm-up and has not been re-measured. **Other systems:** FSR 4.1.2 enables the expanded path across AMD GPUs. Linux RADV, Windows RDNA 3 and 4, and an FSR 4-capable Steam Deck remain untested; other FSR versions use the legacy unroller. The 1 GiB compact-build threshold is limited to the older AMD Windows compiler, with 8 GiB elsewhere. **Switches:** No switch added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning; the new FSR-version and compiler policies select the default path automatically, pending the requested hardware measurements. **Reviewed:** b97a4c79846e against a2dc53859018: Read AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the commit summary, changed policy and pipeline paths, and portions of the changed unroller. The large unroller, remaining changed code and tests were not read in full; the supplied runs and binary fixture were not independently verified.; nothing run (a code review). **Checked and fine:** - FSR 4 versions other than 4.1.2 retain the legacy unroller. - The compact memory threshold requires both the expanded path and the older AMD Windows compiler policy. - Passes without a plain fallback twin are excluded from unrolling. **Testing:** No commands from the project were run. The author reports Windows builds and targeted checks passing, plus earlier in-game RX 6700 XT measurements; Linux and the listed hardware runs remain pending. **Overlaps and merge order:** The description reports integration with merged warm-up and model-selection changes; no current overlapping pull request was established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
madebyjordan force-pushed perf/fsr4-further from b97a4c7984
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
CI / Website build and checks (pull_request) Failing after 29s
beanstalk/approval not approved yet
PR description / Description follows the template (pull_request_target) Successful in 5s
to 2d4d155042
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
beanstalk/approval not approved yet
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
PR description / Description follows the template (pull_request_target) Successful in 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / Website build and checks (pull_request) Successful in 3m36s
2026-11-22 19:53:51 +00:00
Compare
Author
Member

Rebased onto main @ 753fb5af6 (2d4d15504), resolving the tests/test_device_policy.py conflict with #2228 (bc_small_runs / bc_copy_per_layer alongside fsr4_compact_builds on AMD Windows).

  • Re-verified scripts/dev.py vk (longshot_vk.dll, llvm-mingw) and game-free checks on both clang++ and g++: test_device_policy.py, test_fsr4_tune.py (with spirv-val), test_fsr4_bind_dispatch.py, and test_doc_anchors.py.
Rebased onto `main @ 753fb5af6` (`2d4d15504`), resolving the `tests/test_device_policy.py` conflict with #2228 (`bc_small_runs` / `bc_copy_per_layer` alongside `fsr4_compact_builds` on AMD Windows). - Re-verified `scripts/dev.py vk` (`longshot_vk.dll`, `llvm-mingw`) and game-free checks on both `clang++` and `g++`: `test_device_policy.py`, `test_fsr4_tune.py` (with `spirv-val`), `test_fsr4_bind_dispatch.py`, and `test_doc_anchors.py`.
Author
Member
@review
BeanBot requested changes 2026-11-22 20:53:02 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The earlier RX 6700 XT measurement showed a substantial GPU-time improvement, but the requested comparison and hardware coverage remain outstanding. The guide screenshots check also fails on this head. (It stands on L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.)

FSR 4.1.2 shaders are folded and unrolled more broadly, including the postpass, to reduce GPU time and pipeline build cost. The change adds a substantial SPIR-V transformation and keeps a second unroller as a temporary fallback.

Blocking (1): must change before merging.

  1. L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.

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

  • L19: Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source logs, cold and warm time to first playable frame, and peak RAM and VRAM.
  • L20 gpu/vk/vk_fsr4.cpp:735: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

@fix can do L22.

Since the last review (on b97a4c7984)
Still open: L19 (Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source…); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Also noticed (1; not asked for, not blocking)
  • The reported Windows build and targeted checks cover the rebased head, but the in-game measurements precede the rebase.
More: does it help, other systems, switches, what was read

Does it help: Unproven on the current head: an earlier RX 6700 XT comparison reported 4.542 to 3.699 ms FSR dispatch time and 147.0 to 3.43 s cold builds, but the rebased head has not been measured in game against its merge base.

Other systems: FSR 4.1.2 selects the expanded path on AMD configurations including RADV, RDNA 4 and Steam Deck; their requested cold pacing, cache and visual parity runs remain missing. Other FSR versions retain the legacy unroller, and unmeasured compilers retain 8 GiB build headroom.

Switches: No switches added, changed or removed. Existing RX_VK_FSR4_TUNE=0 disables tuning.

Reviewed: 2d4d155042 against 753fb5af68: Read AGENTS.md and CONTRIBUTING.md, the supplied reviews, comments, CI and ledger, both versions of the device-policy test diff, and the current policy and unroller-selection references. The remaining changed code and tests were not read in full for this re-check; the generated SPIR-V fixture was not inspected.; nothing run (a code review).

Checked and fine:

  • The rebase preserves the FSR compact-build expectations alongside the base branch's BC policy expectations.
  • The expanded unroller remains gated on FSR 4.1.2, and compact headroom remains gated by the device policy.

Testing: No commands that build or run tests were executed. The author reports Windows builds and targeted checks passing on the head; the supplied CI reports a guide screenshots failure.

Overlaps and merge order: No unresolved overlap identified in the supplied information; the reported warm-up and model-selection changes have been rebased into the branch.


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

**Recommendation: Request changes.** The earlier RX 6700 XT measurement showed a substantial GPU-time improvement, but the requested comparison and hardware coverage remain outstanding. The guide screenshots check also fails on this head. (It stands on L22: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s.) FSR 4.1.2 shaders are folded and unrolled more broadly, including the postpass, to reduce GPU time and pipeline build cost. The change adds a substantial SPIR-V transformation and keeps a second unroller as a temporary fallback. **Blocking (1)**: must change before merging. 1. **L22**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L19**: Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source logs, cold and warm time to first playable frame, and peak RAM and VRAM. - **L20** `gpu/vk/vk_fsr4.cpp:735`: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. `@fix` can do L22. **Since the last review** (on b97a4c79846e) Still open: L19 (Repeat the merge-base versus corrected-head comparison with Auto and a heavy scene, source…); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The reported Windows build and targeted checks cover the rebased head, but the in-game measurements precede the rebase. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the current head: an earlier RX 6700 XT comparison reported 4.542 to 3.699 ms FSR dispatch time and 147.0 to 3.43 s cold builds, but the rebased head has not been measured in game against its merge base. **Other systems:** FSR 4.1.2 selects the expanded path on AMD configurations including RADV, RDNA 4 and Steam Deck; their requested cold pacing, cache and visual parity runs remain missing. Other FSR versions retain the legacy unroller, and unmeasured compilers retain 8 GiB build headroom. **Switches:** No switches added, changed or removed. Existing RX_VK_FSR4_TUNE=0 disables tuning. **Reviewed:** 2d4d155042bc against 753fb5af6860: Read AGENTS.md and CONTRIBUTING.md, the supplied reviews, comments, CI and ledger, both versions of the device-policy test diff, and the current policy and unroller-selection references. The remaining changed code and tests were not read in full for this re-check; the generated SPIR-V fixture was not inspected.; nothing run (a code review). **Checked and fine:** - The rebase preserves the FSR compact-build expectations alongside the base branch's BC policy expectations. - The expanded unroller remains gated on FSR 4.1.2, and compact headroom remains gated by the device policy. **Testing:** No commands that build or run tests were executed. The author reports Windows builds and targeted checks passing on the head; the supplied CI reports a guide screenshots failure. **Overlaps and merge order:** No unresolved overlap identified in the supplied information; the reported warm-up and model-selection changes have been rebased into the branch. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
madebyjordan force-pushed perf/fsr4-further from 2d4d155042
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
beanstalk/approval not approved yet
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
PR description / Description follows the template (pull_request_target) Successful in 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / Website build and checks (pull_request) Successful in 3m36s
to 64318392b3
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
CI / Website build and checks (pull_request) Successful in 4m7s
beanstalk/approval can't be tested as asked: see the farm's comment
PR description / Description follows the template (pull_request_target) Successful in 4s
2026-11-23 07:57:37 +00:00
Compare
Author
Member

Rebased onto main @ 0e32bc100, run in the game at this head, and four unroller guards added from a cold read. The new head is 64318392b; the description has the numbers.

What changed

  • Rebase: the one conflict was tests/test_device_policy.py with #2232 (threaded_auto_recorder beside fsr4_compact_builds on one AMD Windows row); both kept. The PR merges into main again.
  • 64318392b, four guards in gpu/vk/spirv_unroll.h, each with a synthetic case in tests/test_fsr4_tune.py that fails on 09345da7f and passes here. None is reachable with FSR 4.1.2's shaders: the seven folded passes keep their word counts and the cache file its size.
    • R7: a header phi fed by the loop's own test was cloned with the test's id, which no copy defines (spirv-val: ID '36' has not been defined).
    • R8: the counter became a constant index in every body copy with no bounds check, so if (i < 2) x = arr[i]; over four trips left arr[2] and arr[3] in the copies.
    • R10: a loop refused after its constants were made gave their ids back but left them in the constant table; the next loop was handed an id nothing defines.
    • R9: DCE removed a constant composite that no instruction reads though it is decorated (BuiltIn WorkgroupSize).
    • The worker_fn comment said device_proc writes the real_* pointers; it never does.
  • The same cold read found nothing in vk_fsr4.cpp's threads, tokens, cleanup or lock order, and spirv_unroll_legacy.h is main's spirv_unroll.h apart from its two namespace lines.

In the game, on this head (Windows 11, RX 6700 XT, Adrenalin 26.10.1, FSR 4.1.2)

main @ 0e32bc10 this PR @ 64318392
fsr4 ffxDispatch GPU time, three interleaved 60 s pairs 3.851 / 3.854 / 3.867 ms 3.336 / 3.334 / 3.340 ms (-13.4 %)
fps 73.7 / 74.7 / 73.3 73.5 / 76.4 / 75.4 (runs overlap)
Cold --prepare-shaders: passes unrolled, their builds 3, 131.4 s 7, 3.27 s
the same: peak commit 4,351 MB 1,429 MB
Later starts 3 of 3 from the caches 7 of 7 from the caches

One cost the earlier numbers did not show: the unroller itself runs again at every start before the cache is asked, 0.14 to 0.56 s a pass, 2.2 s for the seven on a background thread (main: 0.1 s a pass, three passes). It is in Risks. Keeping the folded SPIR-V beside the pipeline cache would remove it; that is a follow-up, not this PR.

HumanBean's review of 10b8e9f2

  1. The gate: by FSR 4 version and compiler since b97a4c798 (expanded_unroll on 4.1.2 for every AMD GPU, fsr4_compact_builds for the 1 GiB limit on the older Windows compiler only). The log on this PC: passes unrolled by the expanded unroller; a compact build wants 1 GiB of memory to spare.
  2. Two unrollers: the description names the runs that retire spirv_unroll_legacy.h.
  3. The conflict and #1886: rebased; the warm-up does warm the folded passes (SDR pipeline preparation finished (7 optimized layers ready)), and the cold figures are measured again through it.
  4. The head in the game: done, above.
  5. ab.py: out of the PR since b97a4c798.
  6. and 7. !has_plain and the comments: in the description, vk_fsr4.cpp, fsr4_tune.h and upscalers.md since b97a4c798.

BeanBot's review of 2d4d1550

  • L22 is not this PR's. The Guide screenshots check does not pass on the base: it fails on main at 0443e4be1, 964599d20, e171f9db2, 753fb5af6 and 0e32bc100. scripts/check_guide_screenshots.py --review-sources names gpu/vk/device_policy.h and gpu/vk/vk_api.h for settings-graphics.png, both changed on main after the revision #2255 reviewed, a2dc5385 (#2228, #2232, #2275). This head reports the same two files. This PR's own change to device_policy.h is one policy field with no menu row. I have not touched the manifest here: reviewing #2232's and #2275's changes against the picture is a second topic, and whoever refreshes it on main would conflict with it. Once main's manifest is refreshed, this PR needs device_policy.h's hash recorded once more.
  • L19: the percentiles are in the table now. Time to the first playable frame and peak VRAM need new instrumentation, which is its own PR (as ab.py was); the preparation's peak commit is given instead.
  • L20: stands, as Still to test. The gate now lets the farm reach the new path on RADV, RDNA 3, RDNA 4 and the Steam Deck.

For the hardware runs

On another AMD GPU, FSR 4.1.2 may hand over a different shader set from the RX 6700 XT's (fsr4_model_v07_fp8_no_scale_*). The unroller refuses what it does not understand, but nothing validates its output at run time, so those runs should read the AMD FSR 4: lines and compare the picture with main, not only the timings.

Overlap

#2331 also changes gpu/vk/vk_fsr4.cpp; whichever merges second rebases.

Rebased onto `main @ 0e32bc100`, run in the game at this head, and four unroller guards added from a cold read. The new head is `64318392b`; the description has the numbers. ### What changed - **Rebase:** the one conflict was `tests/test_device_policy.py` with #2232 (`threaded_auto_recorder` beside `fsr4_compact_builds` on one AMD Windows row); both kept. The PR merges into `main` again. - **`64318392b`, four guards in `gpu/vk/spirv_unroll.h`**, each with a synthetic case in `tests/test_fsr4_tune.py` that fails on `09345da7f` and passes here. None is reachable with FSR 4.1.2's shaders: the seven folded passes keep their word counts and the cache file its size. - `R7`: a header phi fed by the loop's own test was cloned with the test's id, which no copy defines (spirv-val: `ID '36' has not been defined`). - `R8`: the counter became a constant index in every body copy with no bounds check, so `if (i < 2) x = arr[i];` over four trips left `arr[2]` and `arr[3]` in the copies. - `R10`: a loop refused after its constants were made gave their ids back but left them in the constant table; the next loop was handed an id nothing defines. - `R9`: DCE removed a constant composite that no instruction reads though it is decorated (`BuiltIn WorkgroupSize`). - The `worker_fn` comment said `device_proc` writes the `real_*` pointers; it never does. - The same cold read found nothing in `vk_fsr4.cpp`'s threads, tokens, cleanup or lock order, and `spirv_unroll_legacy.h` is `main`'s `spirv_unroll.h` apart from its two namespace lines. ### In the game, on this head (Windows 11, RX 6700 XT, Adrenalin 26.10.1, FSR 4.1.2) | | main @ 0e32bc10 | this PR @ 64318392 | |---|---|---| | `fsr4 ffxDispatch` GPU time, three interleaved 60 s pairs | 3.851 / 3.854 / 3.867 ms | 3.336 / 3.334 / 3.340 ms (-13.4 %) | | fps | 73.7 / 74.7 / 73.3 | 73.5 / 76.4 / 75.4 (runs overlap) | | Cold `--prepare-shaders`: passes unrolled, their builds | 3, 131.4 s | 7, 3.27 s | | the same: peak commit | 4,351 MB | 1,429 MB | | Later starts | 3 of 3 from the caches | 7 of 7 from the caches | One cost the earlier numbers did not show: the unroller itself runs again at every start before the cache is asked, 0.14 to 0.56 s a pass, 2.2 s for the seven on a background thread (`main`: 0.1 s a pass, three passes). It is in Risks. Keeping the folded SPIR-V beside the pipeline cache would remove it; that is a follow-up, not this PR. ### HumanBean's review of `10b8e9f2` 1. **The gate:** by FSR 4 version and compiler since `b97a4c798` (`expanded_unroll` on 4.1.2 for every AMD GPU, `fsr4_compact_builds` for the 1 GiB limit on the older Windows compiler only). The log on this PC: `passes unrolled by the expanded unroller; a compact build wants 1 GiB of memory to spare`. 2. **Two unrollers:** the description names the runs that retire `spirv_unroll_legacy.h`. 3. **The conflict and #1886:** rebased; the warm-up does warm the folded passes (`SDR pipeline preparation finished (7 optimized layers ready)`), and the cold figures are measured again through it. 4. **The head in the game:** done, above. 5. **`ab.py`:** out of the PR since `b97a4c798`. 6. and 7. **`!has_plain` and the comments:** in the description, `vk_fsr4.cpp`, `fsr4_tune.h` and `upscalers.md` since `b97a4c798`. ### BeanBot's review of `2d4d1550` - **L22 is not this PR's.** The Guide screenshots check does not pass on the base: it fails on `main` at `0443e4be1`, `964599d20`, `e171f9db2`, `753fb5af6` and `0e32bc100`. `scripts/check_guide_screenshots.py --review-sources` names `gpu/vk/device_policy.h` and `gpu/vk/vk_api.h` for `settings-graphics.png`, both changed on `main` after the revision #2255 reviewed, `a2dc5385` (#2228, #2232, #2275). This head reports the same two files. This PR's own change to `device_policy.h` is one policy field with no menu row. I have not touched the manifest here: reviewing #2232's and #2275's changes against the picture is a second topic, and whoever refreshes it on `main` would conflict with it. Once `main`'s manifest is refreshed, this PR needs `device_policy.h`'s hash recorded once more. - **L19:** the percentiles are in the table now. Time to the first playable frame and peak VRAM need new instrumentation, which is its own PR (as `ab.py` was); the preparation's peak commit is given instead. - **L20:** stands, as Still to test. The gate now lets the farm reach the new path on RADV, RDNA 3, RDNA 4 and the Steam Deck. ### For the hardware runs On another AMD GPU, FSR 4.1.2 may hand over a different shader set from the RX 6700 XT's (`fsr4_model_v07_fp8_no_scale_*`). The unroller refuses what it does not understand, but nothing validates its output at run time, so those runs should read the `AMD FSR 4:` lines and compare the picture with `main`, not only the timings. ### Overlap https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2331 also changes `gpu/vk/vk_fsr4.cpp`; whichever merges second rebases.
Author
Member

@Beanstalk AMD FSR 4 (Upscaler: AMD FSR 4, Render resolution: Performance) on AMD GPUs with an FSR 4.1.2 library: Linux with RADV, Windows RDNA 3 (RX 7000) and RDNA 4 (RX 9000), and a Steam Deck if FSR 4 runs there. Hyrule Field, standing still, with RX_VK_PASS_TIMING=1, on main and on this PR. Wanted from each: the AMD FSR 4: log lines of a first start with no cache/longshot_fsr4_pipelines.bin (which unroller, how many passes are unrolled, each one's build time, any 'left rolled' or 'not unrolled now' line), the same lines of a second start (from the caches), the fsr4 ffxDispatch GPU time and the fps, and a screenshot of the same spot from each side to compare the picture.

@Beanstalk AMD FSR 4 (Upscaler: AMD FSR 4, Render resolution: Performance) on AMD GPUs with an FSR 4.1.2 library: Linux with RADV, Windows RDNA 3 (RX 7000) and RDNA 4 (RX 9000), and a Steam Deck if FSR 4 runs there. Hyrule Field, standing still, with RX_VK_PASS_TIMING=1, on main and on this PR. Wanted from each: the `AMD FSR 4:` log lines of a first start with no cache/longshot_fsr4_pipelines.bin (which unroller, how many passes are unrolled, each one's build time, any 'left rolled' or 'not unrolled now' line), the same lines of a second start (from the caches), the `fsr4 ffxDispatch` GPU time and the fps, and a screenshot of the same spot from each side to compare the picture.
Member

Beanstalk test farm

Commit 520abbf · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `520abbf` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/1999) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
Author
Member
@review
BeanBot requested changes 2026-11-23 08:01:23 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The RX 6700 XT measurements show a substantial FSR 4 GPU-time and cold-build improvement, but the outstanding heavy-scene and cross-platform runs are still needed. (It stands on L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.)

FSR 4.1.2 shaders are folded and more passes unrolled, reducing measured GPU time and cold compilation cost on the tested Windows RDNA 2 system. The expanded unroller adds substantial compiler code and costs about 1.9 seconds of additional background unrolling on warm starts.

Blocking (1): must change before merging.

  1. L22: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 48s.

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

  • L19: The remaining heavy-scene and first-playable-frame measurements are missing. When: The reported comparison uses Performance in Hyrule Field and measures shader preparation and process commit, leaving Auto, first-playable timing and peak VRAM unknown. Do: Compare the merge base and this head in an Auto heavy scene, with source logs, cold and warm time to first playable frame, and peak VRAM.
  • L20 gpu/vk/vk_fsr4.cpp:735: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

@fix can do L22.

Since the last review (on 2d4d155042)
Still open: L19 (The remaining heavy-scene and first-playable-frame measurements are missing.); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)

Checks: Still running: CI / Website build and checks (pull_request).

Also noticed (2; not asked for, not blocking)
  • The reported warm-start unrolling takes 2.2 seconds on a background thread, compared with 0.3 seconds on main.
  • The provided CI data reports Guide screenshots failing on this head and the Website check still running.
More: does it help, other systems, switches, what was read

Does it help: Yes on the tested RX 6700 XT: three interleaved runs report median FSR 4 GPU time falling from 3.854 to 3.336 ms, while cold pipeline builds fall from 131.4 to 3.27 seconds. Overall frame-rate runs overlap, and other AMD compilers remain unmeasured.

Other systems: FSR 4.1.2 selects the expanded path on AMD GPUs across Windows and Linux; other FSR versions retain the legacy path. RADV, Windows RDNA 3 and 4, and an FSR 4-capable Steam Deck still need the reported parity, cache and performance runs. Other vendors do not use this AMD FSR path.

Switches: No switch added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning.

Reviewed: 64318392b3 against 0e32bc100d: Read AGENTS.md and CONTRIBUTING.md, the latest commit diff, the unroll_one implementation around the changed guards, and the relevant policy and dispatch references. The remaining changed files, full base diff, project standards and PR template were not read in full; the binary fixture was not inspected.; nothing run (a code review).

Checked and fine:

  • The new refusal path removes newly created constants from the lookup tables and restores the ID bound.
  • The decorated constant-composite guard preserves the WorkgroupSize fixture's constant.
  • The description records the measured gain, warm-start cost, fallback policy and outstanding hardware runs.

Testing: No commands that build or run tests were executed. The author reports an in-game Windows RX 6700 XT run and game-free checks on this head; Linux and additional hardware runs remain outstanding.

Overlaps and merge order: The description reports integration with landed shader preparation and model-selection changes; no current overlapping pull request was independently checked.


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

**Recommendation: Request changes.** The RX 6700 XT measurements show a substantial FSR 4 GPU-time and cold-build improvement, but the outstanding heavy-scene and cross-platform runs are still needed. (It stands on L22: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s.) FSR 4.1.2 shaders are folded and more passes unrolled, reducing measured GPU time and cold compilation cost on the tested Windows RDNA 2 system. The expanded unroller adds substantial compiler code and costs about 1.9 seconds of additional background unrolling on warm starts. **Blocking (1)**: must change before merging. 1. **L22**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 48s. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L19**: The remaining heavy-scene and first-playable-frame measurements are missing. *When:* The reported comparison uses Performance in Hyrule Field and measures shader preparation and process commit, leaving Auto, first-playable timing and peak VRAM unknown. **Do:** Compare the merge base and this head in an Auto heavy scene, with source logs, cold and warm time to first playable frame, and peak VRAM. - **L20** `gpu/vk/vk_fsr4.cpp:735`: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. `@fix` can do L22. **Since the last review** (on 2d4d155042bc) Still open: L19 (The remaining heavy-scene and first-playable-frame measurements are missing.); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…); L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) **Checks:** Still running: `CI / Website build and checks (pull_request)`. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The reported warm-start unrolling takes 2.2 seconds on a background thread, compared with 0.3 seconds on main. - The provided CI data reports Guide screenshots failing on this head and the Website check still running. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested RX 6700 XT: three interleaved runs report median FSR 4 GPU time falling from 3.854 to 3.336 ms, while cold pipeline builds fall from 131.4 to 3.27 seconds. Overall frame-rate runs overlap, and other AMD compilers remain unmeasured. **Other systems:** FSR 4.1.2 selects the expanded path on AMD GPUs across Windows and Linux; other FSR versions retain the legacy path. RADV, Windows RDNA 3 and 4, and an FSR 4-capable Steam Deck still need the reported parity, cache and performance runs. Other vendors do not use this AMD FSR path. **Switches:** No switch added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning. **Reviewed:** 64318392b325 against 0e32bc100dbe: Read AGENTS.md and CONTRIBUTING.md, the latest commit diff, the unroll_one implementation around the changed guards, and the relevant policy and dispatch references. The remaining changed files, full base diff, project standards and PR template were not read in full; the binary fixture was not inspected.; nothing run (a code review). **Checked and fine:** - The new refusal path removes newly created constants from the lookup tables and restores the ID bound. - The decorated constant-composite guard preserves the WorkgroupSize fixture's constant. - The description records the measured gain, warm-start cost, fallback policy and outstanding hardware runs. **Testing:** No commands that build or run tests were executed. The author reports an in-game Windows RX 6700 XT run and game-free checks on this head; Linux and additional hardware runs remain outstanding. **Overlaps and merge order:** The description reports integration with landed shader preparation and model-selection changes; no current overlapping pull request was independently checked. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
madebyjordan force-pushed perf/fsr4-further from 64318392b3
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
CI / Website build and checks (pull_request) Successful in 4m7s
beanstalk/approval can't be tested as asked: see the farm's comment
PR description / Description follows the template (pull_request_target) Successful in 4s
to 9d18a64f5c
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
Website / Website preview, build (pull_request) Has been skipped
Website / Website preview, upload (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
CI / Workflow lint (actionlint) (pull_request) Successful in 15s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 16s
Third-party parts / As their notes say (pull_request) Successful in 18s
CI / Website build and checks (pull_request) Failing after 26s
Website / Website builds (pull_request) Failing after 28s
PR description / Description follows the template (pull_request_target) Successful in 7s
beanstalk/approval not approved yet
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m41s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 3m0s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 4m23s
2026-11-25 08:10:21 +00:00
Compare
Author
Member

Rebased onto main @ be663a08a; the new head is 9d18a64f5.

  • The conflict: gpu/vk/vk_fsr4.cpp load(), beside #2331's Lite log lines. Both kept, and the expanded_unroll / compact_builds lines still come after the last pick_newest() and before l.ok = true. Every line this PR adds or removes is the same as at 64318392b.
  • #2331's stand-in and forced Lite don't reach the expanded unroller: there suppress is set, so create_compute_pipelines passes through; on another maker's GPU tune::on() is false.
  • L22 (Guide screenshots): main's manifest was refreshed by #2463, so the one file left is this PR's own gpu/vk/device_policy.h. Its change is the fsr4_compact_builds flag and its log line, with no menu row, so the Graphics image still matches. f91788248 records the new hash (with a sha256: revision, since this PR's commits don't survive the squash). check_guide_screenshots.py --review-sources passes.
  • 9d18a64f5: a cold read found that no check read the gate itself (test_fsr4_bind_dispatch.py sets expanded_unroll on its own). tests/test_fsr4_tune.py now does; tune::expanded_unroll = true; or no line fails it.
  • Checks: built with LONGSHOT_FSR=1 (0 errors), run_all.py --changed forge/main 39 passed, 0 failed, 4 skipped.
  • Why the numbers still hold: the renderer change is line for line the one measured at 64318392b. A run in the game at this head needs a game built at this main (#2286 and #2411 changed the host's side of the renderer), and no nightly has it yet.

Still open, as before: the hardware runs in Still to test (the farm can't build FSR 4), and an approval.

Rebased onto `main @ be663a08a`; the new head is `9d18a64f5`. - **The conflict:** `gpu/vk/vk_fsr4.cpp` `load()`, beside https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2331's Lite log lines. Both kept, and the `expanded_unroll` / `compact_builds` lines still come after the last `pick_newest()` and before `l.ok = true`. Every line this PR adds or removes is the same as at `64318392b`. - **#2331's stand-in and forced Lite** don't reach the expanded unroller: there `suppress` is set, so `create_compute_pipelines` passes through; on another maker's GPU `tune::on()` is false. - **L22 (Guide screenshots):** `main`'s manifest was refreshed by https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2463, so the one file left is this PR's own `gpu/vk/device_policy.h`. Its change is the `fsr4_compact_builds` flag and its log line, with no menu row, so the Graphics image still matches. `f91788248` records the new hash (with a `sha256:` revision, since this PR's commits don't survive the squash). `check_guide_screenshots.py --review-sources` passes. - **`9d18a64f5`:** a cold read found that no check read the gate itself (`test_fsr4_bind_dispatch.py` sets `expanded_unroll` on its own). `tests/test_fsr4_tune.py` now does; `tune::expanded_unroll = true;` or no line fails it. - **Checks:** built with `LONGSHOT_FSR=1` (0 errors), `run_all.py --changed forge/main` 39 passed, 0 failed, 4 skipped. - **Why the numbers still hold:** the renderer change is line for line the one measured at `64318392b`. A run in the game at this head needs a game built at this `main` (#2286 and #2411 changed the host's side of the renderer), and no nightly has it yet. Still open, as before: the hardware runs in Still to test (the farm can't build FSR 4), and an approval.
Author
Member
@review
BeanBot left a comment

Recommendation: Request changes. The RX 6700 XT measurements show a substantial FSR 4 GPU-time and cold-build improvement, but the requested hardware and pacing measurements remain outstanding. Two website checks also fail only on this head, and two checks are still running. (It stands on L27: The check CI / Website build and checks (pull_request) fails on this head and passes on the base branch: Failing after 26s.)

Folds and unrolls more FSR 4.1.2 shaders, including the postpass, to reduce GPU time and pipeline build cost. It adds a substantial shader transformation and retains a second unroller for other FSR versions.

Blocking (2): must change before merging.

  1. L27: The check CI / Website build and checks (pull_request) fails on this head and passes on the base branch: Failing after 26s.
  2. L28: The check Website / Website builds (pull_request) fails on this head and passes on the base branch: Failing after 28s.

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

  • L19: The remaining heavy-scene and first-playable-frame measurements are missing. When: The reported comparison uses Performance in Hyrule Field and measures shader preparation and process commit, leaving Auto, first-playable timing and peak VRAM unknown. Do: Compare the merge base and this head in an Auto heavy scene, with source logs, cold and warm time to first playable frame, and peak VRAM.
  • L20 gpu/vk/vk_fsr4.cpp:735: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

@fix can do L27 and L28.

Since the last review (on 64318392b3)
Resolved: L22 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…)
Still open: L19 (The remaining heavy-scene and first-playable-frame measurements are missing.); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…)
New: L27 (The check CI / Website build and checks (pull_request) fails on this head and passes on…); L28 (The check Website / Website builds (pull_request) fails on this head and passes on the b…)

Checks: Still running: CI / Rust (rustfmt, clippy, cargo test) (pull_request), CI / Host C for Windows (llvm-mingw, compile only) (pull_request).

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

Does it help: Yes on the measured Windows RX 6700 XT: three interleaved pairs show median FSR 4 GPU time falling from 3.854 to 3.336 ms, and cold pipeline builds falling from 131.4 to 3.27 seconds. Frame-rate runs overlap; results on other compilers remain unmeasured.

Other systems: FSR 4.1.2 uses the expanded path on AMD GPUs, including RADV and Windows RDNA 3 and 4; their requested runs remain outstanding. Other FSR versions retain the legacy unroller, and the lower build-memory threshold is limited to AMD's older Windows compiler.

Switches: No switches added, changed or removed. The existing RX_VK_FSR4_TUNE switch can disable tuning.

Reviewed: 9d18a64f5c against be663a08a3: Read AGENTS.md, CONTRIBUTING.md, the changed gate test, relevant FSR 4 selection and headroom code, and the supplied review and measurement records. Skimmed the diff and supporting documentation; the full changed code and all repository review documents were not read.; nothing run (a code review).

Checked and fine:

  • The new source check verifies the FSR 4.1.2 gate occurs after the final version selection and before load completes.
  • The compact-build headroom remains restricted by compiler policy and shader size.

Testing: No commands that build or run the project were executed. The author reports 39 changed-file checks passing on Windows and an in-game A/B on the equivalent earlier renderer change; the current head has not run in the game. Website checks fail on this head and Rust and Windows host checks are still running.

Overlaps and merge order: The supplied history says the changes from #1886, #1989 and #2140 are already incorporated.


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

**Recommendation: Request changes.** The RX 6700 XT measurements show a substantial FSR 4 GPU-time and cold-build improvement, but the requested hardware and pacing measurements remain outstanding. Two website checks also fail only on this head, and two checks are still running. (It stands on L27: The check `CI / Website build and checks (pull_request)` fails on this head and passes on the base branch: Failing after 26s.) Folds and unrolls more FSR 4.1.2 shaders, including the postpass, to reduce GPU time and pipeline build cost. It adds a substantial shader transformation and retains a second unroller for other FSR versions. **Blocking (2)**: must change before merging. 1. **L27**: The check `CI / Website build and checks (pull_request)` fails on this head and passes on the base branch: Failing after 26s. 2. **L28**: The check `Website / Website builds (pull_request)` fails on this head and passes on the base branch: Failing after 28s. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L19**: The remaining heavy-scene and first-playable-frame measurements are missing. *When:* The reported comparison uses Performance in Hyrule Field and measures shader preparation and process commit, leaving Auto, first-playable timing and peak VRAM unknown. **Do:** Compare the merge base and this head in an Auto heavy scene, with source logs, cold and warm time to first playable frame, and peak VRAM. - **L20** `gpu/vk/vk_fsr4.cpp:735`: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. `@fix` can do L27 and L28. **Since the last review** (on 64318392b325) Resolved: L22 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…) Still open: L19 (The remaining heavy-scene and first-playable-frame measurements are missing.); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…) New: L27 (The check `CI / Website build and checks (pull_request)` fails on this head and passes on…); L28 (The check `Website / Website builds (pull_request)` fails on this head and passes on the b…) **Checks:** Still running: `CI / Rust (rustfmt, clippy, cargo test) (pull_request)`, `CI / Host C for Windows (llvm-mingw, compile only) (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the measured Windows RX 6700 XT: three interleaved pairs show median FSR 4 GPU time falling from 3.854 to 3.336 ms, and cold pipeline builds falling from 131.4 to 3.27 seconds. Frame-rate runs overlap; results on other compilers remain unmeasured. **Other systems:** FSR 4.1.2 uses the expanded path on AMD GPUs, including RADV and Windows RDNA 3 and 4; their requested runs remain outstanding. Other FSR versions retain the legacy unroller, and the lower build-memory threshold is limited to AMD's older Windows compiler. **Switches:** No switches added, changed or removed. The existing RX_VK_FSR4_TUNE switch can disable tuning. **Reviewed:** 9d18a64f5c73 against be663a08a30f: Read AGENTS.md, CONTRIBUTING.md, the changed gate test, relevant FSR 4 selection and headroom code, and the supplied review and measurement records. Skimmed the diff and supporting documentation; the full changed code and all repository review documents were not read.; nothing run (a code review). **Checked and fine:** - The new source check verifies the FSR 4.1.2 gate occurs after the final version selection and before load completes. - The compact-build headroom remains restricted by compiler policy and shader size. **Testing:** No commands that build or run the project were executed. The author reports 39 changed-file checks passing on Windows and an in-game A/B on the equivalent earlier renderer change; the current head has not run in the game. Website checks fail on this head and Rust and Windows host checks are still running. **Overlaps and merge order:** The supplied history says the changes from #1886, #1989 and #2140 are already incorporated. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
Author
Member
@fix
Member

I didn't fix this pull request: the check of my change found a blocking problem in it: The Help page repair adds a second, unrelated topic to the FSR 4 performance PR, contrary to the repository’s one-topic rule (L29). Nothing was pushed.


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

I didn't fix this pull request: the check of my change found a blocking problem in it: The Help page repair adds a second, unrelated topic to the FSR 4 performance PR, contrary to the repository’s one-topic rule (L29). Nothing was pushed. --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
Author
Member

BeanBot's review of 9d18a64f

  • L27 and L28 are wrong: both checks fail on main too, with the same error. On be663a08a (this PR's base), CI / Website build and checks (push) fails (run 53536) and so does Website / Website on Cloudflare (push) (run 53540), the push-side build of the site. Website / Website builds runs only on pull requests, so it shows as skipped on main, not passed. All four logs stop at the same line of astro build:
    Help page group list changed: it must link each group in order
      at formatCommonIssues (website/src/repo-docs/format-common-issues.ts:53:9)
    
    The cause is #2286: it added the "Not sure where to start? … doctor" paragraph to docs/user/common-issues.md after the introduction's list of groups, and the site's parser wants that list to end the introduction. This PR doesn't touch either file.
  • L19: as before, measuring time to the first playable frame and peak VRAM needs new instrumentation, which is its own PR. The cold preparation's time and peak commit are measured instead.
  • L20: stands, as Still to test.
### BeanBot's review of `9d18a64f` - **L27 and L28 are wrong: both checks fail on `main` too, with the same error.** On `be663a08a` (this PR's base), `CI / Website build and checks (push)` fails ([run 53536](https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/53536)) and so does `Website / Website on Cloudflare (push)` ([run 53540](https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/53540)), the push-side build of the site. `Website / Website builds` runs only on pull requests, so it shows as *skipped* on `main`, not passed. All four logs stop at the same line of `astro build`: ``` Help page group list changed: it must link each group in order at formatCommonIssues (website/src/repo-docs/format-common-issues.ts:53:9) ``` The cause is https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2286: it added the "Not sure where to start? … `doctor`" paragraph to `docs/user/common-issues.md` after the introduction's list of groups, and the site's parser wants that list to end the introduction. This PR doesn't touch either file. - **L19:** as before, measuring time to the first playable frame and peak VRAM needs new instrumentation, which is its own PR. The cold preparation's time and peak commit are measured instead. - **L20:** stands, as Still to test.
Author
Member

The fix for main's Website checks is #2518 (both errors in common-issues.md, from #2286). Once it merges, this PR is rebased onto it and BeanBot asked again, so L27 and L28 clear.

The fix for main's Website checks is https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2518 (both errors in common-issues.md, from #2286). Once it merges, this PR is rebased onto it and BeanBot asked again, so L27 and L28 clear.
Author
Member

Rebased onto main e9e4065c8 (#2536, #2541, #2538, #2547). All four commits are unchanged (git range-diff: each '='), and main touches none of this PR's files. The website failures BeanBot flagged as L27/L28 came from main: #2536 and #2547 fixed them, and main's 'Website build and checks' passes at e9e4065c8. On Windows, tests/test_fsr4_tune.py and check_guide_screenshots.py --review-sources pass on this head.

@review

Rebased onto main e9e4065c8 (#2536, #2541, #2538, #2547). All four commits are unchanged (git range-diff: each '='), and main touches none of this PR's files. The website failures BeanBot flagged as L27/L28 came from main: #2536 and #2547 fixed them, and main's 'Website build and checks' passes at e9e4065c8. On Windows, tests/test_fsr4_tune.py and check_guide_screenshots.py --review-sources pass on this head. @review
madebyjordan force-pushed perf/fsr4-further from 9d18a64f5c
Some checks failed
CI / Conventional Commit title (pull_request) Successful in 7s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
Website / Website preview, build (pull_request) Has been skipped
Website / Website preview, upload (pull_request) Has been skipped
CI / Website build and checks (pull_request) Failing after 26s
CI / Workflow lint (actionlint) (pull_request) Successful in 15s
Third-party parts / As their notes say (pull_request) Successful in 18s
beanstalk/approval not approved yet
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 16s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m41s
Website / Website builds (pull_request) Failing after 28s
PR description / Description follows the template (pull_request_target) Successful in 7s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 3m0s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 4m23s
to 520abbfdb0
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
beanstalk/approval not approved yet
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 21s
CI / What the change needs (pull_request) Successful in 25s
PR description / Description follows the template (pull_request_target) Successful in 32s
CI / Workflow lint (actionlint) (pull_request) Successful in 42s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 44s
Third-party parts / As their notes say (pull_request) Successful in 51s
CI / Website build and checks (pull_request) Successful in 1m9s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m25s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 42s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 3m50s
2026-11-25 17:19:21 +00:00
Compare
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The measured RX 6700 XT result shows a substantial FSR 4 GPU-time and cold-build improvement, but the outstanding heavy-scene and other-platform runs remain incomplete. Recommend approval; not approved on the forge.

The change folds and unrolls more FSR 4.1.2 passes, reducing GPU work and cold pipeline build time on the measured system. It adds a second unroller and more transformation code, and increases background work on warm starts.

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

  • L19: The remaining heavy-scene and first-playable-frame measurements are missing. When: The reported comparison uses Performance in Hyrule Field and measures shader preparation and process commit, leaving Auto, first-playable timing and peak VRAM unknown. Do: Compare the merge base and this head in an Auto heavy scene, with source logs, cold and warm time to first playable frame, and peak VRAM.
  • L20 gpu/vk/vk_fsr4.cpp:735: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes.

Since the last review (on 9d18a64f5c)
Resolved: L27 (The check CI / Website build and checks (pull_request) fails on this head and passes on…); L28 (The check Website / Website builds (pull_request) fails on this head and passes on the b…)
Still open: L19 (The remaining heavy-scene and first-playable-frame measurements are missing.); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…)

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

Does it help: Yes, on the measured Windows RX 6700 XT: three interleaved pairs show median FSR 4 GPU time falling from 3.854 to 3.336 ms, and cold pipeline builds from 131.4 to 3.27 seconds. Overall frame-rate runs overlap, and one changed-side run had worse frame pacing.

Other systems: FSR 4.1.2 selects the expanded unroller on AMD systems including RADV and Windows RDNA 3 and 4; those paths and an FSR 4-capable Steam Deck still need the reported hardware runs. Other FSR versions retain the legacy unroller; compilers outside the measured older AMD Windows compiler retain the 8 GiB build headroom.

Switches: No switch was added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning; the new version and compiler policies select the unroller and build headroom automatically.

Reviewed: 520abbfdb0 against e9e4065c86: Read AGENTS.md, CONTRIBUTING.md and the pull request template, the policy and documentation diff, and the relevant vk_fsr4.cpp gate, job and headroom sections. Skimmed the remaining change, recorded runs, comments and reviews; the unroller, tests and other changed files were not read in full on this re-check. No review-checklist file exists at the named path.; nothing run (a code review).

Checked and fine:

  • The FSR 4.1.2 gate selects the expanded unroller; other versions retain the legacy path.
  • Compact build headroom is limited to the older AMD proprietary Windows compiler and compact expanded shaders.
  • The reported rebase leaves the pull request diff unchanged, and CI reports no current failures.

Testing: No commands from the project were run. The author reports Windows build and game-free checks passing, plus in-game RX 6700 XT measurements on the equivalent renderer change; Linux and additional hardware runs remain outstanding.

Overlaps and merge order: The reported website fixes and renderer integration changes are already in the base; no unresolved overlap was identified.


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

**Recommendation: Approve.** The code is ready: only testing is left. The measured RX 6700 XT result shows a substantial FSR 4 GPU-time and cold-build improvement, but the outstanding heavy-scene and other-platform runs remain incomplete. Recommend approval; not approved on the forge. The change folds and unrolls more FSR 4.1.2 passes, reducing GPU work and cold pipeline build time on the measured system. It adds a second unroller and more transformation code, and increases background work on warm starts. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L19**: The remaining heavy-scene and first-playable-frame measurements are missing. *When:* The reported comparison uses Performance in Hyrule Field and measures shader preparation and process commit, leaving Auto, first-playable timing and peak VRAM unknown. **Do:** Compare the merge base and this head in an Auto heavy scene, with source logs, cold and warm time to first playable frame, and peak VRAM. - **L20** `gpu/vk/vk_fsr4.cpp:735`: Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and parity across odd dimensions and SDR/HDR or context changes. **Since the last review** (on 9d18a64f5c73) Resolved: L27 (The check `CI / Website build and checks (pull_request)` fails on this head and passes on…); L28 (The check `Website / Website builds (pull_request)` fails on this head and passes on the b…) Still open: L19 (The remaining heavy-scene and first-playable-frame measurements are missing.); L20 (Complete the RADV, RDNA 4 and Steam Deck runs, including cold pacing, warm cache hits and…) <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes, on the measured Windows RX 6700 XT: three interleaved pairs show median FSR 4 GPU time falling from 3.854 to 3.336 ms, and cold pipeline builds from 131.4 to 3.27 seconds. Overall frame-rate runs overlap, and one changed-side run had worse frame pacing. **Other systems:** FSR 4.1.2 selects the expanded unroller on AMD systems including RADV and Windows RDNA 3 and 4; those paths and an FSR 4-capable Steam Deck still need the reported hardware runs. Other FSR versions retain the legacy unroller; compilers outside the measured older AMD Windows compiler retain the 8 GiB build headroom. **Switches:** No switch was added, changed or removed. The existing RX_VK_FSR4_TUNE=0 disables tuning; the new version and compiler policies select the unroller and build headroom automatically. **Reviewed:** 520abbfdb031 against e9e4065c86f0: Read AGENTS.md, CONTRIBUTING.md and the pull request template, the policy and documentation diff, and the relevant vk_fsr4.cpp gate, job and headroom sections. Skimmed the remaining change, recorded runs, comments and reviews; the unroller, tests and other changed files were not read in full on this re-check. No review-checklist file exists at the named path.; nothing run (a code review). **Checked and fine:** - The FSR 4.1.2 gate selects the expanded unroller; other versions retain the legacy path. - Compact build headroom is limited to the older AMD proprietary Windows compiler and compact expanded shaders. - The reported rebase leaves the pull request diff unchanged, and CI reports no current failures. **Testing:** No commands from the project were run. The author reports Windows build and game-free checks passing, plus in-game RX 6700 XT measurements on the equivalent renderer change; Linux and additional hardware runs remain outstanding. **Overlaps and merge order:** The reported website fixes and renderer integration changes are already in the base; no unresolved overlap was identified. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
beanstalk/approval not approved yet
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 21s
CI / What the change needs (pull_request) Successful in 25s
PR description / Description follows the template (pull_request_target) Successful in 32s
CI / Workflow lint (actionlint) (pull_request) Successful in 42s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 44s
Third-party parts / As their notes say (pull_request) Successful in 51s
CI / Website build and checks (pull_request) Successful in 1m9s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m25s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 42s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 3m50s
This pull request has changes conflicting with the target branch.
  • docs/user/images/guide/manifest.json
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/fsr4-further:madebyjordan-perf/fsr4-further'
git switch 'madebyjordan-perf/fsr4-further'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!1999
No description provided.