fix(vk): jump directly to projected DRS stop on severe overload and damp bounce ping-pong across GPUs #3095
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!3095
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:fix/vk-drs-responsiveness"
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) is enabled and the GPU is heavily overloaded (for example, entering Market or Hyrule Field at
100% render scale), render resolution jumps directly to the stop that fits the GPU budget in ~2 s instead of crawling down one stop every ~3 s across 6 steps (~16–19 s), and stops ping-ponging between adjacent stops (such as75% <-> 83%) without ever permanently locking out resolution recovery.resolution=0) when transitioning from light to heavy scenes or hovering near a stop boundary.100%,67%,50%), scenes already at the DRS floor (50%/42%/33%), or CPU-bound scenes.Root Cause & Fix (
gpu/vk/drs.h,mkwvk::drs::updatecalled bymenu_drs_tick()atgpu/vk/vk_menu.cpp:1251)mkwvk::drs::updatepreviously waitedkStepDownWindows = 3(~3 s) and dropped only one stop (stops[idx - 1]) regardless of how far GPU time exceeded budget. Using a sharedproject_gpu_ms()helper (0.35 + 0.65 * scale^2, guarded forcur_pct <= 0),updatenow trackssevere_windows(consecutive windows>= 1.25 * budget) andsustained_gpu_ms(minimum GPU time across the consecutive overload streak):over_windows >= 3 || severe_windows >= 2(preserving 1-window spike immunity even after a mild window, and keeping 3 windows when Auto Frame Generation is active soAutoGuardsheds excess FG passes first).sustained_gpu_ms >= 1.25 * budget, jumps directly to the highest stop whose projected GPU time fits<= 0.96 * budget(or the floor if none), while mild overloads (< 1.25 * budget) continue dropping 1 stop.75% <-> 83%): Addsbounce_stop_id,calm_windows, andlast_budget_mswithreset_hysteresis():kBounceHeadroomStep(0.06,62%/79%projected) margin only whilecur_id == bounce_stop_id, while keeping cooldown backoff up tobounce_level == 2(40windows).bounce_levelafterkBounceDecayWindows(80) calm post-cooldown windows, clears bounce on a further step-down to a lower stop, and resets hysteresis whenever the frame budget changes by> 0.05 ms(e.g. changing FPS cap60 -> 30).Testing
Tested: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (RDNA 3.5 iGPU, Adrenalin 26.10.1), windowed
1920x1080, FSR 3.1, Auto DRS (50%floor),60 FPScap (16.7 msbudget),n=4interleaved ABBA runs per scene onforge/main6318f4056(+ local 1-line Windows builder compile fix forsandbox_windows.rs:1654note_linesoutside this PR).Auto,50%floor),1920x1080(100% render scalestart),60 FPScap.Market_ChildorHyruleField_Adultand inspectvk: drs:transitions inlongshot_log.txt.tests/test_drs.py): Commitbc910b5dcadds 7 cases (severe 2-window jump, mild+severe spike immunity,1.16x1-stop hold, Auto FG 3-window vs Fixed FG 2-window,75% <-> 83%ping-pong damping,bounce_level == 2recovery in a60%scene, and60 -> 30 FPScap budget reset); all 7 fail onforge/main(6318f4056), and405/405checks pass with25e7988d5.72a0bc8d4+#3095+#3096combined, Radeon 860M,1920x1080, FSR 3.1,AutoFG +AutoDRS across60/40/30 FPScaps and33%/50%floors):17live Auto DRS transitions with075% <-> 83%ping-pong oscillations,0DEVICE_LOST, and0in-play shader waits —60 FPS(16.7 msbudget) jumped straight100% -> 33%/100% -> 50%in 1 step;40 FPS(25.0 msbudget) jumped100% -> 67%and67% -> 50%;30 FPS(33.3 msbudget) stepped smoothly under mild< 1.25xload (32.3–36.3 ms).forge/main08a57248f(ddb2cd013;gpu/vk/drs.huntouched between6318f4056..08a57248f);tests/test_drs.pypassed405/405checks (fsr3fi: 71/71), andpython -I -B tests/run_all.py --changed forge/main --strictpassed (7 passed, 0 failed, 3 skipped[Linux-onlycmake/spirv-val]). 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:
DLSS+Auto DRS+Auto FGon Windows/Linux) (@Beanstalk/ by hand)30/45FPS cap) (@Beanstalk/ by hand)Measurements
Verdict: Yes — cuts
100% render scale -> 50% render scaleoverload convergence from6steps to2steps, liftsMarket_Childmedian FPS+9.7%/ 1% low+5.3%, and liftsHyruleField_Adult1% low+13.6%(>50 msspikes-58%) acrossn=4interleaved ABBA warm runs.Setup: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (Adrenalin 26.10.1), windowed
1920x1080, FSR 3.1, Auto DRS (100% render scalestart,50% render scalefloor),60 FPScap (16.7 msbudget),n=4interleaved ABBA warm runs per variant (M P2 P3 P3 P2 Mx2).Where it makes a difference:
6318f405625e7988d5100% render scale -> 50% render scale(Market/Hyrule)Market_Childmedian FPSMarket_Childmedian 1% lowMarket_Childmedian p99 frame timeHyruleField_Adultmedian 1% lowHyruleField_Adultmedian p99 frame timeHyruleField_Adultmedian>50 msspikesdispatchvk: slow submit(Market/Hyrule)Where it does NOT make a difference (within run-to-run variance):
6318f405625e7988d5HyruleField_Adultmedian FPSMarket_Childmedian max frame timeRisks
project_gpu_ms()assumes35%fixed +65%pixel-rate GPU cost; scenes with higher fixed geometry/compute share may still need a follow-up 1-stop step-down (as seen inMarket_Child:100% -> 58% -> 50%), while pure fill-rate scenes may step slightly below optimal and recover after cooldown.#3096(45d1863b2, which eliminates FSR 3.1 internal image reallocations on DRS steps); standalonemainABBA numbers below were measured on6318f4056before#3096merged.RX_VK_DRS=0disables Auto DRS; revertinggpu/vk/drs.hrestores previous single-stop behavior with no save/settings/cache impact.Checklist
Ready for review
main(08a57248f, headddb2cd013); the title is a Conventional Commit.mise run testpasses (tests/run_all.py --changed forge/main --strict:7 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_drs.py, commitbc910b5dc).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: 6 steps -> 1 step, Market +13.5% Mean / +50.3% 1% low
c9a3b5b41625e7988d5625e7988d56ddb2cd0131WIP: fix(vk): jump directly to projected DRS stop on severe overload and damp bounce ping-pong across GPUsto fix(vk): jump directly to projected DRS stop on severe overload and damp bounce ping-pong across GPUsRecommendation: Request changes. Bounce damping can permanently hold resolution below a recoverable stop after the cooldown backoff has decayed. The measured Radeon 860M runs show faster overload convergence, but the affected Tier 1 systems still need testing.
Auto DRS drops multiple resolution stops during sustained severe GPU overload and adds bounce damping. This improves convergence in the reported runs, at the cost of more controller state and a possible persistent loss of image resolution.
Blocking (1): must change before merging.
gpu/vk/drs.h:336: Decay reduces bounce_level but never clears bounce_stop_id, so the extra headroom requirement can remain indefinitely after the backoff has faded. (more on the line) Do: Expire or otherwise relax the stop's headroom restriction after a bounded calm period, and test recovery at a load between the old and tightened thresholds.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/drs.h:297: The new projected jump and recovery policy needs a live NVIDIA RTX check on Windows and Linux, including DLSS and Auto frame generation. (more on the line) Do: Run representative heavy-to-light transitions on Tier 1 NVIDIA hardware on both operating systems, recording resolution transitions, frame pacing and recovery against the base.gpu/vk/drs.h:297: The changed policy also needs the stated discrete AMD and Steam Deck runs. (more on the line) Do: Run severe transitions and recovery on Tier 1 AMD Windows and Linux RADV systems and Steam Deck, recording resolution, frame pacing and recovery against the base.@fixcan do L1.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the reported Radeon 860M: four interleaved runs per variant show Market median FPS up 9.7% and 1% low up 5.3%, and Hyrule Field 1% low up 13.6%. The comparison used earlier commits rather than the current base and head; broader hardware behavior remains unverified.
Other systems: The controller also affects DLSS, FSR, XeSS and the game's own upscaler, fixed and Auto frame generation, V-Sync modes, Windows, Linux and Steam Deck. The supplied live runs cover Windows Radeon 860M with FSR 3.1; the deterministic tests exercise controller inputs but cannot establish visual quality, frame pacing or GPU-specific behavior.
Switches: No switches added, changed or removed. Existing RX_VK_DRS defaults to enabled and disables Auto DRS when set to 0.
Reviewed:
ddb2cd0131against08a57248f6: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the diff, commits, gpu/vk/drs.h and tests/test_drs.py; inspected the menu and replay callers and their locking. The named docs/review-checklist.md and adjacent Tooling/AGENTS.md were absent. No generated files or translations changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, scripts or tests were run. The supplied CI checks are still running.
Overlaps and merge order: None identified; the description says complementary PR #3096 is already merged.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as Jer9 took it out of WIP. Nothing was run; a maintainer decides.
@ -248,0 +294,4 @@const bool fast = !(s.framegen_active && s.fg_fixed_mult == 0) && st.severe_windows >= kSevereStepDownWindows;if (++st.over_windows >= kStepDownWindows || fast) {int next_idx = idx - 1;if (st.sustained_gpu_ms >= kSevereOverloadGpuShare * budget) {L2 (should fix): The new projected jump and recovery policy needs a live NVIDIA RTX check on Windows and Linux, including DLSS and Auto frame generation.
When: A severe transition can now skip multiple DLSS stops, and the fixed 35%/65% projection can choose a lower resolution than necessary; the supplied live results cover only a Radeon 860M with FSR 3.1.
Do: Run representative heavy-to-light transitions on Tier 1 NVIDIA hardware on both operating systems, recording resolution transitions, frame pacing and recovery against the base.
L3 (should fix): The changed policy also needs the stated discrete AMD and Steam Deck runs.
When: Auto DRS can skip multiple stops on RX 6000–9000 GPUs and Steam Deck, including at the Deck's 30 and 45 FPS caps; the reported iGPU run does not cover those drivers or workloads.
Do: Run severe transitions and recovery on Tier 1 AMD Windows and Linux RADV systems and Steam Deck, recording resolution, frame pacing and recovery against the base.
@ -265,0 +333,4 @@st.severe_windows = 0;st.sustained_gpu_ms = 0.0f;// (the cooldown's backoff fades after a long calm stretch, so two old bounces never outlast the scene that caused them)if (!cooling && st.bounce_level > 0 && ++st.calm_windows >= kBounceDecayWindows) {L1 (blocking): Decay reduces bounce_level but never clears bounce_stop_id, so the extra headroom requirement can remain indefinitely after the backoff has faded.
When: After a bounce to 75%, a scene at 65% of budget satisfies the old 68% step-up threshold but not the new 62% threshold. Even after 80 calm windows reduce bounce_level to zero, bounce_stop_id still matches 75%, so it stays there indefinitely unless the workload becomes lighter, the budget changes or the controller resets.
Do: Expire or otherwise relax the stop's headroom restriction after a bounded calm period, and test recovery at a load between the old and tightened thresholds.
Addressed L1 in
9b3ef63aa:gpu/vk/drs.h): Whencalm_windowsdecaysst.bounce_leveldown to0,st.bounce_stop_idis now cleared (if (st.bounce_level == 0) st.bounce_stop_id = 0;) so the normal68%/85%step-up thresholds resume after a bounded calm period instead of staying tightened indefinitely.tests/test_drs.py): Added a game-free reproduction case intest_bounce_damping_recovers_and_resets()(bounces at75%, holds at65%of budget between the62%tightened and68%normal thresholds, verifies it stays damped through cooldown + calm decay, then clearsbounce_stop_idand recovers to83%). Verified the new assertions failed before9b3ef63aaand pass with it (drs controller: 510 checks, 0 failures;tests/run_all.py --changed forge/main --strict:6 passed, 3 skipped[Linux-onlycmake/spirv-val], withtest_drs.pyrun directly via--cxxand--headers).@Beanstalk Please run Tier 1 live comparisons of this branch against
mainfor L2 and L3:@Jer9 only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@review
Recommendation: Approve. The code is ready: only testing is left. The bounce margin now clears when its backoff decays, and the reported Radeon 860M measurements show faster overload convergence. The requested NVIDIA, discrete AMD and Steam Deck live runs are still outstanding. Recommend approval; not approved on the forge.
Auto DRS can jump down several resolution stops under sustained severe GPU load and damp repeated bouncing, with the bounce margin now expiring after calm play. The policy adds state and relies on an estimated GPU cost model.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/drs.h:297: The new projected jump and recovery policy needs a live NVIDIA RTX check on Windows and Linux, including DLSS and Auto frame generation. When: A severe transition can now skip multiple DLSS stops, and the fixed 35%/65% projection can choose a lower resolution than necessary; the supplied live results cover only a Radeon 860M with FSR 3.1. Do: Run representative heavy-to-light transitions on Tier 1 NVIDIA hardware on both operating systems, recording resolution transitions, frame pacing and recovery against the base.gpu/vk/drs.h:297: The changed policy also needs the stated discrete AMD and Steam Deck runs. When: Auto DRS can skip multiple stops on RX 6000–9000 GPUs and Steam Deck, including at the Deck's 30 and 45 FPS caps; the reported iGPU run does not cover those drivers or workloads. Do: Run severe transitions and recovery on Tier 1 AMD Windows and Linux RADV systems and Steam Deck, recording resolution, frame pacing and recovery against the base.Since the last review (on
ddb2cd0131)Resolved: L1 (Decay reduces bounce_level but never clears bounce_stop_id, so the extra headroom requirem…)
Still open: L2 (The new projected jump and recovery policy needs a live NVIDIA RTX check on Windows and Li…); L3 (The changed policy also needs the stated discrete AMD and Steam Deck runs.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Radeon 860M: the PR reports four interleaved warm runs per scene, with Market median FPS up 9.7% and 1% low up 5.3%, and Hyrule Field 1% low up 13.6%, against main. Other hardware remains untested.
Other systems: The controller affects Auto DRS across upscalers, frame-generation modes and supported platforms. The reported live runs cover Windows with Radeon 860M and FSR 3.1; NVIDIA RTX, discrete AMD and Steam Deck coverage remains outstanding.
Switches: No switches added, changed or removed. The existing RX_VK_DRS switch defaults to enabled and can disable Auto DRS.
Reviewed:
9b3ef63aa9against08a57248f6: Reviewed the PR diff and the changed controller and test logic; the full test file and repository rules output were truncated, so their complete contents were not verified.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports 510 controller checks passing on the fixed head; CI is still running.
Overlaps and merge order: The description identifies merged PR #3096 as complementary.
Automated code review by BeanBot (gpt-6.1-terra), asked for by Jer9. Nothing was run; a maintainer decides.