perf(vk): fold constants and local arrays when unrolling AMD FSR 4, and unroll the postpass #1999
No reviewers
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) to further reduce AMD FSR 4 GPU time and cut cold first-run pipeline compilation time and memory by >40×.
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, 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 (while guardingOpAccessChainagainst negative or out-of-bounds constant indices from untaken branches), forward intra-block non-escaping plain Function allocas (with bitcasted-vector unpacking, safe dead-store tracking, and vector reassembly), 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). PreservesOpDecorateby refusing decorated loop results/folds/forwarded loads, places new constants right before the firstOpFunction(after all type declarations), guards operand counts against malformed SPIR-V, refuses non-32-bitOpSwitchin block merging and anyOpSwitchor non-retargeted nestedcontinueinside 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(create_compute_pipelines,build_unrolled,destroy_pipeline,prepare_device,kCompactHeadroom/kBuildHeadroom): Removes the wave64-only (kind & 1) gate sopostpass(alsokind & 2) unrolls and saves intocache/longshot_fsr4_pipelines.binalongside passes1, 2, 4, 5, 10, 12, while preserving its requested subgroup size (unrolled_lanes: 64 for wave64 layers, else the original requested size / absent). Uses a two-tier cold-build headroom guard (kCompactHeadroom = 1 GiBonly when the folded shader is<= kCompactUnrollWords = 60,000words; keepskBuildHeadroom = 8 GiBfor larger shaders up to120,000words). Keys in-flight jobs by per-creation generation tokens (pending_token) so handle reuse never publishes a stale build, gives worker threads an immutableworker_fndispatch table initialized inprepare_device(), and handles thread-creation and worker allocation failures with full Vulkan resource rollback. LeavesInitializerBuffer-only passes (pass3, 6, 7, 8, 9, 11) rolled after hardware ablations showed zero gain (and a +0.036 ms regression onpass6).gpu/vk/fsr4_tune.h&docs/dev/reference/upscalers.md: Updates notes and measured figures (distinguishing standalone vs in-game cold compile times and noting eligibility limits).tests/test_fsr4_tune.py,tests/test_fsr4_bind_dispatch.py,tests/fsr4_tune/postpass.hlsl,tests/fsr4_tune/postpass.spv: Adds a race-free DXC-compiledpostpassminiature fixture (InBuffer+ disjointScratchBufferwrites), 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 for L1–L5 and L8–L10, Unicode-safe stdio transport,CXXenv handling, Windows execution via{spirv_val}tool detection (noRUN_ALL_SKIP), and compiled behavioral tests intest_fsr4_bind_dispatch.pyexercising the realcreate_compute_pipelines,build_unrolled,destroy_pipeline,cmd_bind_pipeline, andcmd_dispatchhooks (wave64 -> 64 lanes, postpass -> 32 lanes / nullpNext, two-tier headroom,worker_fnisolation, and handle-reuse token cancellation).Start review at
gpu/vk/spirv_unroll.h(unroll_one,unroll_all,detail::fold_constants,detail::forward_function_allocas,detail::dce) andgpu/vk/vk_fsr4.cpp(build_unrolled,create_compute_pipelines,destroy_pipeline).Testing
Tested:
main @ afc4d1adandthis PR @ b79edcc7withLONGSHOT_FSR=1and ran cold first-run builds plus 3 interleaved 30 s timing pairs (A1/B1/A2/B2/A3/B3) in Hyrule Field (child) at 2560×1440 output, AMD FSR 4 Performance 50% (1280×720), V-Sync Off, Frame Generation Off, cap 1000,RX_VK_PASS_TIMING=1. All 7 passes (pass1, 2, 4, 5, 10, 12, postpass) unrolled, compiled cold in 3.43 s total, saved tocache/longshot_fsr4_pipelines.bin(208 KB), and loaded 7/7 from cache on every subsequent start with clean rendering and-0.843 ms(-18.6%) fasterfsr4 ffxDispatch.spirv-val --target-env vulkan1.3(0 failures, 100% deterministic across repeated runs, identical word counts27311–44769on all 7 unrolled passes).9.008 msraw AMD →3.517 ms(-61.0%),pass1/2/4/5/10/12100% bit-exact (0 / 14,745,600FP16 diffs); withpostpass,6 / 14,745,600FP16 diffs (99.99996% bit-exact, max 2 ULP, all interior pixels, confirmed viaNoContractionablation to be one additional FMA contraction across the unrolled 2×2 quad).8.110 msraw AMD →3.329 ms(-59.0%,postpass0.975 → 0.502 ms),0 / 14,745,600FP16 diffs (100% bit-exact).clang++,spirv-val):tests/test_fsr4_tune.py --spirv-val spirv-val(honoringCXX=clang++, SPIR-V VM parity + L1–L10 edge cases): PASStests/test_fsr4_own_cache.py --cxx clang++: PASStests/test_fsr4_bind_dispatch.py --cxx clang++ --headers ...(compiled behavioral tests ofcreate_compute_pipelines,build_unrolled,destroy_pipeline,cmd_bind_pipeline,cmd_dispatch): PASStests/run_all.py fsr4(without--no-skipon Windows): 3 passed, 0 failed, 0 skippedscripts/check_third_party.py: PASSLONGSHOT_FSR=1 python -I scripts/dev.py vk(Windows llvm-mingw): compiledvk_fsr4.cppwith 0 errors and linkedlongshot_vk.dll(symbols checked).tests/run_all.py --changed: all FSR 4 checks and all 4 C++ unit tests pass; 3 pre-existing failures onmain @ f1f2dc5bin untouched files (tests/test_pass_barrier.pyonvk_work.h,tests/test_upscaler_rows.pyonvk_menu.cpp,tests/test_recorder_sync.pyonvk_colour_vision.cpp).Still to test:
tests/run_all.py --strictsuite on Ubuntu 24.04 (@Beanstalkor Linux CI).amd_fidelityfx_upscaler_vk.so): run Hyrule Field with FSR 4 enabled, verifying cold compile, cache hits, and visual parity (@Beanstalkor by hand).by hand).by hand).Measurements
Verdict: Faster:
-18.6%(-0.843 ms) on in-gamefsr4 ffxDispatch (AMD's passes)GPU time (4.542 → 3.699 ms, zero overlap across all 3 interleaved pairs),-0.82 msmean frame time (23.96 → 23.14 ms),-0.40 msmedian frame time (22.73 → 22.33 ms),-0.98 msp99 frame time (31.70 → 30.72 ms),+3.6%mean FPS (41.74 → 43.22 fps), and42.9×faster cold first-run background pipeline build (147.0 sfor 3 passes →3.43 sfor all 7 passes,0.33–0.69 seach in-game /0.15–0.35 sstandalone,<60 MBpeak commit vs~3 GB).Setup: Windows 11, AMD Radeon RX 6700 XT, Adrenalin 26.10.1, AMD FSR 4.1.2, Hyrule Field (child), 2560×1440 output, FSR 4 Performance 50% (1280×720), V-Sync Off, Frame Generation Off, cap 1000 (
HOS_FPS_MAX=1000,RX_VK_PASS_TIMING=1,RX_VK_FRAME_TRACE=1,RX_VK_AUTO_TUNE=0), 3 interleaved 30 s steady-state pairs (A1/B1/A2/B2/A3/B3) queued viascripts/dev.py queue run --mode timingafter warming each side'scache/longshot_fsr4_pipelines.bin. Rebased onto currentmain @ fd7dc40dand updated with review soundness fixes; all 7 unrolled FSR 4.1.2 shaders emit the exact same validated SPIR-V word counts and passedspirv-val+ standalone RX 6700 XT SDR/HDR parity checks, so the GPU-time measurements still hold.afc4d1adfsr4 ffxDispatchGPU (median of 3 runs)4.542 / 4.560 / 4.417)3.661 / 3.771 / 3.699)23.33 / 23.96 / 24.00)22.62 / 24.80 / 23.14)22.73 / 22.57 / 23.26)21.84 / 23.61 / 22.33)31.70 / 38.69 / 31.03)29.57 / 48.05 / 30.72)42.86 / 41.74 / 41.66)44.20 / 40.33 / 43.22)31.54 / 25.84 / 32.23)33.82 / 20.81 / 32.55)ffxDispatch(720p → 1440p)postpass0.943 → 0.640 ms)ffxDispatch(720p → 1440p)postpass0.975 ms)postpass0.502 ms, bit-exact)Risks
for_each_idoperand-table check, non-escaping plain-access check,OpDecoratepreservation,OpSwitchwidth check, dominance and type-equality checks), and ifunroll_allleaves any loop rolled (left != 0) or exceedskUnrollWords(120,000), the pass stays on thearrays_to_buffer/ AMD fallback pipeline. Shaders larger thankCompactUnrollWords(60,000) still require the originalkBuildHeadroom(8 GiB) before cold compilation.RX_VK_FSR4_TUNE=0disables all FSR 4 shader tuning and runs AMD's shaders verbatim; a plain revert also restores the previous unroller cleanly.cache/longshot_fsr4_pipelines.binand rebuild in ~3.4 s total on a background thread (down from ~147 s), then save intocache/longshot_fsr4_pipelines.bin(~208 KB vs ~60 KB) for instant loads on subsequent starts. Saves andlongshot_options.iniare untouched.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (Windows changed-file subset & all FSR 4 checks passed locally; 3 baselinemainfailures named in Testing; full Linux suite 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.
Beanstalk test farm
Commit
cfd2544· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.@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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.