perf(vk): fold constants and local arrays when unrolling AMD FSR 4, and unroll the postpass #1999
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1999
Loading…
Reference in a new issue
No description provided.
Delete branch "madebyjordan/Longshot:perf/fsr4-further"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_allblindly clones loop bodies containing 576-wordOpStores into Function arrays and thousands of local-allocaOpAccessChain/OpLoad/OpStoreinstructions. That leftpass1/pass2/pass12at ~107,000 words (~50 s and ~3 GB commit charge each to build cold), causedpass4/pass5/pass10to exceed 200,000 words (40–55 GB OOM, so they stayed rolled), and leftpostpass(the single slowest FSR 4 pass) rolled because it usesOpINotEqual, multi-OpPhilive-out loops,if (oob) continue;, and wave32.What this changes:
gpu/vk/spirv_unroll.h: Upgradesspirv_unroll::unroll_allto hoist immutable constant-arrayOpStores once to each function's entry block (scanning pastOpLine/OpNoLineso hoisted stores always follow every FunctionOpVariable), generalize innermost-first loop unrolling (OpULessThan,OpSLessThan,OpINotEqual, multi-OpPhilive-out loops, and single top-levelif (cond) continue;selections), merge adjacent trivial blocks, fold 32-bit scalar/vector integer arithmetic, bitcasts, flat composites, and constant-array loads into immediate constants (guardingOpAccessChainagainst negative or out-of-bounds constant indices acrossfold_constants,forward_function_allocas, and live-out loopexit_alias), forward intra-block non-escaping plain Function allocas (with bitcasted-vector unpacking, safe dead-store tracking, vector reassembly, and 0-indexOpAccessChainescape rejection), and run exact fixed-point DCE (removing dead Function variables only after every store and access chain referencing them is gone, plus unusedOpConstantCompositetables and strippedOpNames). PreservesOpDecorate/OpGroupDecorate/OpDecorateId/OpDecorateString, places new constants right before the firstOpFunction, guards operand counts against malformed SPIR-V, refuses non-32-bitOpSwitchin block merging and anyOpSwitch, degenerateB == Mloop, or non-retargeted selection reachingcontinue(CFG-order-independent) inside unrolled loops, and scans pastOpLine/OpNoLinewhen checking merge-blockOpPhis. 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: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.kCompactHeadroom = 1 GiBcold-build memory threshold (for compact folded shaders<= kCompactUnrollWords = 60,000words) viaDevicePolicy::fsr4_compact_buildsto AMD's older Windows shader compiler (RDNA 1 and 2, matchingnan_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 to120,000words keepkBuildHeadroom = 8 GiBuntil their compile memory is measured.unrolled_lanes: 64 for wave64 layers, else the original requested size / absent), integrates cleanly with#1886/#2140(fsr4_prepare_shaderswarms the folded passes before gameplay) and#1989(tune::suppressedpass-through for forced Lite), keys in-flight jobs by per-creation generation tokens (pending_token), gives worker threads an immutableworker_fndispatch table initialized inprepare_device(), and handles thread-creation and worker allocation failures with full Vulkan resource rollback.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 againstspirv_unroll.h—spirv_unroll_legacy.hand theexpanded_unrollsplit 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_buildspolicy and the!has_plainrequirement.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-compiledpostpassminiature fixture, an exact Python SPIR-V interpreter verifying bit-exact output parity across invocations and bothcontinueoutcomes for rolled, tail-rewritten, and unrolled+foldedlayer.spvandpostpass.spv, synthetic SPIR-V regression tests (L1–L5,L8–L10,R1–R6), Unicode-safe stdio transport,CXXenv handling,DevicePolicy::fsr4_compact_buildscoverage across all 24 PC fixtures, and compiled behavioral tests intest_fsr4_bind_dispatch.pyexercisingcreate_compute_pipelines,build_unrolled,destroy_pipeline,cmd_bind_pipeline,cmd_dispatch,build_want,expanded_unrollfallback,suppressedpass-through,worker_fnisolation, 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), andgpu/vk/device_policy.h(fsr4_compact_builds).Testing
Tested:
9d18a64f5onmain @ be663a08a), Windows 11, RX 6700 XT: the rebase of64318392b(below) ontomain, plus the Guide manifest'sdevice_policy.hhash and one more source check. Every line the PR adds or removes is the same as at64318392b; the one conflict was beside #2331's Lite log lines inload().LONGSHOT_FSR=1 python -I scripts/dev.py vk(Rust 1.99.1, asmise.tomlpins): 0 errors, the exportsmkwvk_initandmkwvk_close_asked.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-sourcespasses.tests/test_fsr4_tune.py(load()gives the expanded unroller to FSR 4.1.2 alone, after the lastpick_newest()and beforel.ok = true) fails withtune::expanded_unroll = true;and with the line deleted, and passes here.MkwVkHostversions 46 to 48), so this DLL needs a game built at thatmain, and no nightly has it yet (nightly-805 is6b928cb4). The numbers below are from64318392b, whose renderer change is line for line this one.64318392bonmain @ 0e32bc100, Windows 11, AMD Radeon RX 6700 XT, Adrenalin 26.10.1 (driver0x800161), AMD FSR 4.1.2: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 inbin/longshot_vk.dll. Hyrule Field (child), 2560×1440 output, FSR 4 Performance (1280×720): the log sayspasses 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-shaderswarms the folded passes (#1886): from an empty FSR 4 cache at a new folder path, the preparation builds all 7 and ends withSDR pipeline preparation finished (7 optimized layers ready);mainbuilds 3 and leavespass4,pass5andpass10rolled. Times and memory are in Measurements.from the caches(main: 3 of 3).python -I -B tests/run_all.py --changed forge/main(llvm-mingwclang++, Vulkan SDK 1.4.341.1spirv-val): 39 passed, 0 failed, 4 skipped (nx2/test_image_arrays.py,tests/test_native_float_atomic_add.pyandtests/test_vendor_translation.pyare skipped on Windows by their own declaration,tests/test_native_zstd.pywants thezstandardpackage).R7–R10intests/test_fsr4_tune.py) each fail on09345da7f, the commit before their guards, and pass here.c8371016: SDRpass1/2/4/5/10/12bit-exact (0 / 14,745,600FP16 values differ), with the postpass6 / 14,745,600differ by at most 2 ULP (one more FMA contraction across the unrolled 2×2 quad, confirmed withNoContraction); HDR bit-exact. All 13 FSR 4.1.2 shaders passedspirv-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:
by hand).tests/run_all.py --stricton Ubuntu 24.04, expecting no failure thatmaindoes not have (@Beanstalkor Linux CI).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 asmain(by hand).fsr4 ffxDispatchthanmain(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'shyrule-fieldscene), 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 atimingjob of the queue run bydev.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 fromRX_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=0in 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.0e32bc1064318392fsr4 ffxDispatchGPU time (run 1 / 2 / 3; median)--prepare-shaders, FSR 4's part: passes unrolledpass4,pass5,pass10left rolled)preparation finishedcache/longshot_fsr4_pipelines.binmain.longshot_fsr4_pipelines.binin a game folder at a path the driver had not seen.The log lines:
Risks
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.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.RX_VK_FSR4_TUNE=0runs AMD's shaders as they are; a revert restores the previous unroller.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 formain's three), and the file grows by about 150 KB. Saves andlongshot_options.iniare untouched.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (the checks that read the changed files pass on Windows; the Guide screenshots check fails onmaintoo, see the comment of 2026-11-23; the full Linux suite is in Still to test).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.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.
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.
@fixwill do (21)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)gpu/vk/spirv_unroll.h:1255: Unrolling now accepts decorated loop results, then drops their OpDecorate instructions without cloning them. (more on the line)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)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)gpu/vk/spirv_unroll.h:949: DCE can remove a Function variable while leaving a store that still uses it. (more on the line)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)gpu/vk/spirv_unroll.h:1022: Block merging reads every OpSwitch case as a 32-bit literal and label. (more on the line)gpu/vk/spirv_unroll.h:1225: A continue that misses the narrow pattern is still cloned. (more on the line)gpu/vk/spirv_unroll.h:1276: The merge-block check inspects one instruction immediately after OpLabel. (more on the line)gpu/vk/spirv_unroll.h:211: The parser checks instruction framing but the new scans assume opcode-specific operands exist. (more on the line)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)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)gpu/vk/vk_fsr4.cpp:821: The new postpass job inherits cancellation keyed only by the raw VkPipeline handle. (more on the line)gpu/vk/vk_fsr4.cpp:674: The extra background job reads plain driver function pointers that device_proc rewrites. (more on the line)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)tests/test_fsr4_tune.py:204: The subgroup checks match specific source strings. (more on the line)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.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)
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
afc4d1adversus 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:
de6ab96897againstf1f2dc5bd2: 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:
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.
@ -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`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) {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());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());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));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);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])) {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]);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++) {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;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)) {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)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<uint3VkShaderModule module = VK_NULL_HANDLE;if (real_csm(dev.device, &mci, nullptr, &module) == VK_SUCCESS) {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, VkPipelineCapending.insert(p[i]);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)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: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")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.
Not ready to merge. This is a comment because the PR is my own. I read the code at
de6ab968and ran nothing.New and blocking
gpu/vk/spirv_unroll.h:800).forward_function_allocasrecords the store's position, then may addOpBitcasts 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: storeasuint(float2(a, b))top, readp[0], store topagain. Fix: record the position after the bitcasts are added, and add this case to the test.New and minor
kISubis 129, which isOpFAdd;OpISubis 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 literalcase 130:inis_pure_opwithcase 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
float4(v.xy, a, b).Merge state
40bfceb0).gpu/vk/vk_fsr4.cppwith #1886 and #1989. Whichever lands second needs a rebase.Checked and fine: the
lanes[i].pNextguard does nothing for the postpass, buthas_plainalready 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,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();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.
Addressed all code, test, and doc findings from review #2050 (
L1–L18,L21, and the code-side guards ofL19–L20):gpu/vk/spirv_unroll.his_flat_construct()so vectorOpCompositeConstructtracking in bothfold_constantsandforward_function_allocasverifiesin.size() - 3 == countand scalar element types (rejecting mixed vector+scalar packing).TypeInfo::scanrecords all IDs targeted byOpDecorate;unroll_onerefuses loops whosemadeset contains a decorated ID,fold_constantsrefuses to alias decorated results, andforward_function_allocasrefuses to forward decorated loads.forward_function_allocastracks alias-forwarded loads and callsstrip_annotations(m, removed_loads, false)to strip theirOpNames without touchingOpDecorate.TypeInfo::scanrecordsfirst_func;insert_new_constsandunroll_oneinsert newOpConstants immediately before the firstOpFunction(after allOpType*and prior constants), andfold_constantsscans fromfirst_func.find_non_escaping_fvarsrequires plain 4-wordOpLoadand plain 3-wordOpStore, excluding any Function variable with memory-operand-qualified accesses from forwarding and DCE.dceiterates to exact fixed point and only deletes a dead FunctionOpVariableonce!used.count(in[2])(after every store and chainedOpAccessChainreferencing it has been removed).merge_trivial_blocksrefuses modules containing anyOpSwitchwhose selector is not a known 32-bit integer or whose operand count is odd;unroll_onerefuses loops containingOpSwitch.unroll_onetracksopen_sel_mergesand refuses any branch/conditional branch targetingcontfrom inside a non-retargeted selection.unroll_onescans the entire merge block[mi + 1 .. terminator/next_label)forOpPhisoOpLine/OpNoLinecannot hide a merge-block phi.TypeInfo::scan,for_each_id(MAligned /LLoopControl),merge_trivial_blocks, andunroll_one.gpu/vk/vk_fsr4.cppkBuildHeadroom = 8 GiBfor larger/unverified shaders (> kCompactUnrollWords = 60,000) and gated the1 GiBthreshold (kCompactHeadroom) strictly to compact folded shaders (<= 60,000words; all 7 measured FSR 4.1.2 passes fold to 27–45K words and peak <60 MB).std::thread(build_unrolled, ...).detach()intry/catchwith full rollback ofjobs().running,pending_token, and copied Vulkan layouts (passingsetsby value socatchalways owns every handle), and wrappedbuild_unrolledintry/catchwith an RAIICleanupguard so allocation failures never terminate the process or leak handles.pending/cancelledhandle sets withpending_tokenkeyed by a monotonic per-creationuint64_ttoken (next_job_token), so a destroyed and driver-reusedVkPipelinehandle never publishes a stale build.worker_fndispatch table initialized once inprepare_device()beforedevice_procis exposed;build_unrolledusesworker_fn.*exclusively.Tests & Docs
tests/fsr4_tune/postpass.hlsl&postpass.spvto read from a separateInBufferand write disjointScratchBufferwords; added a Python SPIR-V interpreter intests/test_fsr4_tune.pyverifying bit-exact output parity across invocations (including bothcontinueoutcomes) for rolled, tail-rewritten, and unrolled+foldedlayer.spvandpostpass.spv, plus syntheticspirv-val+ semantic regression cases forL1–L5andL8–L10.tests/test_fsr4_tune.pywith compiled behavioral tests intests/test_fsr4_bind_dispatch.pyexercising the realcreate_compute_pipelines,build_unrolled,destroy_pipeline,cmd_bind_pipeline, andcmd_dispatchhooks against recording fake callbacks (wave64 layer -> 64 lanes, postpass -> 32 lanes and nullpNextwithALLOW_VARYINGpreserved, two-tier headroom,worker_fnisolation, and handle-reuse token cancellation).RUN_ALL_SKIPon Windows fromtests/test_fsr4_tune.py(now gated automatically by{spirv_val}), honoredCXXenv var, and switched the test driver to binarystdin/stdoutso Python'sPathhandles all Unicode paths natively.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).27311–44769),det=1, 13/13 passspirv-val --target-env vulkan1.3.LONGSHOT_FSR=1 python -I scripts/dev.py vk(Windows llvm-mingw): 0 errors, symbols checked.@review
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.
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.
@fixwill do (5)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.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)
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:
c8371016fdagainstf1f2dc5bd2: Read AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the changes sincede6ab968and 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:
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.
@fix
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
Changed in part (the rest is for the author)
Not done this time (still open: the next
@fixtakes it)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.
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.
@fixwill do (4)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)
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:
0ccb8e229cagainstf1f2dc5bd2: 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:
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.
@ -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]);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.
0ccb8e229c3a7aca49c9Addressed both real findings from Review #2085, rebased onto current
main(fd7dc40d), replaced BeanBot's unbuilt0ccb8e22commit (which duplicatedspirv_unroll_legacy.h, hardcoded a single GPU/driver/FSR stringAMD 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)
gpu/vk/spirv_unroll.hforward_function_allocas): Movedsm[loc.path] = rebuilt.size();after thevec_bitcast_srcunpacking loop (right before pushing theOpStore) so overwriting a location removes the supersededOpStoreand never a scalarOpBitcastreferenced by a forwarded load. Added synthetic regressionR1_bitcast_overwrite_dead_store(asuint(float2(a, b))store -> load -> overwrite ->spirv-val+ SPIR-V VM parity) intests/test_fsr4_tune.py.OpFAdd/OpISubopcodes (gpu/vk/spirv_unroll.h): FixedkISub = 130(was129,OpFAdd) and updatedis_pure_op(case 129:instead of duplicatecase 130:). Audited every other opcode number inspirv_unroll.hagainstspirv.h(all match). AddedR2_isub_const_fold.OpAccessChainconstant index guard (gpu/vk/spirv_unroll.h): EnablingOpISubfolding surfacedpass11.spvfolding0 - 1 = -1into anOpAccessChaininside a dead-at-runtime branch (if (i != 0) arr[i - 1]), whichspirv-valrejects even in untaken code. Addedsafe_access_chain_const()(trackingOpTypeArray,OpTypeVector,OpTypeMatrix,OpTypeStruct,OpTypeRuntimeArraybounds) sofold_constants/apply_aliasesnever substitute a negative or out-of-boundsOpConstantinto anOpAccessChainindex operand, plus regression testR3_oob_access_chain_index.Rebase & Review #2103 Notes
forge/main(fd7dc40d): Pulls in#2013(40bfceb0), clearing the earlier base (f1f2dc5b) CI failures (Websiteand all 37 oldGuide screenshotsentries; notemainheadfd7dc40d#1657currently has 4 unrelatedsettings-graphics.pngitems in untouchedfps_counter.cpp/vk_menu.cpp).L18:scripts/check_pr_description.pyhard-fails non-WIP PRs if any box in### Ready for reviewor kept in### When it appliesis unchecked. Testing and Still to test explicitly record that the Linux build and full Linux CI suite are pending, and### Ready to mergestays unchecked.L11:kCompactHeadroom(1 GiB) only applies to AMD FSR 4 weight-table passes that fold cleanly (left == 0) to<= 60,000words (peaking<60 MB, >16× headroom); larger shaders still requirekBuildHeadroom(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 (includingR1,R2,R3regressions).spirv-val --target-env vulkan1.3(det=1, and all 7 unrolled passespass1/2/4/5/10/12/postpassretain identical folded word counts27311–44769).LONGSHOT_FSR=1 python -I scripts/dev.py vk(Windows llvm-mingw, onmain @ fd7dc40d): compiled cleanly (0 errors, symbols checked).scripts/check_third_party.py&scripts/check_pr_description.py: passed.@review
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.
@fixwill do (3)gpu/vk/vk_fsr4.cpp:735: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations.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)
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:
3a7aca49c9againstfd7dc40db0: 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:
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.
@review
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.
@fixwill do (3)gpu/vk/vk_fsr4.cpp:735: Retain the existing fallback for combinations awaiting coverage, while using the new path for measured combinations.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)
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:
3a7aca49c9againstfd7dc40db0: 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:
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.
@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.
@fix
3a7aca49c9cfd2544fb5Recommendation: 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
@fixchangedI changed this pull request: the new head is
cfd2544fb5. I rebased it ontomain(7c23d2be26).Not done this time (still open: the next
@fixtakes it)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.
@fixwill do (2)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)
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)
cfd2544f;7c23d2beis 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:
cfd2544fb5against7c23d2be26: 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:
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.
@fix
@beanstalk
cfd2544fb510b8e9f2e7Recommendation: 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
@fixchangedI changed this pull request: the new head is
10b8e9f2e7. I rebased it ontomain(9dd41326e7). I edited its description to match the change.Changed in part (the rest is for the author)
Left for the author
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)
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)
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:
10b8e9f2e7against9dd41326e7: 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:
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.
@ -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 _WIN32tune::measured_unroll = dev.props.vendorID == 0x1002 && dev.props.deviceID == 0x73df &&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.
I built and tested BeanBot's
10b8e9f2, which was pushed without being built.dev.py vkpasses on Windows.test_dev_ab,test_dev_packs,test_upscaler_rows,test_pass_barrier,test_recorder_sync) fail onmain @ 9dd41326too.vulkaninfo(RX 6700 XT,0x73df, driver 2.0.353, 26.10.1). This head has not been run in the game yet.The gate leaves two problems, so I have not asked the farm for L20's runs yet:
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.
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 keepsmain'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 withmainnow, and the head has not run in the game.I read the code only (nothing built or run). I went through
vk_fsr4.cppclosely andspirv_unroll.h's folding and forwarding at spot depth. I did not audit all 1,479 lines of the unroller.Blocking
The gate is one configuration, not a per-platform default (
gpu/vk/vk_fsr4.cpp:1121,load()).measured_unrollneeds Windows, vendor 0x1002, device 0x73df, the AMD proprietary driver atdriverVersion == 0x800161, the name "AMD Radeon RX 6700 XT", "26.10.1" in the driver info, and FSR 4.1.2. That has three effects:driverVersioncheck.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.
Two unrollers (
gpu/vk/spirv_unroll_legacy.h, 277 lines, a copy ofmain'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.The branch conflicts with
mainingpu/vk/vk_fsr4.cpp. #1886 ("warm FSR 4 pipelines during shader preparation") changedbuild_unrolled's cache save andcreate_compute_pipelines. After the rebase: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
scripts/devtools/ab.pyis 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.vk_fsr4.cpp:875adds!has_plainfor 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.vk_fsr4.cpp:177andfsr4_tune.h:14say "every pass with constant weight tables … unrolled and folded" with no mention of the gate.docs/dev/reference/upscalers.mddoes 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:
RX_VK_PASS_TIMINGon, 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.nvn: GPU waits in 5 s: 1,866–1,988 ms with FSR 3.1, 1,588–1,592 ms native.temporal_rejected_network,gpu/vk/vk_draw.cpp:9690, followed by afull_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.st_wait_ns("GPU-bound wait"), is 0.1 ms in both. The extra 3 ms isgpu_time_collectandgprof_collect, which run insidebegin_recording'sPROF(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"spirv_unroll_legacy.his 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 passThis 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.mddoes 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;!has_plainapplies 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 _WIN32tune::measured_unroll = dev.props.vendorID == 0x1002 && dev.props.deviceID == 0x73df &&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):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.10b8e9f2e7b97a4c7984Addressed Review #2249 (plus a full audit of
spirv_unroll.hand rebase ontomain @ a2dc53859), pushed asb97a4c798:Review #2249 items addressed
gpu/vk/vk_fsr4.cpp,gpu/vk/device_policy.h):measured_unroll(the single-GPU/single-driver allow-list) withtune::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 retainsspirv_unroll_legacy.hfor wave64 layers only.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"), matchingnan_bits) so the1 GiBcompact-build headroom applies on AMD's older Windows shader compiler (RDNA 1 & 2, where compile memory was measured) while every other compiler keeps8 GiBuntil measured. Fixed the startup log line to print8 GiBwheneverexpanded_unrollis false.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 againstspirv_unroll.h),spirv_unroll_legacy.hand theexpanded_unrollbranch can be removed.main @ a2dc53859: Resolved conflicts cleanly with#1886(fsr4_prepare_shaderswarm-up),#1989(FSR 4 model selection plumbing,tune::suppressedpass-through,prepare_device()),#2140(fsr4_prepare_shadersmodel forwarding),#2148(bc_small_runs),#2169, and#2171.scripts/devtools/ab.pychanges: Removed from this PR (second topic).!has_plainand aligned all comments/docs: Updatedgpu/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_buildsgate and note that a layer without a plain twin is left rolled on every configuration.Additional soundness fixes from auditing
gpu/vk/spirv_unroll.hhoist_const_var_stores: Scans pastOpLine/OpNoLineto find the last FunctionOpVariablein the entry block before inserting hoistedOpStores (fixes invalidOpStorebeforeOpVariablewhen debug line info appears between variables; regressionR4_hoist_var_with_opline).forward_function_allocas: Guards constant load forwarding andapply_aliaseswithsafe_access_chain_constso negative or out-of-bounds constants stored into local variables are never forward-substituted intoOpAccessChain(regressionR5_forward_neg_access_chain).find_non_escaping_fvars: Treats 4-word 0-indexOpAccessChainas escaping so aliased Function variables are not dropped or mis-forwarded (regressionR6_zero_index_access_chain).TypeInfo::scan&apply_aliases/fold_constants: Also tracks and preservesOpGroupDecorate,OpDecorateId, andOpDecorateString.unroll_one: Guards degenerateB == Mloops, makes non-retargeted selection-continue rejection CFG-order-independent, and refuses if a live-out phiexit_aliaswould substitute a negative/OOB constant into an outsideOpAccessChain.tests/test_fsr4_tune.py&tests/test_fsr4_bind_dispatch.py: FixedOpNoLineopcode in the test VM (317, was9), addedR4–R6, and addedsuppressedpass-through andbuild_wantcoverage.Verification on
b97a4c798LONGSHOT_FSR=1 python -I scripts/dev.py vkbuilt cleanly on Windows llvm-mingw (0errors, symbols checked) on bothb97a4c798and baselinemain @ a2dc53859.clang++andg++where C++ is compiled).--prepare-shaderswarm-up and RX 6700 XT A/B onb97a4c798vsmain @ a2dc53859is next once the localnightly-745-a2dc5385build finishes.@review
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)
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)
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:
b97a4c7984againsta2dc538590: 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:
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.
b97a4c79842d4d155042Rebased onto
main @ 753fb5af6(2d4d15504), resolving thetests/test_device_policy.pyconflict with #2228 (bc_small_runs/bc_copy_per_layeralongsidefsr4_compact_buildson AMD Windows).scripts/dev.py vk(longshot_vk.dll,llvm-mingw) and game-free checks on bothclang++andg++:test_device_policy.py,test_fsr4_tune.py(withspirv-val),test_fsr4_bind_dispatch.py, andtest_doc_anchors.py.@review
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.
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)
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.@fixcan 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)
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:
2d4d155042against753fb5af68: 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:
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.
2d4d15504264318392b3Rebased onto
main @ 0e32bc100, run in the game at this head, and four unroller guards added from a cold read. The new head is64318392b; the description has the numbers.What changed
tests/test_device_policy.pywith #2232 (threaded_auto_recorderbesidefsr4_compact_buildson one AMD Windows row); both kept. The PR merges intomainagain.64318392b, four guards ingpu/vk/spirv_unroll.h, each with a synthetic case intests/test_fsr4_tune.pythat fails on09345da7fand 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, soif (i < 2) x = arr[i];over four trips leftarr[2]andarr[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).worker_fncomment saiddevice_procwrites thereal_*pointers; it never does.vk_fsr4.cpp's threads, tokens, cleanup or lock order, andspirv_unroll_legacy.hismain'sspirv_unroll.hapart from its two namespace lines.In the game, on this head (Windows 11, RX 6700 XT, Adrenalin 26.10.1, FSR 4.1.2)
0e32bc1064318392fsr4 ffxDispatchGPU time, three interleaved 60 s pairs--prepare-shaders: passes unrolled, their buildsOne 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
10b8e9f2b97a4c798(expanded_unrollon 4.1.2 for every AMD GPU,fsr4_compact_buildsfor 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.spirv_unroll_legacy.h.SDR pipeline preparation finished (7 optimized layers ready)), and the cold figures are measured again through it.ab.py: out of the PR sinceb97a4c798.!has_plainand the comments: in the description,vk_fsr4.cpp,fsr4_tune.handupscalers.mdsinceb97a4c798.BeanBot's review of
2d4d1550mainat0443e4be1,964599d20,e171f9db2,753fb5af6and0e32bc100.scripts/check_guide_screenshots.py --review-sourcesnamesgpu/vk/device_policy.handgpu/vk/vk_api.hforsettings-graphics.png, both changed onmainafter the revision #2255 reviewed,a2dc5385(#2228, #2232, #2275). This head reports the same two files. This PR's own change todevice_policy.his 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 onmainwould conflict with it. Oncemain's manifest is refreshed, this PR needsdevice_policy.h's hash recorded once more.ab.pywas); the preparation's peak commit is given instead.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 theAMD FSR 4:lines and compare the picture withmain, not only the timings.Overlap
#2331 also changes
gpu/vk/vk_fsr4.cpp; whichever merges second rebases.@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), thefsr4 ffxDispatchGPU time and the fps, and a screenshot of the same spot from each side to compare the picture.Beanstalk test farm
Commit
520abbf· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.@review
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.
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)
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.@fixcan 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)
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:
64318392b3against0e32bc100d: 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:
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.
64318392b39d18a64f5cRebased onto
main @ be663a08a; the new head is9d18a64f5.gpu/vk/vk_fsr4.cppload(), beside #2331's Lite log lines. Both kept, and theexpanded_unroll/compact_buildslines still come after the lastpick_newest()and beforel.ok = true. Every line this PR adds or removes is the same as at64318392b.suppressis set, socreate_compute_pipelinespasses through; on another maker's GPUtune::on()is false.main's manifest was refreshed by #2463, so the one file left is this PR's owngpu/vk/device_policy.h. Its change is thefsr4_compact_buildsflag and its log line, with no menu row, so the Graphics image still matches.f91788248records the new hash (with asha256:revision, since this PR's commits don't survive the squash).check_guide_screenshots.py --review-sourcespasses.9d18a64f5: a cold read found that no check read the gate itself (test_fsr4_bind_dispatch.pysetsexpanded_unrollon its own).tests/test_fsr4_tune.pynow does;tune::expanded_unroll = true;or no line fails it.LONGSHOT_FSR=1(0 errors),run_all.py --changed forge/main39 passed, 0 failed, 4 skipped.64318392b. A run in the game at this head needs a game built at thismain(#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.
@review
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.
CI / Website build and checks (pull_request)fails on this head and passes on the base branch: Failing after 26s.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)
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.@fixcan 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 checkWebsite / 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:
9d18a64f5cagainstbe663a08a3: 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:
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.
@fix
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.
BeanBot's review of
9d18a64fmaintoo, with the same error. Onbe663a08a(this PR's base),CI / Website build and checks (push)fails (run 53536) and so doesWebsite / Website on Cloudflare (push)(run 53540), the push-side build of the site.Website / Website buildsruns only on pull requests, so it shows as skipped onmain, not passed. All four logs stop at the same line ofastro build: The cause is #2286: it added the "Not sure where to start? …doctor" paragraph todocs/user/common-issues.mdafter 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.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.
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 ate9e4065c8. On Windows, tests/test_fsr4_tune.py and check_guide_screenshots.py --review-sources pass on this head.@review
9d18a64f5c520abbfdb0@review
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)
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 checkWebsite / 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:
520abbfdb0againste9e4065c86: 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:
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.
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.