perf(vk): render targets take a pooled image's memory by size, and the pool holds longer on integrated GPUs #1681
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!1681
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:vk-target-reuse-memory"
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
On a Steam Deck, turning the camera in Hyrule Field spends time asking the system for fresh memory for the game's shadow maps, which change size a little every frame, while a nearly identical one was just set aside. A render target of a size not seen before was always a new allocation (on the Deck, a kernel call that compacts memory and can swap), while the pool let go of a nearly matching image after 8 frames. This PR lets such a target take the memory of a pooled image it fits in (up to 1.5 times its size); on integrated GPUs the pool keeps its images 64 frames instead of 8 and makes these targets' memory a size class larger (at most a quarter more), so the next one fits; and a render target the pool's memory type cannot serve is made outside it. Discrete GPUs keep the 8-frame hold and get no size classes (only the take by size); the exact-match pool, its byte cap and its pressure rules, and standing fps do not change.
The result: on a Steam Deck OLED at Render 50% the turn runs about 1 fps faster with fewer long frames, as on a second Deck OLED (dukenheimer); at Render 100% six runs a side don't separate it from
main, and on a Steam Deck LCD (omgitsgela) no fps win was shown in any cell. It helps where the host, not the GPU, sets the frame rate, and is neutral elsewhere.Why: on a Steam Deck OLED in Hyrule Field with the camera panning, the replay thread spent about 3.2 ms a frame in VMA's block allocations (a kernel call that failed direct compaction about 29 times a second and pushed the game's memory to swap), and 92% of those were render targets made new after the pool's exact match missed. OoT sizes each nearby character's shadow map anew every frame, so its pool key never recurs, while an image of nearly the same size was just retired. The swap during turns was first reported in the Deck performance issue, #1477. Prior art: the pool's 8-present hold came from #1255, and the shadow maps' storage buckets from #1256. The tracker was searched for render targets, allocation, swap, compaction and turning stutter. Turning stutter in Hyrule Field on discrete NVIDIA cards (#1406, #1111) may share part of the cause, but there this PR only adds the take by size at the 8-frame hold, and it has not run on such a card: those issues are not claimed.
Read first:
create_imageputs a render target in the targets' VMA pool only when the pool's memory type is among the image'smemoryTypeBits(target_pool_takes,gpu/vk/vk_vma.cpp); VMA does not check this for a custom pool. The requirements come fromvkGetDeviceImageMemoryRequirements(Vulkan 1.3, loaded with the optional device functions), asked once a texture (ImageNeed,gpu/vk/vk_internal.h).pool_take_memory(gpu/vk/vk_texture.cpp), tried increateonly afterpool_takemisses: the fit rule istarget_pool::verdict(gpu/vk/target_pool.h): a usable, device-local memory type, an aligned offset, at least the size and at most 1.5 times it, only allocationscreate_imagetagged as the targets' blocks (VMA never makes dedicated memory there); the wait istakeable_by_size. The new image is bound withvmaCreateAliasingImage; the pooled image and its views are destroyed aspool_destroydoes (the pool holds only images whose GPU work completed). The image starts UNDEFINED and is cleared as a new one is; it is counted at its allocation's size.target_pool::idle_presents: 64 presents on an integrated GPU while the take is on, 8 otherwise;RX_VK_POOL_IDLEstill sets it.reused by sizeandmissed after their image was taken by size, and a second line every 600 presents,render targets not reused by size:, with each miss's reason (target_pool::Miss) and what the pool let go of over its bound and idle.=2, the default on integrated GPUs):target_pool::class_bytes,create_image_in_class(gpu/vk/vk_vma.cpp), and the pool's index by memory type and class (by_class,pool_unindex).tests/test_target_reuse_memory.py(new: rules compiled from the header;pool_take_memory,pool_take,pool_put,pool_trimcompiled from the source with stubs, the dead queue made unreadable to them);tests/test_target_image_pool.py(the memory-type check;create_image's new argument);tests/test_dead_targets_sweep.py(the hold's default);tests/test_target_image_reuse.py.RX_VK_TARGET_REUSE_MEMORYrow in the Memory table ofdocs/dev/reference/switches.md(main's revamp removeddocs/development.md, where it was); the rows ofRX_VK_TARGET_REUSE_MEMORYandRX_VK_POOL_IDLEingpu/vk/switches.def.See #1477
Testing
Tested: this PR's code at
540f552deon my Steam Deck OLED (the setup in Measurements): 30 runs at Render 50% and 100%, interleaved with main38990574a, all exiting normally with no error, validation or device-lost line in the log; the status line printed the level each arm asked for (2 by default, 1 and 0 when set). Pictures by eye at this code: the Field after the turn (Render 50%, R1 against main's C1) and Kokiri Forest standing (Render 100%, R3): nothing missing or misdrawn; the after-turn views differ only by where the camera stopped. Earlier builds of this change ran 23 more runs on the same Deck with the same result.Independently, on a second Steam Deck OLED, dukenheimer at
540f552d(#1681 (comment), #1681 (comment)): the turn faster, no R-only picture fault in 636 frames inspected at full resolution, 0 frames flagged by a per-present flash detector over every present, no crash, device loss or validation error (Measurements).On a Steam Deck LCD, omgitsgela ran this PR with the switch off against the default in one binary, in three areas (#1477, their comments of 2026-11-19 21:05 and 21:07). Their reading, which I agree with: no demonstrated fps win in any cell, and not proof of no effect. The one pair per cell that passed their scene-match gate: Hyrule Field median 39.93 ms with the default against 40.04 off (p99 -11.0 ms, 22 fewer frames over 50 ms, inside their A/A floor); Castle Town 43.64 against 42.42 (the default slightly behind); Kokiri gave no admitted pair.
The renderer built for Windows at the earlier rebased head:
RX_TARGET=windows RX_MARCH=x86-64-v3 RX_VK_ONLY=1 python3 -I nx2/build.py --standalonewith llvm-mingw 20261104 (UCRT): 213 files compiled, 0 failed,longshot_vk.dlllinked (PE32+ x86-64 DLL); on Linux the same renderer build with clang, 214 files, 0 failed,longshot_vk.solinked;tests/test_utf8_paths.pywithLONGSHOT_MINGWset passes (the probe built for Windows). At this head,gpu/vk/vk_texture.cppandgpu/vk/vk_vma.cppwith-fsyntax-onlyfor Linux (clang) and Windows (llvm-mingw): no errors, as on main068fb8ebe.Game-free on Linux x86-64, in the PC's job queue, at this head (
742b053aeon main068fb8ebe): the 116 checks that read its files (run_all.py --changed forge/main): 100 passed, 16 failed, 1 skipped (Windows-only), the 16 failing on main too; and the wholepython3 -I -B tests/run_all.py(not--strict) here and on main068fb8ebein the same environment: 73 fail on both (this PC's environment: missing tools and modules, timing). 12 more failed here in a run shared with two other full suites and each passed when run again alone (nx2/test_coop_spirv.py,nx2/test_default_point_size.py,nx2/test_draw_parameters.py,nx2/test_mesh_first_types.py,nx2/test_spirv_struct_identity.py,test_appimage_package_retry,test_fpx_sticky,test_mesh_fallback_layout,test_mesh_unreachable_outputs,test_pipeline_cache_file,test_pipeline_cache_save,test_pipeline_state_sources). The new checks fail at their test-only commits and pass here:tests/test_target_image_pool.pyat9ddf2389a(2 of 10 fail),tests/test_target_reuse_memory.pyat739fec485.The 73 checks that fail both here (
742b053ae) and on main068fb8ebenx2/test_nup_codec.py,nx2/test_nup_read_name.py,nx2/test_nup_stand_in.py,nx2/test_nup_verify.py,test_appimage_player_build,test_bug_report_defaults,test_capture_read_once,test_capture_readback_visibility,test_crash_dialog,test_crt_options,test_damage_debug_menu,test_dav1d_av1,test_dev_ab,test_dev_packs,test_discover,test_display_startup_failure,test_dlss_feature_size,test_draw_stream_visibility,test_failed_compile_keeps_objects,test_frame_overlap,test_fsr3fi_hud_layer,test_fsr_image_retirement,test_fsr_uniform_ownership,test_guest_imported,test_high_fps_fixes,test_host_guest_writes,test_hud_layout_row,test_insn_fixed_convert,test_libc_hooks,test_lift_cache,test_lift_lookups,test_linux_preflight,test_linux_pressure,test_linux_tools,test_linux_update,test_log_open_failure,test_make_game_cache,test_make_game_ngx,test_mise_build,test_missing_nup,test_mods_list,test_mods_size_table,test_native_zstd,test_ngx_sdk,test_nonuniform_image_arrays,test_parallel_init_order,test_pending_guest_import,test_pipeline_play_cache,test_prepare_cache_save,test_prepare_stall,test_present_queue_default,test_present_source_crop,test_present_thread,test_profiling_mode,test_prompt_guide_lines,test_prompt_hand_guides,test_prompt_picture_tint,test_prompt_speed,test_psychov35_fsr3_fg,test_readback_timeout_source,test_recorder_sync,test_replay_write_order,test_slow_frames,test_song_note_cue,test_staging_burst,test_texel_buffer_ownership,test_thinlto_tls,test_upscaler_rows,test_vbytes,test_vcore_escape,test_vk_occlusion_queries,test_walk,test_walk_keyA driver whose depth or multisampled images exclude the targets' pool's memory type (none known on hand) can't be run by hand: the memory-type check is covered by
tests/test_target_image_pool.py. Not run: Intel's Mesa defaults that main gained since the measurement (#1586) together with this change; this head in the game (its code is the measured code, see Measurements).Still to test:
render target images:line withreused by sizeabove 0 (@Beanstalk windows, Hyrule Field camera turn)main's (by hand)Measurements
Verdict: it helps the Hyrule Field camera turn at Render 50%, where the host, not the GPU, sets the frame rate: 33.64 fps against main's 32.60 (median of three runs a side, every run of this PR above every run of main), 1% low 15.7 against 13.1, 22 frames of 50 ms or more against 32, and compaction stalls 1.0-5.2 a second against 4.6-11.9; a second Steam Deck OLED saw the turn about 1 fps faster in the same binary with the switch off and on. At Render 100%, where the GPU's work is most of the frame, six runs a side do not separate this PR from main: the turn runs 29.37 fps against 29.34, the 1% low 13.63 against 14.57 and the 0.1% low 9.06 against 10.91, with every arm's range overlapping (this PR's 1% low is above main's in 13 of the 36 run pairings; an exact rank test gives p 0.48 for the 1% low and 0.39 for the 0.1% low); it has fewer frames of 50 ms or more (32.5 against 42) and swaps about half as much. Neither better nor measurably worse there. Standing after the turn, with the camera returned to its heading before the turn, shows no difference at Render 50% (34.40 fps against 33.27, the run-to-run spread as large as the arms' difference). Standing fps before the turn is unchanged. No errors in 30 runs. On a Steam Deck LCD (omgitsgela) no fps win was shown (Testing).
Setup: Steam Deck OLED, SteamOS 3.9.5 (build 20261023.100, kernel 7.2.7-valve2), RADV VANGOGH (Mesa 26.2.0-devel 5c65d4fc31), AMD Custom APU 0932, 16 GB shared; GPU clock manual 1600 MHz (Steam's performance menu), checked before and after every run. The repository's
kokiri-startsave: Kokiri Forest standing 120 s, teleport to Hyrule Field (the Lost Woods tunnel mouth, night), 20 s settle, standing 60 s, four full-stick camera pans (the turn, 49-60 s), standing until 210 s after arrival (300 s in the anchored block). Minimum preset (quality_preset=1),handheld_profile=0, Render 50% (resolution=4) and Render 100% (resolution=1), the game's own upscaler, output 1280x800, frame pacing on, uncapped, vsync off, frame generation off; headless (HOS_HEADLESS=1), a fresh options file each run, the same shared shader cache (47798 program keys kept, no preparation) in every run. fps and frame times from the game's present trace (HOS_PRESENT_TRACE) over each window (the turn: from the first pan's start to the last pan's end); 1% / 0.1% low = 1000 / the mean of the slowest 1% / 0.1% of frame times in the window; the render target counts and the pool's size from the status lines' change across the window; GPU time from the log;/proc/vmstat(compact_stall,pswpout),/proc/meminfoand PSI sampled at 5 Hz, heavy reads only outside scored windows. Render 50%: 10 runs, C1 R1 R2 C2 L1 R3 C3 L2 Z1 L3, 01:05-02:26Z 2026-11-19. Render 100%: 14 runs, C1 R1 L1 R2 C2 L2 R3 C3 and, in a second session, C4 R4 R5 C5 C6 R6 (17:14-17:57Z); C1 ran at 02:35Z, about 7.5 hours before the next seven (10:00-10:54Z), so the drift that interleaving spreads over the arms is not spread over it. The median of each arm; every run's value in brackets. To reproduce: thekokiri-startsave and the options above; main's build against this PR's with no switch (level 2 on an integrated GPU), and the same PR build withRX_VK_TARGET_REUSE_MEMORY=1(or=0) for the variants.Measured at
540f552deon main38990574a. Since then the head differs only by rebases (onto868f6be87,a433db328and now068fb8ebe):git range-diffshows the eight code commits identical (=) througha433db328; on068fb8ebeone comment drops a pull request number, as main's comments no longer carry them, andtests/test_target_reuse_memory.pyreads the switch's row where main's docs now keep it. Main's commits since38990574atouch none of the pool's code; main's other changes (host threading and waits, #1662, #1663, #1664; the render thread replaying jobs as they come, #1121) can move both sides' absolute fps; the comparison is main against this change on the same base. Not measured again on068fb8ebe.38990574a540f552de540f552deMain's runs are C1-C3 at Render 50% and C1-C6 at 100%, this PR's R1-R3 and R1-R6, the
=1variant's L1-L3 (two at 100%), in the order above. One run withRX_VK_TARGET_REUSE_MEMORY=0on the PR's build at Render 50% (Z1) turned at 32.51 fps, 1% low 14.77, 28 frames of 50 ms or more, 11.6 compaction stalls a second: with main's, not with the PR's default. Level 1 against level 2 is not separated by these runs (Render 50%: 33.07 against 33.64, overlapping).Standing after the turn, anchored (Render 50%, three runs a side; 6 runs, C1 R1 R2 C2 C3 R3, 18:05-19:58Z). The plain after-turn window starts wherever the turn leaves the camera, and swung 5-7 fps between runs of one arm. Here the camera is turned back to within 2 degrees of its heading before the turn first, its draws checked to be within 10% of the standing window before the turn, and 60 s are scored there. R2 failed that check (+12.2%) and is marked with an asterisk; it is kept in the medians.
38990574a(C1 / C2 / C3)540f552de(R1 / R2* / R3)No difference is shown after the turn: the pre-turn standing window itself varies from 33.2 to 37.0 fps between runs, as much as the arms differ, and without the marked R2 this PR's median is 34.39 against main's 34.40. The pool is empty or nearly so in the window (as dukenheimer's samples found, below).
An independent test on a second Steam Deck OLED. dukenheimer ran this PR's code at
540f552don base38990574on their own Deck OLED, on its built-in 1280x800 panel at Render 50%, frame generation off, on AC at 15 W, comparing the switch off (RX_VK_TARGET_REUSE_MEMORY=0) against the PR's default in the same binary, in four fixed pairs (#1681 (comment)). In the turn, in the two pairs admitted by their shader and queued-work checks, the default was about 1 fps faster (+0.33, +1.66) with lower p95 and p99 frame times (p95 -2.30 and -3.10 ms, p99 -2.40 and -10.30 ms); standing before the turn +0.21 fps; Kokiri standing about -0.09 fps, lower in all four pairs; standing after the turn -3.12 fps (-5.84 to +0.38), which they could not separate from the different views the turn leaves. No R-only picture fault in 636 frames inspected at full resolution, 0 frames flagged by a per-present flash detector, and no crash, device loss or validation error. Their follow-up (#1681 (comment)) read the pool from their logs: a cap of 487 MiB; sampled high-water marks in the admitted turns of 65 and 48 MiB with the switch off against 307 and 315 MiB at the default; between the turn and the window after it the pool fell (456→0, 78→6, 352→86, 303→0 MiB) and each round's last sample had no pooled images; system-wide memory PSIsomein the turn 14.1→6.1% and 13.5→8.2%. Their delta (level 2 against 0 in one binary) and ours (this PR against main) are not directly comparable.The fps, lows and frame times come from the present trace; the counts from the status lines. At the end of the turn, Render 50%, main (run C2) and this PR (run R3); running totals since the start, so the turn's figures are their change across it:
The switches: one switch is added and one switch's default changes on integrated GPUs; no menu row or ini key changes.
RX_VK_TARGET_REUSE_MEMORY(new): 0 off; 1 a target that misses the pool takes a pooled image's memory by size (and the 64-present hold on an integrated GPU); 2 also size classes. It ships at 2 on an integrated GPU, chosen by the Render 50% runs on the Steam Deck OLED above (level 1 there measured, not separated from 2; no separable change at Render 100%; on the Deck LCD no fps win shown), and at 1 elsewhere, which is not measured: discrete GPUs, Intel and Windows are in Still to test for the Test Farm.RX_VK_POOL_IDLE: 8 presents before; 64 on an integrated GPU while the take is on, else 8. More images to reuse, more memory held (up to the pool's cap). Measured on the Deck OLED only together with the take (the hold alone, on main, measured worse in an earlier block: 29.3 fps against 29.8-30.3, the pool pinned at 428-468 MB); discrete keeps 8, untested there.Risks
What could break: memory of one render target reused for another of a different shape: a wrong fit or a missed barrier would show as corruption in shadows or other targets, or a device loss (none seen in 30 runs here and dukenheimer's 636 inspected frames).
What it costs, as measured:
vk: render target pool: up to 486 MB; dukenheimer's logs 487 MiB), so at Render 50% the pool fills close to its cap in the turn. The lowest MemAvailable in the turn was 1.9-2.2 GB against main's 1.6-2.8 at Render 50% and 1.5-2.2 GB against 1.4-2.1 at Render 100% (no run ran out of memory: all 30 exited normally). After the turn the pool drains (dukenheimer's samples; 0-9 MB median in the anchored window here). The size classes cost up to a quarter more memory per render target of the pooled kind there (6-9% on average), counted in the texture budget.Turning it off:
RX_VK_TARGET_REUSE_MEMORY=0(the take, the hold and the classes off; the memory-type check stays);=1for the take and the hold without the classes;RX_VK_POOL_IDLE=8for the take without the hold.After updating: nothing changes for a player's files: no save, ini, shader or pipeline cache change (the translator stamp is unchanged), no
MKWVK_API_VERSIONchange.Checklist
Ready for review
main; the title is a Conventional Commit.540f552de, the same code; this head not run in the game]mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure. [against main38990574a; Measurements says why the numbers still hold on068fb8ebe]third_party/untouched; nothing GPL-incompatible. [every line of the diff is new code written for this PR; it calls VMA's existing public API (vmaCreateAliasingImage,vmaAllocateMemory,vmaGetAllocationInfo) and Vulkan 1.3'svkGetDeviceImageMemoryRequirements, copying neither]When it applies
mainand passes here. [the memory-type check:tests/test_target_image_pool.py]gpu/vk/switches.def. [2 on an integrated GPU, from the Deck runs; 1 elsewhere is unmeasured and asked of the Test Farm in Still to test]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. [the head is not pushed yet; why the numbers still hold is in Measurements]Tested in game: Earlier builds of this change (the same code but for review fixes): Steam Deck OLED, SteamOS 3.9.5, RADV (Mesa 26.2.0-devel), Kokiri Forest and Hyrule Field at Minimum, Render 50% and 100%: no error or picture difference in 23 runs. This head has not run in the game yet.
Measured at this change's head
540f552deon a Steam Deck OLED against main38990574a(18 interleaved runs), and rebased onto main868f6be87: the eight code commits are unchanged (git range-diff: all=), plus one commit with the 18 runs' files underdocs/tested/. The description's Measurements, Testing, Risks and checklist now describe this head instead of earlier builds. Headline: at Render 50%, where the host sets the frame rate, the Hyrule Field turn runs 33.64 fps against 32.60 (all three runs above all of main's), with a 1% low of 15.7 against 13.1 and fewer long frames. At Render 100%, where the GPU's work is most of the frame, fps does not change (about 29.2 on every arm); it swaps less and has fewer long frames, but its 1% and 0.1% lows are slightly below main's, which three runs a side do not separate, so the PR stays WIP on that and on the Windows build.540f552dedd018c58232Test of render-target memory reuse (
RX_VK_TARGET_REUSE_MEMORY) on a second Steam Deck OLED, to see whether the switch changes frame rate, frame-time tails or CPU on our route, and whether reuse shows any picture fault.What was tested. This PR's code at
540f552don base38990574. The timed runs used one binary on the Deck's built-in 1280×800 panel, Render 50%, frame generation off, on AC at 15 W with the same clock policy and restored save. O disables by-size memory reuse, not all render-target pooling; R also enables size-class allocations and longer pool retention. This compares that bundle. The separate visual runs used the matched coverage build. O =RX_VK_TARGET_REUSE_MEMORY=0, R = unset (the PR's default, level 2 on this integrated GPU). Route: Kokiri Forest standing 120 s (K), then a debug teleport to the Field: standing 60 s (FS1), the camera turning 60 s (F), standing again 60 s (FS2). One warm-up per arm, then four fixed pairs in the order R/O, O/R, R/O, O/R. A pair counts only if both windows pass the logged shader/pipeline and queued-work checks. One warm-up turn and two scored turns were excluded (2.O and 3.R), leaving rounds 1 and 4 for F.Results. R minus O within each admitted pair. Values are paired medians unless both round 1 and round 4 differences are shown; ranges are given where listed. CPU is game-process CPU ms per renderer present.
FS2 starts where the turn leaves the camera. We can report the observed −3.12 FPS, but cannot separate a switch effect from the different views. In K, median frame time was about 38 ms in both arms.
Pictures.
Head. These are 540f552d's code on base
38990574, not today's rebased018c582onto868f6be87. Per your comment (#1681 (comment)) the eight code commits are unchanged by the rebase, but we have not rund018c582. Your 33.64 vs 32.60 FPS at Render 50% compared540f552dagainst main38990574. Ours is level 2 vs 0 in the same540f552dbinary on our route, so the two deltas are not directly comparable.Limits.
@dukenheimer thank you: a same-binary pair on a second OLED and on the panel is the cell this PR lacked, and the picture check (636 frames, the flash detector over every present) is more than I had done.
How I read it next to ours: the turn moves the same way on both Decks (yours about +1 fps with lower p95 and p99 in the two admitted pairs; ours 33.6 against 32.6 against main), and standing before the turn is flat on both. Two things I take as open rather than explained:
The PR stays WIP on those and on the Render 100% lows. If your pool counters and memory pressure analysis shows the pool's size across the turn and the seconds after it, that would speak to the first point directly.
The standing-after-the-turn window by arm, from the 18 runs already in this PR (fps over the 70-81 s after the last pan; C = main
38990574a, R = this PR at its default, L =RX_VK_TARGET_REUSE_MEMORY=1, Z ==0on the PR's build):Medians: Render 50% C 36.83, R 38.69, L 38.35; Render 100% C 29.25, R 29.00, L 28.86. So our runs do not show the deficit, but they would not show a 3 fps one reliably either: that window swings by 5-7 fps between runs of the same arm (R at 50%: 32.3 to 39.5; C: 33.7 to 37.7), more than any arm difference. As you said for yours, where the turn leaves the camera differs by run. The Kokiri standing medians are C 17.75, R 17.85, L 17.89 at 50% and C 17.33, R 18.01, L 16.76 at 100%: no sign of a cost there in ours.
I'll leave the after-turn point open in the description rather than call it noise: an anchored view after the turn (the camera returned to a fixed heading before the window) is what would settle it, and I'll add that to the next block.
@zeldaootr on the pool across the turn and after it, from our raw logs at
540f552d:At
540f552dthe logged pool cap was 487 MiB in all four measured rounds. For the two jointly admitted turns (rounds 1/4), sampled high-water marks were O 65/48 versus R 307/315 MiB. R's two successive samples between the F and FS2 window boundaries were 456→0, 78→6, 352→86 and 303→0 MiB by round. In FS2 itself R's sampled maxima were 319/4/196/0 MiB; each round's last sample had zero pooled images. In round 1 it went from zero back up to 319 during FS2. These are point readings every 600 renderer presents, not continuous maxima or exact window-end values. They show intermittent occupancy rather than a pool observed full throughout FS2; they don't establish what caused the FPS difference or rule out an earlier pressure effect.System-wide memory PSI
some, O→R, was 14.1→6.1% and 13.5→8.2% in the two admitted turn pairs. That is the whole system, not game CPU, and not proof that pool size caused it.@dukenheimer thank you, and your cap line corrects an error of mine. I wrote (in the description's Risks and in my comment above) that the pool peaked "above the 392 MB its cap works out to" and that this was unexplained. That 392 was a figure I had worked out, not read. Our own logs say what yours do:
vk: render target pool: up to 486 MB (RX_VK_TARGET_POOL_MB)(486 to 489 across runs). So the peaks of 455-484 MB at Render 50% are under the cap, nothing is unexplained there, and the plain reading is that in the turn the pool fills close to its cap. The description is corrected.On your samples after the turn: 456→0, 78→6, 352→86 and 303→0 MiB between the two window boundaries, and zero pooled images at each round's last sample, say the pool drains within the 64-present hold once the turn stops, as designed, and is not sitting full through the standing window. That weakens my own suggestion that held memory explains your -3 fps there, without ruling out what the turn left behind in the system (your PSI line is the other side of that: 14.1→6.1 % and 13.5→8.2 % in the turn itself). The anchored after-turn window is still what I'll run to settle it.
d018c58232351ead0caaRebased onto main
a433db328(the eight code commits unchanged,git range-diffall=), with 12 more Steam Deck OLED runs and their files underdocs/tested/. At Render 100%, six runs a side don't separate this PR from main: the turn runs 29.37 fps against 29.34, and the 1% / 0.1% lows (13.63 / 9.06 against 14.57 / 10.91) sit inside main's own range, above main's in 13 of 36 pairings. Standing after the turn, with the camera turned back to its heading before the turn first, shows no difference at Render 50% (33.27 against 34.40 fps, 34.39 without R2, the one run whose draws missed the 10% check). Now that #1729 is merged, the renderer builds for Windows with llvm-mingw (213 files,longshot_vk.dlllinked), so the description now ticks both remaining boxes and lists every cost measured under Risks. Thank you @dukenheimer for the independent run on a second Deck OLED: the same-binary pairs, the 636 inspected frames and the pool readings after the turn are what pointed me to the anchored window, and the description now cites both comments.WIP: perf(vk): render targets take a pooled image's memory by size, and the pool holds longer on integrated GPUsto perf(vk): render targets take a pooled image's memory by size, and the pool holds longer on integrated GPUsFor the record here: omgitsgela ran this PR on a Steam Deck LCD, the switch off against the default in one binary, in three areas (#1477, their comments of 2026-11-19 21:05 and 21:07). Their reading, which I agree with: no demonstrated fps win in any cell, and not proof of no effect. The one pair per cell that passed their scene-match gate: Hyrule Field median 39.93 ms with the default against 40.04 off (p99 -11.0 ms, 22 fewer frames over 50 ms, inside their A/A floor); Castle Town 43.64 against 42.42 (the default slightly behind); Kokiri gave no admitted pair.
That is the same picture as this PR's Render 100% rows on the OLED: where the frame is not waiting on the host's allocations, the frame rate does not move. The gain measured here is at Render 50% on the OLED (33.6 against 32.6 fps in the turn), and dukenheimer's same-binary pairs at Render 50% went the same way. So the claim stays as the description has it: it helps the turn where the host sets the frame rate, and is neutral elsewhere. Thank you @omgitsgela for the LCD cells.
351ead0caa742b053ae6Rebased onto main
068fb8ebe, the docs and tools revamp (head742b053ae, the eight code commits kept, the code unchanged except that one comment drops a pull request number, to match main's comment sweep).docs/development.mdis gone, so this PR's text onRX_VK_TARGET_REUSE_MEMORYis now a row in the Memory table ofdocs/dev/reference/switches.md, whichtests/test_target_reuse_memory.pyreads. Main removed the tested-configurations catalogue, so the two commits with the 30docs/tested/run files are dropped; their numbers stay in the description's Measurements, which now follows the new template and also records omgitsgela's Deck LCD cells in Testing. The game-free checks fail nothing that main doesn't also fail on this PC; the measurements are from540f552deand have not been run again.@Beanstalk
Beanstalk test farm · an earlier run: commit
742b053(the newer results are in a comment below)Commit
742b053· approved by HumanBean (reviewed) · dashboardStarted at 18:55 UTC.
Estimate: done in about 1 h, from the queue and the testers online now.
anyWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)The plan compares main and the PR in Hyrule Field during repeated camera turns and a standing period afterward, where changing shadow-map sizes exercise render-target reuse. It takes about 12 minutes per tester and records whole-run hitches, standing frametimes, VRAM use, and a comparison image. Crashes, device loss, substantial performance or memory regressions, or a material image difference fail the test; a speedup is not required.
kokiri-start, then teleport to Hyrule Field, 8 times: move the stick, measure standing for 20 s (after 5 s warm-up), take the picture field-after-turns to compare with main; 1 run on each side.@Beanstalk please test this, to decide the real default of
RX_VK_TARGET_REUSE_MEMORY. Same build of this PR, the switch as a matrix axis:=0(main's behavior),=1and=2, interleaved. Targets: windows+nvidia, windows+amd, windows+intel, linux+nvidia, linux+amd, steamdeck (igpu targets are where=2is the default today). Windowed, not headless, frame generation off: Hyrule Field with the camera turning full circle several times (Render 50% and 100% on the Deck and any iGPU), then standing. Report fps, 1% low, frames over 50 ms, p99, the pool's peak MB, lowest available memory and the log'srender target images:line (reused by size), per level. We want to know if=1,=2, or off should be the default on each kind of PC (discrete, integrated, Deck), and whether any picture fault, device loss or memory pressure shows up.Beanstalk test farm · 🔄 testing (8 of 6 reports so far, a failure already)
Commit
742b053· approved by HumanBean (reviewed) · dashboardDone (started 18:59 UTC, last report 22:19 UTC). Run 2: re-planned by HumanBean. Comment
@Beanstalkto run it again.windows+nvidiawindows+amdwindows+intellinux+nvidialinux+amdsteamdeckfield-turn-and-stand· frame time p99 (ms)RX_VK_TARGET_REUSE_MEMORY=0(reference)RX_VK_TARGET_REUSE_MEMORY=1RX_VK_TARGET_REUSE_MEMORY=2windows+nvidiawindows+amdwindows+intellinux+nvidialinux+amdsteamdeckWhy it failed
windows+amd:field-turn-and-stand · RX_VK_TARGET_REUSE_MEMORY=0 (PR only)screenshot.max_diff:limit 0.1windows+amd:field-turn-and-stand · RX_VK_TARGET_REUSE_MEMORY=1 (PR only)screenshot.max_diff:limit 0.1Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
windows+nvidia, report 1:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)windows+nvidia, report 2:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)windows+amd, report 1:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)linux+nvidia, report 1:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)linux+nvidia, report 2:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)linux+amd, report 1:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)linux+amd, report 2:no scenario could be judged: a step ran out of time at step 2 (wait map HyruleField_Child): timeout: not met in time (then the game was in play on KokiriForest_Child)What was tested
What will be tested · AI plan (
gpt-6.1-terra)In Hyrule Field, the plan compares reuse levels 0, 1 and 2 on the PR build, with main also run because the memory-type safety check remains active at level 0. It turns the camera and then measures standing performance, captures pictures, and samples pool occupancy, reuse counts, VRAM and hitch metrics over roughly 35 minutes per tester. Crashes, device loss, large picture differences or a substantial standing p99 regression against level 0 fail the plan. Windows Intel waits for a matching tester; the farm cannot run windowed or measure lowest available system memory, and the turning input cannot overlap a timed measurement segment. No tester online now matches windows+intel: that target waits for one.
0or1or2(PR only).kokiri-start(settings fullscreen=0, frame_generation=0), then teleport to Hyrule Field, take the picture field-before to compare with main, 4 times: move the stick, take the picture field-after-turn to compare with main, measure standing for 25 s (after 5 s warm-up), take the picture field-standing to compare with main; 1 run on each side for each of 3 cells (3 game starts a run).Measurements on `windows+nvidia`, for the PR description
Verdict: could not be judged on windows+nvidia (2 reports).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 5080, 621.24.0AMD Ryzen 9 9900X3D 12-Core Processor, 64 GB RAMScene: field-turn-and-stand, from the repository's save kokiri-start (fullscreen=0, frame_generation=0); 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); field-turn-and-stand: 1 game start a side, standing 25 s after 5 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)068fb8e742b053RX_VK_TARGET_REUSE_MEMORY=0 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=0 (PR only)· standing · frame time (p99) (ms)RX_VK_TARGET_REUSE_MEMORY=0 (PR only)· standing · peak VRAM (MB)RX_VK_TARGET_REUSE_MEMORY=1 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=2 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=2 (PR only)· standing · frame time (p99) (ms)RX_VK_TARGET_REUSE_MEMORY=2 (PR only)· standing · peak VRAM (MB)Flags and settings
RX_VK_TARGET_REUSE_MEMORY0,1,2As Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: fail on windows+amd (2 reports):
field-turn-and-stand screenshot.max_difffailed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 9060 XT, 2.0.416AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 7700 8-Core Processor, 32 GB RAMScene: field-turn-and-stand, from the repository's save kokiri-start (fullscreen=0, frame_generation=0); 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); field-turn-and-stand: 1 game start a side, standing 25 s after 5 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)068fb8e742b053RX_VK_TARGET_REUSE_MEMORY=0 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=0 (PR only)· standing · frame time (p99) (ms)RX_VK_TARGET_REUSE_MEMORY=0 (PR only)· standing · peak VRAM (MB)RX_VK_TARGET_REUSE_MEMORY=1 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=1 (PR only)· standing · frame time (p99) (ms)RX_VK_TARGET_REUSE_MEMORY=1 (PR only)· standing · peak VRAM (MB)RX_VK_TARGET_REUSE_MEMORY=2 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=2 (PR only)· standing · frame time (p99) (ms)RX_VK_TARGET_REUSE_MEMORY=2 (PR only)· standing · peak VRAM (MB)Flags and settings
RX_VK_TARGET_REUSE_MEMORY0,1,2As Markdown for the PR description:
Measurements on `linux+nvidia`, for the PR description
Verdict: could not be judged on linux+nvidia (2 reports).
Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce GTX 1070, 580.196.7Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, 32 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 5080, 620.73.4AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: field-turn-and-stand, from the repository's save kokiri-start (fullscreen=0, frame_generation=0); 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); field-turn-and-stand: 1 game start a side, standing 25 s after 5 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)068fb8e742b053RX_VK_TARGET_REUSE_MEMORY=0 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=1 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=2 (PR only)· forbidden log linesFlags and settings
RX_VK_TARGET_REUSE_MEMORY0,1,2As Markdown for the PR description:
Measurements on `linux+amd`, for the PR description
Verdict: could not be judged on linux+amd (2 reports).
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 6600 (RADV NAVI23), 26.2.6AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM; 2: linux+amd+radv+igpuAMD Radeon 890M Graphics (RADV STRIX1), 26.1.99AMD Ryzen Z2 Extreme, 32 GB RAMScene: field-turn-and-stand, from the repository's save kokiri-start (fullscreen=0, frame_generation=0); 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); field-turn-and-stand: 1 game start a side, standing 25 s after 5 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)068fb8e742b053RX_VK_TARGET_REUSE_MEMORY=0 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=1 (PR only)· forbidden log linesRX_VK_TARGET_REUSE_MEMORY=1 (PR only)· standing · frame time (p99) (ms)RX_VK_TARGET_REUSE_MEMORY=1 (PR only)· standing · peak VRAM (MB)RX_VK_TARGET_REUSE_MEMORY=2 (PR only)· forbidden log linesFlags and settings
RX_VK_TARGET_REUSE_MEMORY0,1,2As Markdown for the PR description:
The testers' hardware
windows+nvidiaNVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAMwindows+nvidiaNVIDIA GeForce RTX 5080, 621.24.0AMD Ryzen 9 9900X3D 12-Core Processor, 64 GB RAMwindows+amdAMD Radeon RX 9060 XT, 2.0.416AMD Ryzen 5 5600 6-Core Processor, 32 GB RAMwindows+amdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 7700 8-Core Processor, 32 GB RAMlinux+nvidiaNVIDIA GeForce GTX 1070, 580.196.7Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, 32 GB RAMlinux+nvidiaNVIDIA GeForce RTX 5080, 620.73.4AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMlinux+amdAMD Radeon RX 6600 (RADV NAVI23), 26.2.6AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAMlinux+amdAMD Radeon 890M Graphics (RADV STRIX1), 26.1.99AMD Ryzen Z2 Extreme, 32 GB RAM