WIP: perf(vk): late readbacks on by default on the Steam Deck and handhelds #1725
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1725
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/readback-late-handhelds"
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?
Type: perf · Risk: low · Tested on: CachyOS Linux, RTX 3090 (unchanged there) · Needs: Steam Deck (the gain and the white-flash count), Intel and AMD integrated GPUs (whether they should get it too)
TL;DR
On a Steam Deck the game's reads of GPU results each waited for the GPU to finish the work that writes them, 2.4 to 4.9 ms a wait. #238 added a rule that reads the newest of them a frame late without waiting, as the console does when its GPU runs behind (24.3 → 30.1 fps on a Deck OLED), but left it off. This turns that rule on by default on the Steam Deck and the handhelds Steam runs as one. Desktop GPUs are unchanged: on an RTX 3090 those waits are 0.04-0.2 ms and the rule changed nothing measurable.
Breakdown
RX_VK_READBACK_LATE=newestinlongshot_env.txt), so players only had it if they found the playbook.DeviceFacts::handheld(): the Deck's own APU, or an integrated GPU withSteamDeck=1) getsnewest; every other PC gets no rule, as before.0is no rule).readback_late_newest=0and no rule is logged; a 2-round A/B of the rule forced on there gave mixed ±4-7% by area, within the PC's noise. The Deck's numbers are #238's.RX_VK_READBACK_LATE=0turns it off.Why
The game reads some GPU results back each frame (
nvnMemoryPoolInvalidateMappedRange), and a job thread waits for their write-back while the game's other threads poll. On the Deck that wait is milliseconds; #238 measured it and the rule that removes most of it, and the Steam Deck playbook tells players to set it. A default that is right for the device beats a line in a playbook.What changed
readback_late_newestingpu/vk/device_policy.h,f.handheld(), in the policy's log line; the device policy test's field lists (tests/test_device_policy.py: the Steam Deck fixture has it on).readback_late_wantedingpu/vk/vk_replay.cpptakes the device's default whenRX_VK_READBACK_LATEis unset, and logs where its rule came from.gpu/vk/readback_late.h,gpu/vk/switches.def's row,docs/development.md,docs/steam-deck-playbook.md(the line is no longer needed there).Measurements
Verdict: No change on an RTX 3090 (the rule stays off; forced on, within noise). The Deck's gain is #238's; the Test Farm's Deck run will confirm it on this build.
Hardware: CachyOS Linux (kernel 7.3.3), RTX 3090 24 GB, NVIDIA 620.70.06, Ryzen 9 7900X, 32 GB
Scene: Kokiri Forest, Hyrule Field (teleport), Castle Town Market (teleport): each 15 s standing, 5 s walking, 20 s walking with the camera turning; 2560x1440 DLSS Quality, Reflex on, uncapped; a private headless sway
Method: the rule forced on (
RX_VK_READBACK_LATE=newest) against none on one game folder (main09cbdd97with #1702's commits), a warm-up and 2 interleaved sessions each on the timing queue,RX_VK_LOG_READBACK_RANGES=1on both; fps from thevk: <n> presents, <fps> fpslinesHow to reproduce:
RX_VK_READBACK_LATE=newestagainstRX_VK_READBACK_LATE=0; the log'svk: readbacks of GPU results: <n> of 3000 waited for their write-back, <ms> ms eachlines.newestFlags and settings
RX_VK_READBACK_LATEneweston the Steam Deck and handhelds, none elsewhereTesting
Tested: CachyOS Linux, RTX 3090, NVIDIA 620.70.06: one session of this build over Kokiri Forest, Hyrule Field and the Market:
readback_late_newest=0in the policy line, no rule logged, no device loss; the A/B above. The renderer compiles (scripts/dev_build.py vk).Not tested: a Steam Deck on this build; integrated GPUs that are not handhelds.
mise run test: not run on this PC.Must be tested:
RX_VK_FRAMELOG) for one-frame white or dark pictures, expecting about +20% and no more flashes than main (Test Farm: @Beanstalk)Risks
What could break: a value the game reads a frame late where it needed this frame's (the exposure meter read late was the white flashes; #238's
newestrule was measured on the Deck without them).Turning it off:
RX_VK_READBACK_LATE=0.Compatibility: Nothing changes: no option, cache or API.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). Not run on this PC.third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened (tests/test_device_policy.py's field lists).🤖 Generated with Claude Code
https://claude.ai/code/session_016o1k1PazAdTJxQQWQBksW2
Tested in game: RTX 3090, NVIDIA 620.70.06, CachyOS Linux (headless sway), 2560x1440 DLSS Quality: one session of this build over Kokiri Forest, Hyrule Field and the Market: readback_late_newest=0 in the policy line (unchanged on a desktop GPU), no rule logged, no device loss; and a 2-round A/B of the rule forced on there, within noise. The Steam Deck, where it turns on, is for the Test Farm
@Beanstalk compare this PR with main on steamdeck (where the PR turns the rule on), and on windows+intel, linux+intel and an AMD integrated GPU with
RX_VK_READBACK_LATE=newestforced againstRX_VK_READBACK_LATE=0(whether integrated GPUs other than handhelds should get it): Kokiri Forest, Hyrule Field and the Market, standing and walking with the camera turning, the frame rate uncapped; fps, p99 frame time, the pictures against main, and the frame log (RX_VK_FRAMELOG) for one-frame white or dark picturesBeanstalk test farm
Commit
fec5333· tier reviewed · approved by HumanBean · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)The plan compares the PR with main on Steam Deck, Windows Intel, Linux Intel and an AMD integrated GPU; the Intel targets will wait for matching testers. It exercises standing and walking with camera movement in Kokiri Forest, Hyrule Field and the Market at an uncapped frame rate, measuring FPS and p99 frame time and comparing sampled pictures. It also compares forced newest and disabled readback rules on the PR; crashes, significant performance regressions or picture differences fail the plan. The requested frame log is unavailable to plans, so sampled pictures cannot reliably detect one-frame flashes. Each target takes roughly 35 minutes. No tester online now matches windows+intel, linux+intel: those targets wait for one.
0ornewest.kokiri-start(settings frame_rate_cap=6), then teleport to Kokiri Forest, take the picture forest to compare with main, measure forest-standing for 15 s (after 5 s warm-up), move the stick, take the picture forest-turned to compare with main, measure forest-turned for 10 s (after 0 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field-standing for 15 s (after 5 s warm-up), take the picture field-turned to compare with main, measure field-turned for 10 s (after 0 s warm-up), teleport to Market, take the picture market to compare with main, measure market-standing for 15 s (after 5 s warm-up), take the picture market-turned to compare with main, measure market-turned for 10 s (after 0 s warm-up); 1 run on each side.kokiri-start(settings frame_rate_cap=6), then teleport to Kokiri Forest, take the picture forest to compare with main, measure forest-standing for 15 s (after 5 s warm-up), move the stick, take the picture forest-turned to compare with main, measure forest-turned for 10 s (after 0 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field-standing for 15 s (after 5 s warm-up), take the picture field-turned to compare with main, measure field-turned for 10 s (after 0 s warm-up), teleport to Market, take the picture market to compare with main, measure market-standing for 15 s (after 5 s warm-up), take the picture market-turned to compare with main, measure market-turned for 10 s (after 0 s warm-up); 1 run on each side for each of 2 cells (2 game starts a run).Done (started 2026-11-19 08:43 UTC, last report 2026-11-19 14:58 UTC). Comment
@Beanstalkto run it again.AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99; 2: windows+amd+amd-proprietary+igpuAMD Radeon(TM) 880M Graphics, 2.0.416Run by hand on PCs that don't match their target (not counted toward it):
NVIDIA GeForce RTX 5070, 620.70.6)RX_VK_READBACK_LATE=0RX_VK_READBACK_LATE=0RX_VK_READBACK_LATE=0RX_VK_READBACK_LATE=0RX_VK_READBACK_LATE=newestRX_VK_READBACK_LATE=newestRX_VK_READBACK_LATE=newestRX_VK_READBACK_LATE=newestMeasurements · steamdeck
Verdict: fail on steamdeck (1/1 report):
default-policy screenshot.max_diff;forced-rules screenshot.max_diff;forced-rules field-turned.frametime_p99_ms.max_delta_pct (+28.8%)failed.Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMScene: default-policy, from the repository's save kokiri-start (frame_rate_cap=6); forced-rules, from the repository's save kokiri-start (frame_rate_cap=6); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); default-policy: 1 game start a side, forest-standing 15 s after 5 s warm-up, forest-turned 10 s after 0 s warm-up, field-standing 15 s after 5 s warm-up, field-turned 10 s after 0 s warm-up, market-standing 15 s after 5 s warm-up, market-turned 10 s after 0 s warm-up; forced-rules: 1 game start a side, forest-standing 15 s after 5 s warm-up, forest-turned 10 s after 0 s warm-up, field-standing 15 s after 5 s warm-up, field-turned 10 s after 0 s warm-up, market-standing 15 s after 5 s warm-up, market-turned 10 s after 0 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)c4e8e2efec5333RX_VK_READBACK_LATE=0· field-turned · frame rateRX_VK_READBACK_LATE=0· forest-turned · frame rateRX_VK_READBACK_LATE=0· market-turned · frame rateRX_VK_READBACK_LATE=0· field-standing · frame rateRX_VK_READBACK_LATE=0· forest-standing · frame rateRX_VK_READBACK_LATE=0· market-standing · frame rateRX_VK_READBACK_LATE=0· field-turned · frame time (p99) (ms)RX_VK_READBACK_LATE=0· forest-turned · frame time (p99) (ms)RX_VK_READBACK_LATE=0· market-turned · frame time (p99) (ms)RX_VK_READBACK_LATE=0· field-standing · frame time (p99) (ms)RX_VK_READBACK_LATE=0· forest-standing · frame time (p99) (ms)RX_VK_READBACK_LATE=0· market-standing · frame time (p99) (ms)RX_VK_READBACK_LATE=newest· field-turned · frame rateRX_VK_READBACK_LATE=newest· forest-turned · frame rateRX_VK_READBACK_LATE=newest· market-turned · frame rateRX_VK_READBACK_LATE=newest· field-standing · frame rateRX_VK_READBACK_LATE=newest· forest-standing · frame rateRX_VK_READBACK_LATE=newest· market-standing · frame rate(6 more rows on the dashboard)
Flags and settings
RX_VK_READBACK_LATE0,newestMarkdown for the PR description
Measurements · amd+igpu
Verdict: fail on amd+igpu (2/1 report):
default-policy screenshot.max_diff;forced-rules screenshot.max_diff;forced-rules forest-standing.frametime_p99_ms.max_delta_pct (+15.8%)failed.Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAM; 2: windows+amd+amd-proprietary+igpuAMD Radeon(TM) 880M Graphics, 2.0.416AMD Ryzen AI 9 365 w/ Radeon 880M, 32 GB RAMScene: default-policy, from the repository's save kokiri-start (frame_rate_cap=6); forced-rules, from the repository's save kokiri-start (frame_rate_cap=6); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); default-policy: 1 game start a side, forest-standing 15 s after 5 s warm-up, forest-turned 10 s after 0 s warm-up, field-standing 15 s after 5 s warm-up, field-turned 10 s after 0 s warm-up, market-standing 15 s after 5 s warm-up, market-turned 10 s after 0 s warm-up; forced-rules: 1 game start a side, forest-standing 15 s after 5 s warm-up, forest-turned 10 s after 0 s warm-up, field-standing 15 s after 5 s warm-up, field-turned 10 s after 0 s warm-up, market-standing 15 s after 5 s warm-up, market-turned 10 s after 0 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)c4e8e2efec5333RX_VK_READBACK_LATE=0· field-turned · frame rateRX_VK_READBACK_LATE=0· forest-turned · frame rateRX_VK_READBACK_LATE=0· market-turned · frame rateRX_VK_READBACK_LATE=0· field-standing · frame rateRX_VK_READBACK_LATE=0· forest-standing · frame rateRX_VK_READBACK_LATE=0· market-standing · frame rateRX_VK_READBACK_LATE=0· field-turned · frame time (p99) (ms)RX_VK_READBACK_LATE=0· forest-turned · frame time (p99) (ms)RX_VK_READBACK_LATE=0· market-turned · frame time (p99) (ms)RX_VK_READBACK_LATE=0· field-standing · frame time (p99) (ms)RX_VK_READBACK_LATE=0· forest-standing · frame time (p99) (ms)RX_VK_READBACK_LATE=0· market-standing · frame time (p99) (ms)RX_VK_READBACK_LATE=newest· forest-turned · frame rateRX_VK_READBACK_LATE=newest· forest-standing · frame rateRX_VK_READBACK_LATE=newest· field-turned · frame rateRX_VK_READBACK_LATE=newest· market-turned · frame rateRX_VK_READBACK_LATE=newest· field-standing · frame rateRX_VK_READBACK_LATE=newest· market-standing · frame rate(6 more rows on the dashboard)
Flags and settings
RX_VK_READBACK_LATE0,newestMarkdown for the PR description
I think turning it on for desktops would help as well: you won't see it much in mean fps, but in fewer hitches and long frames, so fewer frame dips.
Measured here: frames over 25 ms fell from 46-70 to 16-19 a Market visit. A mean fps or a mean wait cannot show that. Suggested check before leaving desktops out: the frames over 20 and 25 ms on the 3090, with and without the rule.
Setup: Windows 11, Ryzen 9 9900X, RTX 4070 SUPER, 3840x2160 output, DLSS Quality, 60 fps cap, Castle Town Market route (rc.7 with faster lifted code, 2026-11-17). With no rule, the job threads' reads of the 0x3980, 0x9b040, 0x8b040, 0x44b040 and 0x1b580 ranges came 8-11 ms into the frame and waited 2-11 ms in
invalidate()for the GPU; that wait was in about 80 % of the frames over 22 ms. WithRX_VK_READBACK_LATE=3980,9b040,8b040,44b040,1b580(everything else the same,RX_VK_FRAME_GATE=0on both sides), two runs against the base runs:It has been on in my everyday game since (with
RX_VK_FRAME_GATE=0), at least two hours of play: no flash or pop-in seen.3980alone changed nothing here (the wait moved to the next read).newestwas not tried on this PC.Why the mean hides it: this PC is not GPU-bound in that scene (the GPU needs about 11 ms a frame, the game's threads 12-14). A normal frame has 0.4 ms of readback wait in all, a long one 5.5-8 ms. The wait appears in the single frames where the render thread or the GPU is late (texture uploads, a heavy view) and the game's read comes before the write-back; the frame then has no time left to take it and runs over. Faster game code moves the read earlier in the frame, so the waits grow with it: the game's frame-end GPU wait was 0.3 ms a frame here before the lifted code got faster and 2.0 ms after.
The rule costs nothing in a frame without a wait, so the default could be wider than handhelds. The ranges the CPU reads and resets, like the exposure meter, keep their wait, as readback_late.h already says.
Follow-up: on this desktop it is the five sizes that help, not
newest. Withnewestas many readbacks wait as with no rule at all.Measured today on v3.0.0 as shipped (source 87cb36aa), same PC (Windows 11, Ryzen 9 9900X, RTX 4070 SUPER), 3840x2160 output, DLSS Quality, 90 fps cap, the Castle Town Market walking route (the second visit, 60 s),
RX_VK_FRAME_GATE=0in all three, one run each:RX_VK_READBACK_LATEnewest3980,9b040,8b040,44b040,1b580A fourth run with the five sizes and the frame gate on: 67.0 fps, 96 frames over 20 ms, 20 over 25 ms, 0 readbacks waited. So two runs with the sizes (90, 96 frames over 20 ms) against two without an effective rule (158, 176).
Why
newestfinds nothing here: it lets a read go only when the range's writer is the newest submission handed out (v >= f0ininvalidate). The count says the reads that wait on this PC have an earlier submission as their writer, one the GPU has not finished yet. The mean wait is 0.04 ms with or without it, as on the 3090, and the frames over 20 ms still nearly halve once those reads stop waiting.So
newestas a desktop default would change nothing here; a desktop default would need these ranges, or a rule that knows which ranges are plain results. The five sizes' safety on this PC rests on play only: over two hours in my everyday game, no flash or pop-in.Folded into #1763 (head
21b606e): on the Steam Deck and handhelds the unset default reads the newest submission's results late, on top of the culling camera block every PC reads late (device_policy.hreadback_late_newest). The Deck's flash check this PR still needed is in #1763's Still to test. Closing this one so there is a single PR.Pull request closed