perf(vk): allocate FSR 3.1 internal images once at max_render_size across DRS steps on all GPUs #3096
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3096
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:perf/vk-fsr3-drs-max-render-size"
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
What a player notices: When Dynamic Resolution Scaling (Auto) changes render resolution under AMD FSR 3.1, gameplay no longer hitches from destroying and reallocating all 22 internal FSR 3.1 images (plus the temporal chain's
color/depth/motion/maskimages) on every step, and temporal upscaling history stays intact without a reset flash. When Dynamic Resolution is Off (fixed render scale), render-sized images allocate at the fixed size; the SPD scratch image also retains fewer mip levels than onmain.resolution=0).50%render scale, with render-sized internal images allocated at exactrw x rh. Scenes where DRS never changes scale and non-FSR 3.1 upscalers do not benefit from DRS reuse.Root Cause & Fix (
gpu/vk/vk_fsr3.cpp,gpu/vk/vk_fsr3.h)gpu/vk/vk_fsr3.cpp(prepare()andprepare_sizes()) previously required exactrender_width/render_heightequality, destroying and recreating all 22 internal Vulkan images, resettingg.first_evaluation = true/g.lut_uploaded = false/g.parity = 0, and returning2fromprepare_sizes()(resettingvk_temporal.cpphistory) on every DRS step — even though the vendored FidelityFX FSR 3.1 shaders already support dynamicrender_size <= max_render_sizeviak.max_render_sizeandk.previous_render_size. Likewise,chain_prepare()returnedrw, rhinstead ofmax_render_width, max_render_height, causingvk_temporal.cppto reallocates.color,s.depth, ands.motionon every step.dynamic_render_size()(opts.resolution == 0) andreusable()shared byprepare()andprepare_sizes().dynamic_render_size() == true): Allocate render-sized internal images once atmw = std::max(rw, uw),mh = std::max(rh, uh)(half-res atmw/2, mh/2), reuse them whilerw <= max_render_width && rh <= max_render_height(prepare_sizes()returns1, preserving history and Lanczos LUT), and returnmax_render_width/heightfromchain_prepare()(matching DLSS/FSR 4/XeSS).dynamic_render_size() == false): Allocate render-sized images at exactrw x rhand requirerender == max == rw x rhto reuse. SwitchingAuto -> Fixedretires the larger images; they are freed after GPU use completes.k.max_render_size = {g.max_render_width, g.max_render_height}inupscale(), whilek.render_sizeuses currentrw, rhandk.previous_render_sizekeeps frameN-1'sg.previous_render_size(matching FSR 3.1'sClampUv(..., PreviousFrameRenderSize(), MaxRenderSize())).Testing
Tested on the earlier
d4d502613revision; the final changes have not been reported as tested: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (RDNA 3.5 iGPU, Adrenalin 26.10.1), windowed1920x1080, FSR 3.1, both Auto DRS (100% render scale -> 50% render scale,n=4interleaved ABBA runs) and Fixed50% render scale(960x540 -> 1920x1080,n=2ABBA VRAM check) onforge/main6318f4056(+ local 1-line Windows builder compile fix forsandbox_windows.rs:1654note_linesoutside this PR).Auto,50%floor) at1920x1080.Market_Child/HyruleField_Adultacross DRS steps and verify only 1vk: fsr3: ... (max 1920x1080)allocation and0dispatchvk: slow submitspikes inlongshot_log.txt.50% render scale) and verifyvk: fsr3: 960x540 -> 1920x1080 (max 960x540)(zero over-allocation).tests/test_fsr3_drs_resize.py): Commit183d19d9dchecks Auto DRS reuse (0allocs/drops,k.previous_render_size/k.max_render_size,frame_index), Fixed-scale1280x720sizing andAuto <-> Fixedreclaim/regrow,release()and OOM zeroing ofmax_render_*; fails onforge/main, passes133/133checks withd4d502613.python -I -B tests/run_all.py --changed forge/main --strictpassed19 passed, 0 failed(3Linux-onlycmake/spirv-valskips). Fulltests/run_all.py --strictbaseline on6318f4056ran (831 passed, 9 failed, 51 skipped— pre-existing Windows env/main failures:test_helpers_extract,test_longshot_builder,test_utf8_paths(CP_ACPathos_file_windows.c:645),test_run_all_junit,test_coverage_run,test_native_zstd,test_fsr4_tune,test_lifter,test_float_add_subgroup).Still to test:
RX_VK_MIRROR=1/RX_VK_ASYNC=1(@Beanstalk/ by hand)g.wave == false) (@Beanstalk/ by hand)Measurements
Verdict: Yes — cuts FSR 3.1 image allocations across 6 DRS steps from
7to1, eliminatesdispatchvk: slow submitspikes (1 -> 0), improvesHyruleField_Adult1% low+3.6%(>50 msspikes-45%), and confirms zero VRAM over-allocation at Fixed50% render scale.Setup: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (Adrenalin 26.10.1), windowed
1920x1080, FSR 3.1,60 FPScap,n=4interleaved ABBA warm runs for Auto DRS (100% render scale -> 50% render scale) andn=2ABBA runs for Fixed50% render scale(960x540 -> 1920x1080).Where it makes a difference:
6318f4056d4d502613vk: fsr3:image allocations (6 DRS steps)max 1920x1080)dispatchvk: slow submit(Market/Hyrule)HyruleField_Adultmedian 1% low (Auto DRS)HyruleField_Adultmedian p99 frame time (Auto DRS)HyruleField_Adultmedian>50 msspikes (Auto DRS)Where it does NOT make a difference (within run-to-run variance):
6318f4056d4d502613Market_Childmedian FPS (Auto DRS)Market_Childmedian 1% low (Auto DRS)HyruleField_Adultmedian FPS (Auto DRS)50% render scale(960x540) VRAM (Market)max 960x540)Risks
opts.resolution == 0) at a lower scale thanupscale_size, FSR 3.1's internal render-sized images and temporal chain inputs remain allocated atmax(rw, uw) x max(rh, uh)until the player switches to a fixed render scale or disables FSR 3.1 (which retires them for release after GPU use completes).RX_VK_FSR3_CHAIN=0(vk_fsr3_inputs.cpp) is a legacy fallback path and still reallocates its 3 input images on resize.gpu/vk/vk_fsr3.cppandgpu/vk/vk_fsr3.h; no save, settings, or shader-cache impact.Checklist
Ready for review
main(6318f4056); the title is a Conventional Commit.mise run testpasses (tests/run_all.py --changed forge/main --strict:19 passed, 0 failed; clean6318f4056baseline pre-existing Windows failures named in Testing).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here (tests/test_fsr3_drs_resize.py, commit183d19d9d).tests/that reads changed source is updated, not weakened.llvm-mingw) and Linux, with UTF-8 paths.Assisted-by:/Co-Authored-By:trailers on every commit.Ready to merge
docs/dev/standards.md, "Hardware tiers").main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11 Radeon 860M 1920x1080 FSR 3.1 Auto DRS: 7 allocs -> 1, 0 dispatch slow submits, Market +28.3% / Hyrule +45.9% 1% low
e38ccf38c8d4d502613a@review
Recommendation: Approve. The new Auto-resolution check races with settings updates, and switching from a fixed scale to Auto can still cause a reallocation and history reset on the next upward DRS step. The allocation reduction is demonstrated on one GPU, but the Auto-mode memory and clear-bandwidth costs and Tier 1 behavior remain unmeasured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change keeps FSR 3.1 images and temporal history across most Auto DRS steps, reducing allocation hitches. It trades those reallocations for larger resident images and full-image clears at reduced render scales.
Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_fsr3.cpp:419: This reads the mutable menu option without the lock used to update it. (more on the line) Do: Publish the selected Auto/fixed mode in a synchronized snapshot or read it under the same lock, and use one consistent value throughout preparation.gpu/vk/vk_fsr3.cpp:426: Entering Auto can reuse images made for a smaller fixed scale instead of allocating the Auto maximum. (more on the line) Do: When entering Auto, require the existing maximum to cover the intended Auto maximum, and update the transition test to require the allocation at the mode change.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_fsr3.cpp:456: The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. (more on the line) Do: Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device. (@fixdoes its part first: Clear only the active region where the Vulkan operation and shader requirements permit, or otherwise reduce the retained scratch allocation.)gpu/vk/vk_fsr3.cpp:571: The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. (more on the line) Do: Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.@fixcan do L1, L2 and L3.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for allocation churn on the tested Radeon 860M: the PR reports 7 allocations versus 1 over six DRS steps and a median Hyrule Field 1% low of 17.63 versus 18.26 FPS across four interleaved runs. The frame-rate gain's spread and the Auto-mode memory and bandwidth costs are not reported.
Other systems: The temporal chain, the legacy FSR 3.1 input path, reactive masks, wave-less shaders, and all GPUs running FSR 3.1 can use the changed state. The PR reports a Windows Radeon 860M run; NVIDIA, discrete AMD on Windows and Linux, Steam Deck, and the wave-less fallback remain untested.
Switches: No switches added, changed, or removed. Existing RX_VK_FSR3_CHAIN=0 retains its separate input allocations and resets history on resize.
Reviewed:
d4d502613aagainst6318f4056e: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the diff and commits, both changed renderer files and the new test, and the relevant temporal-chain, settings, input and FSR shader paths. Skimmed the remaining vendored shader code; docs/review-checklist.md and ../Tooling/AGENTS.md are absent. No recorded runs, translations or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code, tests, builds or project scripts were run. The supplied CI checks are still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -416,1 +417,3 @@/// The pipelines and the internal images for an evaluation at these sizes, made again when the sizes change/// Render resolution = Auto (opts.resolution == 0): the host's DRS or the game's own dynamic resolution steps the render/// size from frame to frame. Any other row is one fixed render sizebool dynamic_render_size() { return opts.resolution == 0; }L1 (should fix): This reads the mutable menu option without the lock used to update it.
When: While the render thread prepares an FSR frame, the game can apply a Render resolution change through menu_settings_apply; its applier writes opts.resolution under menu_mu, while this read holds no such lock. The concurrent plain read and write are a C++ data race.
Do: Publish the selected Auto/fixed mode in a synchronized snapshot or read it under the same lock, and use one consistent value throughout preparation.
@ -417,0 +423,4 @@/// leaving Auto gives back the video memory (and the clears) of the larger imagesbool reusable(uint32_t rw, uint32_t rh, uint32_t uw, uint32_t uh) {if (!g.output.image || g.upscale_width != uw || g.upscale_height != uh) return false;if (dynamic_render_size()) return rw <= g.max_render_width && rh <= g.max_render_height;L2 (should fix): Entering Auto can reuse images made for a smaller fixed scale instead of allocating the Auto maximum.
When: Switch from fixed 1280x720 to Auto while the current render size remains 1280x720: reusable returns true for the fixed-size images. A subsequent upward DRS step exceeds that maximum, recreates the images and resets history, producing the hitch and flash this change aims to avoid.
Do: When entering Auto, require the existing maximum to cover the intended Auto maximum, and update the transition test to require the allocation at the mode change.
@ -437,0 +453,4 @@}// (Auto: made as large as a dynamic-resolution step can reach, the output's size; a fixed render size: as it is)const uint32_t mw = dynamic_render_size() ? std::max(rw, uw) : rw, mh = dynamic_render_size() ? std::max(rh, uh) : rh;L3 (should fix): The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured.
When: At 50% render scale, render-sized images have four times the pixels of the base version, and previous_nearest_depth and the SPD mip chain are cleared over their full allocations every frame, including scenes where DRS never changes.
Do: Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device.
@ -543,3 +569,3 @@k.render_size[0] = rw, k.render_size[1] = rh;k.upscale_size[0] = uw, k.upscale_size[1] = uh;k.max_render_size[0] = rw, k.max_render_size[1] = rh;k.max_render_size[0] = (int32_t)g.max_render_width, k.max_render_size[1] = (int32_t)g.max_render_height;L4 (should fix): The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path.
When: Auto DRS now passes a larger maximum and retains history on every supported FSR 3.1 GPU; the supplied game run covers only Windows on a Radeon 860M.
Do: Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.
@fix
d4d502613ac1d14407deRecommendation: Approve. The code is ready: only testing is left. The change retains the DRS allocation reuse, but its memory and clear costs remain unmeasured and the affected Tier 1 systems have not been tested. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
c1d14407de. I rebased it ontomain(68fc871757). I edited its description to match the change.Changed
Changed in part (the rest is for the author)
Nothing was built or run: the checks run again on the new head.
FSR 3.1 keeps its internal images and temporal history across Auto DRS steps, avoiding repeated allocations. The tradeoff is larger retained images and potentially more clear bandwidth at reduced scales; the fix reduces the SPD scratch mip allocation.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_fsr3.cpp:456: The cost of keeping and clearing output-sized images at reduced Auto scales has not been measured. When: At 50% render scale, render-sized images have four times the pixels of the base version, and previous_nearest_depth and the SPD mip chain are cleared over their full allocations every frame, including scenes where DRS never changes. Do: Measure Auto-mode RAM, VRAM, frame times and lows against the base at a sustained reduced scale, including a memory-constrained device.gpu/vk/vk_fsr3.cpp:571: The changed image sizes and preserved history have not yet been exercised on the Tier 1 systems affected by this rendering path. When: Auto DRS now passes a larger maximum and retains history on every supported FSR 3.1 GPU; the supplied game run covers only Windows on a Radeon 860M. Do: Run Auto DRS transitions and inspect output and frame pacing on discrete NVIDIA and AMD on Windows and Linux, Steam Deck, and the wave-less fallback, as listed in the PR.Checks: they run again on this head; a failure shows on the pull request.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on the final revision. On the earlier tested revision, the reported Radeon 860M runs reduced allocations from 7 to 1 over six DRS steps and improved Hyrule Field median 1% low from 17.63 to 18.26 FPS across four interleaved runs.
Other systems: The Vulkan FSR 3.1 path affects Windows and Linux GPUs, including discrete NVIDIA and AMD hardware, Steam Deck, and the wave-less fallback. Those remaining Tier 1 configurations have no reported runs; the legacy input path still reallocates on resize.
Switches: None added, changed or removed.
Reviewed:
c1d14407deagainst68fc871757: Read the repository rules and pull request template, the fix diff and the FSR 3.1 allocation, preparation and evaluation paths; inspected the related menu locking and test changes. The supplied base-to-HEAD diff also includes many unrelated intervening changes, which were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. Measure retained VRAM and clear costs at reduced Auto scales, and exercise DRS transitions and history on the remaining affected Tier 1 systems.
Overlaps and merge order: Not established from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
WIP: perf(vk): allocate FSR 3.1 internal images once at max_render_size across DRS steps on all GPUsto perf(vk): allocate FSR 3.1 internal images once at max_render_size across DRS steps on all GPUsllun referenced this pull request2026-12-04 00:47:40 +00:00