perf(vk): lift Auto-resolution native FPS 13-23% (+10-19% 1% low, -16-20% GPU) and cut FSR3 FI resize spikes 29% on GPU-limited GPUs via framegen-aware DRS #2400
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!2400
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:feat/vk-fg-aware-drs"
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
When
Render resolutionwas set toAuto(opts.resolution = 0),menu_auto_tune()exited early and the renderer relied solely on the game's own internal dynamic resolution (tuned for Switch 2 hardware, not PC upscaler or frame-generation budgets). In GPU-heavy scenes like Market and Hyrule Field on an integrated GPU, the game remained at 75% (1200x750) even when AMD FSR 3.1 + 2x Frame Generation drove GPU time to 29–30 ms per frame (~30 FPS native, 1% lows below 26 FPS). Furthermore, when render resolution changed mid-play while AMD FSR 3.1 Frame Generation was active,gpu/vk/vk_fsr3fi.cpptore down and reallocated all ~30+ internal resources—including ~25 display-sized optical-flow, luminance, andmade[]images that depend solely on display dimensions—triggering frame spikes of +83.5 ms (126.3 ms peak).This pull request introduces continuous, framegen-aware host Dynamic Resolution Scaling (DRS) and decouples render-sized scratch images from display-sized resources in
vk_fsr3fi.cpp:gpu/vk/drs.h,gpu/vk/switches.def: RX_VK_DRS): Evaluates native frame time, total GPU time (including upscaler and FG passes), and scene draw counts over rolling ~1-second presentation windows. When GPU utilization is heavy (GPU time > 92% of budget and native FPS < 90% of target for 3 consecutive windows), the controller smoothly steps down 1 quality stop across the active upscaler's defined scale stops (clamped to a 50% floor). A CPU-bound guard prevents downscaling when GPU utilization is low (< 75%), preserving sharpness in draw-call-heavy scenes. Recovery back up requires 10 windows of post-step-down cooldown and 10 windows of clear GPU headroom (< 68% budget and projected headroom at the next stop, allowing CPU-bound iGPUs starting at 67% to recover upward), with exponential cooldown backoff (10 -> 20 -> 40 windows) preventing seesawing.gpu/vk/vk_fsr3fi.cpp): Separates internal resources into 25 display-sized images (of_luma,of_flow,of_vector,of_confidence,of_scd_*,fi_inpainting_pyramid,fi_previous_source,fi_distortion_field, andmade[]) and 9 render-sized per-frame scratch images (fi_dilated_depth,fi_dilated_motion_vectors,fi_reconstructed_depth_*,fi_game_mv_*,fi_of_mv_*,fi_disocclusion_mask). When render resolution changes mid-play, only the 9 render-sized scratch images are reallocated; all 25 display-sized images and optical-flow allocations are preserved (whilevk_fsr3_inputs.cppstill cleanly signals a 1-frame reset).RX_VK_DRS=1andopts.resolution == 0. Operates across all upscalers (FSR 3.1, DLSS, FSR 4, XeSS, Game's own) and presets without mutating savedopts.resolution(0) inlongshot_options.ini. SettingRX_VK_DRS=0completely disables the controller and restores exact previous behavior.What a player notices:
Render resolutionset toAuto, gameplay in demanding scenes stays smooth and responsive: native frame rates increase by +13% to +23% (+10% to +19% 1% lows) and GPU frame times drop by 4.7–5.8 ms (-16% to -20%).Helps:
Render resolution = Auto.No measurable impact:
opts.resolution != 0, e.g. Quality 67% or Native 100%).RX_VK_DRS=0.Files to read first:
gpu/vk/drs.h: themkwvk::drs::State/drs::update()state machine, budget calculation, and hysteresis logic.gpu/vk/vk_fsr3fi.cpp: split allocation ofdisplay_images()vsrender_images().gpu/vk/vk_replay.cpp: integration withlog_frame_stats().gpu/vk/vk_menu.cpp:menu_drs_tick(),menu_drs_enabled(), and atomic scale propagation.tests/test_drs.py: deterministic unit tests covering step-down, hysteresis, FIFO+FG budgets, and FSR3 FI resource decoupling.Testing
Tested:
market-entrance): walked straight forward ~5 s (0:LUP/5000) to the central fountain before panning, 1600x1000 windowed @ 120 Hz, FSR 3.1 (dlss=3),resolution=0(Auto),preset=0(Custom),RX_VK_PRECOMPILE=1:frame_rate_cap=6,frame_generation=2): 3 interleaved rounds. DRS stepped 67% -> 58% -> 50% smoothly; native FPS lifted from 30.79 to 37.83 (+22.9%), 1% low lifted from 26.58 to 31.54 (+18.7%), GPU time dropped from 29.1 ms to 23.3 ms (-19.9%), and display latency dropped from 37.1 ms to 29.5 ms (-20.5%).frame_rate_cap=0,frame_generation=0): 3 interleaved rounds. DRS stepped 67% -> 58% -> 50%; native FPS lifted from 38.66 to 44.15 (+14.2%), 1% low lifted from 33.66 to 37.11 (+10.2%), and GPU time dropped from 20.0 ms to 16.8 ms (-16.0%).castle-gate): 1600x1000 windowed @ 120 Hz, FSR 3.1,resolution=0(Auto), 2x FSR 3.1 FG Uncapped:50% -> 67% -> 100% -> 67% -> 50%vialongshot_ctl.py. On the largest step (67% -> 100%), spike dropped from +83.5 ms down to +59.7 ms (-28.6% spike, -25.1 ms peak frame time), confirming decoupled display and optical-flow resources.RX_VK_DRS=0triggers 0 DRS transitions and matchesmainperformance; verified fixed 67% render scale (resolution=3) shows zero regression.27/27--stricttargeted tests PASS. Verified fulltests/run_all.pyon Windows (888 passed, 29 pre-existing baseline failures that also fail on cleanmain—test_auto_handheld,test_pads_after_menu,test_build_long_paths,test_dev_*,test_linux_preflight,test_perf_report,test_crash_dialog, etc. — 60 skipped in 374 s), with 0 regressions. Cleanly rebased onto currentforge/main(79d192c6, head62aad09e).How to test:
Upscaler = AMD FSR 3.1,Render resolution = Auto(resolution=0),Quality preset = Custom, andFrame generation = 2x(FSR 3.1 FG) orOff(60 FPScap).market-entrance, walk straight forward ~5 s (0:LUP/5000) to the central fountain before panning (and testcastle-gatein Hyrule Field). Watchlongshot_log.txtfor smoothvk: drs: 67% -> 58% -> 50%transitions with zero seesaw, and confirmvk: fsr3fi: render inputs ... (keeping ... display & optical-flow images)on mid-play resolution steps.RX_VK_DRS=0to confirm0vk: drs:transitions and exactmainbehavior.Still to test:
Measurements
Verdict: Cuts GPU time by 15.8–19.9% (-4.7 to 5.8 ms), lifts native FPS by +13.3% to +22.9% (+10.2% to +18.7% 1% low), and cuts FSR 3.1 FI resize spikes by -28.6% (-25.1 ms) on GPU-limited hardware.
Setup: Windows 11 (build 26200), AMD Ryzen AI 7 350, AMD Radeon 860M (6 GB VRAM), Adrenalin 26.10.1 (LLPC); 1600x1000 windowed @ 120 Hz, AMD FSR 3.1 (
dlss=3),RX_VK_PRECOMPILE=1, clean warm cache reset per trial, 3 interleaved rounds per scenario (>= 12.5 spost-load settle). Measured onforge/main @ 958b71f9vs1b6e234c; cleanly rebased onto currentforge/main @ 79d192c6(head62aad09e), where none of the intervening commits touchdrs.h,vk_fsr3fi.cpp, orvk_menu.cpp, so the standalone measurements hold unchanged.Where it makes a difference
958b71f9cap=6,1600x1000 @ 120 Hz, Auto resolution):cap=6,1600x1000 @ 120 Hz, Auto resolution):cap=0,1600x1000 @ 120 Hz, Auto resolution):67% render scale -> 100% render scale, Market):Where it does NOT make a difference (within run-to-run variance)
958b71f9RX_VK_DRS=0, 2x FG, Auto resolution:resolution=3):Raw log excerpts:
main(958b71f9) Market 2x FSR 3.1 FG Uncapped:this PR(1b6e234c) Market 2x FSR 3.1 FG Uncapped:this PR(1b6e234c) Mid-Play FSR 3.1 FG 2x Resize:Risks
longshot_options.inischema churn:opts.resolution == 0(Auto) is preserved and the active(upscaler, effective_resolution_id)pair is published in a synchronized runtime atomic (drs_snapshot), ensuring existing player configuration files remain 100% compatible.RX_VK_DRS=0completely disables the dynamic resolution controller, bypassing the tick loop and restoring exactmainbehavior.MKWVK_API_VERSION = 45unchanged.vk_framegen.cpp). Only 2 trivial contextual lines with PR #2383 (docs/user/graphics-and-controls.mdandgpu/vk/vk_menu.cpp:1288), which rebase cleanly on adjacent lines.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.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 Radeon 860M (1600x1000 @ 120 Hz, AMD FSR 3.1, RX_VK_PRECOMPILE=1): 3-round interleaved Market/Hyrule Auto-res + 2x FSR 3.1 FG & Market 60 FPS cap FG Off A/Bs + mid-play FSR3 FI resize spike check + RX_VK_DRS=0 bypass + fixed 67% no-regression check
@Beanstalk Please test Render resolution: Auto with Frame generation 2x and Off on Linux AMD RADV, Steam Deck, and Windows NVIDIA RTX 40/50 (DLSS / DLSS-G) to confirm smooth DRS step-down on GPU-limited hardware, zero throttling on high-headroom GPUs, and clean FSR 3.1 FI mid-play resizes.
@Jer9 only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@review
Beanstalk test farm
Commit
ccf3e1c· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Recommendation: Request changes. Auto resolution can permanently reduce image quality on CPU-bound integrated GPUs, and the controller uses the wrong target for high frame-rate caps. Its new cross-thread option reads also need synchronization.
The change adds host-controlled dynamic resolution and retains display-sized FSR 3.1 frame-generation resources during render-size changes. It can improve frame rate and resize spikes on the tested Radeon 860M, at the cost of lower render resolution and additional controller and resource-lifetime complexity.
Blocking (3): must change before merging.
gpu/vk/drs.h:122: Auto starts every integrated GPU at 67% before establishing that it needs a reduction, and a CPU-bound scene may never recover that quality. (more on the line) Do: Start from the existing Auto scale, or allow recovery when GPU headroom is sufficient even if the CPU cannot reach the target; add a CPU-bound recovery test.gpu/vk/drs.h:141: The target calculation discards frame-rate caps above 60 and clamps to display refresh even when V-Sync is off. (more on the line) Do: Use the actual selected cap and apply the display ceiling only when the active presentation mode imposes it; cover high caps and V-Sync-off refresh rates in the controller tests.gpu/vk/vk_menu.cpp:4442: The atomic runtime stop does not protect the saved resolution and upscaler values read alongside it from another thread. (more on the line) Do: Publish the saved resolution, upscaler and effective stop as a synchronized snapshot, or protect all of these reads and writes with the same lock.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Default RX_VK_DRS off until the affected paths have been validated.)@fixcan do L1, L2, L3 and L4.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven on the requested base and head. Three interleaved runs on an earlier base and PR commit reported 13.3–22.9% higher native FPS and 10.2–18.7% higher 1% lows in GPU-limited scenes, plus a 25.1 ms lower resize peak. The current head was not measured against its merge base, and the visual-quality cost was not shown.
Other systems: The controller affects Auto resolution with every upscaler on Windows and Linux; the FSR 3.1 resource change also affects fixed-resolution users who resize during frame generation. The reported game runs cover Windows Radeon 860M only. Linux RADV and Steam Deck, NVIDIA DLSS/DLSS-G, other upscalers, and live menu switching remain unverified.
Switches: RX_VK_DRS is added, default on; 0 restores the prior Auto controller, while a nonempty HOS_RES_SCALE also disables host DRS. The default is not yet appropriate for all users because it can lower quality even when the GPU has headroom. The switch table and user documentation are updated.
Reviewed:
62aad09e46against79d192c655: Read the requested repository rules, PR template, standards, commit trailers, changed controller, integration and FSR resource changes, the new test harness, and surrounding callers and state. Reviewed the remaining changed test stubs and documentation diff. The large renderer files and existing test files were read around the affected paths rather than in full; recorded runs were reviewed from the PR description and comments. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code, scripts, builds or tests were run, as requested. The author reports Windows game runs and targeted and full test runs; the listed CI checks are still running.
Overlaps and merge order: The description reports no overlap with #2369 and contextual overlap with #2383; independent Forgejo verification was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +119,4 @@/// Starting DRS stop for `upscaler`: 67% on integrated GPUs (smooth out of the box), top stop on discrete GPUs/// (100% for Game's own / FSR 3.1 / Off, 92% for DLSS / FSR 4 / XeSS).inline int initial_stop(int upscaler, bool integrated_gpu) {namespace ur = upscaler_rows;L1 (blocking): Auto starts every integrated GPU at 67% before establishing that it needs a reduction, and a CPU-bound scene may never recover that quality.
When: With Auto and an integrated GPU, a scene rendering at 50 FPS with 8 ms GPU time starts at 67%. The GPU has ample headroom, but step-up requires at least 57 FPS, so CPU-limited play stays at 67% indefinitely even where the previous game's dynamic resolution would render at 75%.
Do: Start from the existing Auto scale, or allow recovery when GPU headroom is sufficient even if the CPU cannot reach the target; add a CPU-bound recovery test.
@ -0,0 +138,4 @@/// 60 Hz display), FIFO caps native output to display_hz / fg_fixed_mult (30 FPS on 60 Hz @ 2x), so the native budget/// follows that physical ceiling instead of falsely treating 30 FPS as overload.inline float target_fps(int cap_fps, int display_hz, bool framegen_active,bool fifo_vsync = false, int fg_fixed_mult = 0) {L2 (blocking): The target calculation discards frame-rate caps above 60 and clamps to display refresh even when V-Sync is off.
When: At a 120 FPS cap on a 120 Hz display, a GPU-limited 70 FPS scene is compared with a 60 FPS target. It cannot satisfy the step-down FPS condition, so Auto remains at its initial scale rather than reducing resolution toward the selected cap. Likewise, an uncapped V-Sync-off game on a 30 Hz display targets only 30 FPS.
Do: Use the actual selected cap and apply the display ceiling only when the active presentation mode imposes it; cover high caps and V-Sync-off refresh rates in the controller tests.
@ -4420,0 +4439,4 @@drs_active_packed.store(0, std::memory_order_relaxed);}int effective_resolution() {const int saved = opts.resolution;L3 (blocking): The atomic runtime stop does not protect the saved resolution and upscaler values read alongside it from another thread.
When: The game thread calls the renderer option query while the menu or control thread changes the resolution or upscaler under menu_mu. effective_resolution reads opts.resolution and upscaler() without that lock while set_row writes those fields, producing a C++ data race and potentially pairing a stop with inconsistent settings.
Do: Publish the saved resolution, upscaler and effective stop as a synchronized snapshot, or protect all of these reads and writes with the same lock.
@Beanstalk
Addressed BeanBot review findings L1, L2, and L3 in commit
72e4ea1432c8a4ad493c85b120570793172f63e7(also corrected theFiles to read firstand## Riskssymbol names in the PR description):Changes
L1 (
gpu/vk/drs.h:256-265) — CPU-bound iGPU recovery:s.native_fps >= kStepUpFpsShare * targetgate fromclear_headroomwhile keeping the67%iGPU starting stop and the< 75%budget CPU-bound step-down guard. CPU-limited scenes on integrated GPUs now recover quality stops cleanly whenever current (< 68%budget) and projected next-stop (< 85%budget) GPU headroom permit.tests/test_drs.pywithtest_cpu_bound_recovery()(67% -> 92%and67% -> 100%) without seesawing.## Measurements, where GPU load exceeds the step-down threshold.L2 (
gpu/vk/drs.h:140-150,gpu/vk/vk_menu.cpp:4830-4835) — High caps and FIFO V-Sync gating:drs::target_fps()now honors positive frame-rate caps above 60 (90,120,144, etc.), defaulting uncapped (0) to60.0f.display_hz(anddisplay_hz / fg_fixed_multfor fixed frame generation, usingframegen_now()so DLSS-G caps are respected) now applies only whenfifo_vsyncis active, sourced fromdev.swapchain(VK_PRESENT_MODE_FIFO_KHR/VK_PRESENT_MODE_FIFO_RELAXED_KHR, with!dev.swapchain && menu_vsync() == 1fallback).tests/test_drs.pyfor high caps (90,120,144),fifo_vsync == falsevstrue, and120 FPSdrs::update()step-down/step-up.L3 (
gpu/vk/vk_menu.cpp,gpu/vk/menu/preset.{h,cpp}) — Synchronized cross-thread resolution snapshot:opts.resolutionandupscaler()with a singlestd::atomic<uint32_t> drs_snapshot(kDrsSnapValid | (u << 8) | res), published viadrs_publish_snapshot()undermenu_muacross initialization, menu/preset/auto-tune writes,menu_drs_tick(), and rollbacks (the detachedprobe_upscalers_soon()thread sets an atomicdrs_probe_dirtyflag consumed onmenu_tick()rather than lockingmenu_mu).effective_resolution_auto()andeffective_resolution_scale()load this snapshot lock-free (RX_VK_DRS=0andHOS_RES_SCALEparity preserved).srccuttest fixtures (tests/test_crt_options.py,tests/test_framegen_preset.py,tests/test_upscaler_round_trip.py).Verification
python -I -B tests/run_all.py --strictacross all affected checks (test_drs,test_crt_options,test_framegen_preset,test_upscaler_round_trip,test_vk_braces,byte_compile_tracked): 6 passed, 0 failed, 0 skipped (all 15 PR-affected checks passed15/15under--strictbefore the final detached-probe/cap polish, with the 6 re-affected checks re-verified after).python -I -B tests/run_all.py --changed 79d192c6on Windows (prior to the final 6-check polish): 355 passed, 10 failed, 10 skipped (all 10 failures confirmed unrelated pre-existing Windows/mainchecks:test_crash_dialog,test_dev_ab,test_dev_packs,test_flat_map,test_input_movie,test_perf_report,test_pipeline_state_computes,test_sampler_admission,test_saveload_warm_cache,test_srccut).python -I scripts/dev.py vkon Windows (llvm-mingw): builds cleanly (longshot_vk.dll).Switch Default & Remaining Tier 1 Testing (L4)
67%),RX_VK_DRSremains default-on (1) per switch conventions (RX_VK_DRS=0restores prior Auto behavior). Non-blocking Tier 1 hardware validation items in L4 (Linux RADV, Steam Deck, and Windows NVIDIA) remain for Beanstalk Test Farm verification.72e4ea1432ccf3e1c956View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.