perf(vk): the dead render targets go at every present, as RX_VK_DEAD_EVERY=1 meant, and a pooled image waits 8 presents (RX_VK_POOL_IDLE) #1255
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!1255
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:perf/dead-targets-every-present"
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: Windows 11, RTX 4070 SUPER (NVIDIA 617.42) · Needs: an AMD card; Linux; a Steam Deck; a card of 8 GB or less
Why
In Castle Town's market the game uses 1.5 to 2 GB of video memory for render targets it is no longer using, and on a 12 GB card that is enough to push it into the texture budget's cut: in a played session the market went from 5.7-6.5 GB on the first visit to 8.9-9.2 GB after a shop, the budget was cut from 6,998 MB to 4,093-4,604 MB, and 208 frames of 2,778 ran over 25 ms.
#994 set
RX_VK_DEAD_EVERYto 1 so that the dead transient targets would be looked for at every present. That never took effect, and it is my mistake: the pass that reads the switch sits behindtexture_frame's olderif (frame_no % 10) return;, so it still ran at every tenth present only (the gate was already there in1db4c290, and #994's test checked the default's value, not when the pass runs). A frame's dead targets waited up to nine more presents and came back to the pool ten frames' worth at once. Measured in the market with the camera turning: 160-290 rendered images (700-830 MB) alive at a time that were unused for two presents or more, and every one of them already met the dead rule (another target drawn over its storage from another start, the GPU done).Once they do come back every present, the pool's own idle time shows: an image waited 120 presents for the next target of its shape. The game sizes each near character's shadow map anew every frame (397, 439, 479 ... pixels a side), each a pool key of its own that never comes again, and those filled the pool to its 768 MB bound.
Related: #994 (the pool's bound and these defaults), #1104 (the pool given back over the hold's line: the same memory from the other side; with this change the pool holds 100-140 MB in the market, not 480-530 MB).
What changed
The dead transient render targets are let go at every present, as
RX_VK_DEAD_EVERY=1was meant to do, and an image waits 8 presents in the pool, not 120.dead_targets_sweep()runs on the presents between the eviction's passes (gpu/vk/vk_texture.cpp). It lets go exactly what the pass's own rule lets go and nothing else: a render target of one level and layer, unused forRX_VK_DEAD_MIN_UNUSEDpresents, the GPU past its last use, with another target drawn over its storage from another start since (target_overlap.h). Nothing is written back; the image goes to the target pool.gpu/vk/dead_targets.hholds when the pass and the sweep run, so the cadence can be tested.RX_VK_DEAD_EVERY=10leaves them to the pass alone, as it was in effect;RX_VK_DEAD_TARGETS=0andRX_VK_NO_EVICTturn the sweep off as they turn the pass's off.RX_VK_POOL_IDLE=<presents>, 8 by default (gpu/vk/target_pool.h,pool_trim); 120 is the behaviour before.tests/test_dead_targets_sweep.py(the presents the pass and the sweep run at, compiled from the header; thattexture_frame's gate calls the sweep before it returns; that the sweep uses the pass's rule and writes nothing back; the pool's idle rule).tests/test_target_image_pool.pyfollows the moved lines, and its check of "every present" now asks for the sweep's call.docs/development.md(the switches' row);docs/tested/2026-11-16-dead-targets-every-present-gumminaomi-old.mdand-new.md.Measurements
Verdict: in the market with the camera turning, 0.6 to 1.0 GB less video memory (the render targets' blocks 576-768 MB against 1,440-1,856 MB) and 18-30 % fewer images made new, for about half a millisecond more of the render thread a frame; the frame rate is the same within the runs' spread (60.4 and 60.5 fps against 60.8 and 62.2).
Hardware: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D (16 cores, SMT off), 32 GB
Scene: save set "First Step into Hyrule Town", the walk into Castle Town's market and the camera turning (town-market.txt, wall clock, 100 s), 2560x1440, DLAA, uncapped
Method: headless runs, two rounds with the two sides in turn; the frame trace from 48 s on (the camera turn) and the log's status lines (the last three of a run)
Baseline: main's behaviour is this PR with
RX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120(the sweep never runs and the pool's idle time is main's); both sides are one build, mainac778751with this change. The branch has since been merged with maina413bf1c(one conflict invk_texture.cpp: main'sreuse_retire_frameand this PR's sweep were added at the same place, both kept) and built and run once there: 22,468 of 25,032 dead targets let go between the passes, the render targets' blocks 608-736 MBHow to reproduce:
RX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120against no switches, on the route aboveRX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120: this PR @79381e65(two runs)79381e65(two runs)texture_frame, a frameThe cost: the texture-destroyed generation now moves at every present, so each handle a recording resolved is looked up again once a frame (descriptors about +0.45 ms), and the sweep orders the rendered textures by address each present (
texture_frameabout +0.25 ms).RX_VK_DEAD_EVERY=2would halve both; not measured.Picture checks, both sides:
RX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120: this PR @79381e6579381e65RX_VK_LOG_REMADE=1), the gate at night and the market, 100 s eachThe flip count runs higher on this side in three of six runs and I cannot rule out a small real difference. I looked at the worst frames of both sides: on both they are scattered single pixels along the edges of the distant lit town while Link walks through the gate, the same on either side, with no surface that flashes. In two played sessions with this change (and the shadow maps' storage slots, a separate PR) the player saw no flicker, and the texture budget was not cut once (6,998 MB throughout, where the session before it was cut to 4,093-4,604 MB).
Flags and settings
One switch now does what it said, and one is new; both on by default.
RX_VK_NO_EVICTandRX_VK_DEAD_TARGETS(existing) turn the sweep off as they turn the pass's off.RX_VK_DEAD_EVERYRX_VK_POOL_IDLETesting
Tested: Windows 11, RTX 4070 SUPER, NVIDIA 617.42: the runs above; two played sessions in the market, a shop and back (with the shadow maps' storage slots as well);
tests/test_dead_targets_sweep.py,tests/test_target_image_pool.py,tests/test_target_pool_cap.pyandtests/test_target_overlap.pypass;python -I -B tests/run_all.py: 391 passed, 90 failed, 213 skipped, the same 90 failing as on mainac778751on this PC (390 passed there; its toolchain: no gcc, Windows line endings, fixtures needing tools not installed).Not tested: AMD, Intel, Linux, the Steam Deck; a card of 8 GB or less, where the memory matters most; frame generation on; other games.
Must be tested:
RX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120, and no flicker of shadows or lit windows (by hand)Risks
What could break: a render target let go a few presents earlier than before and then read again without being drawn would come back empty for a frame (a shadow or a bloom flicker). The rule that decides it is unchanged and the made-again check found none, but the flip counts above leave a small doubt. About half a millisecond more of the render thread a frame where targets die every frame.
Turning it off:
RX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120.Compatibility: Nothing changes.
Issues
None found for this exactly. #994 is the change it corrects.
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Possibly related, for context:
@Beanstalk linux: Castle Town's market with the camera turning (save set "First Step into Hyrule Town", the walk north into the market, then the camera turned for a minute), once with this PR's defaults and once with
RX_VK_DEAD_EVERY=10 RX_VK_POOL_IDLE=120(the behaviour before it). Expecting: no crash; the same picture on both, with no flicker of shadows or lit windows; with the defaults less video memory in use and smaller render-target blocks (the log'svk: VRAM:andimage blocks (render targets)lines), and a frame rate no worse.🤖 Generated with Claude Code
Beanstalk test farm
Commit
f490c2a· tier reviewed · approved by GummiNaomi · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)On Linux, the plan teleports a new save to Castle Town's market and turns the camera, comparing PR defaults and the earlier render-target behavior against main. It takes roughly 30 minutes per tester and measures VRAM, frame rate and frame times, with snapshots for visual regressions. Crashes, substantial VRAM or performance regressions, and picture differences fail the plan. The requested town save is unavailable; render-target block sizes and transient flicker cannot be directly compared by these probes.
120(PR only); RX_VK_DEAD_EVERY10(PR only).Done. Comment
@Beanstalkto run it again.WIP: perf(vk): the dead render targets go at every present, as RX_VK_DEAD_EVERY=1 meant, and a pooled image waits 8 presents (RX_VK_POOL_IDLE)to perf(vk): the dead render targets go at every present, as RX_VK_DEAD_EVERY=1 meant, and a pooled image waits 8 presents (RX_VK_POOL_IDLE)