WIP: perf(vk): the render target pool's bound spares the images that came in the last presents (RX_VK_TARGET_POOL_GRACE=0 to disable) #1996

Draft
siantm wants to merge 6 commits from siantm/Longshot:perf/vk-image-reuse into main
Contributor

Depends on #2064 (the present's source held, split from this PR in dyst's review): this branch is stacked on it.

Summary

The render target pool's bound counts what the pool holds at one moment, and the dead targets come to it several at once (a
pass's targets, a few each present while the camera turns); over the bound the trim destroyed them, and the next presents'
targets of the same shapes were made new.

With this, an image put in the pool in the last RX_VK_TARGET_POOL_GRACE presents (4) is not counted out by the bound while
the pool holds no more than twice the bound: until then its dead texture held it. The idle limit (RX_VK_POOL_IDLE) still
takes it, the grace is kept under it (its value less one at most), and while VRAM is short there is no grace. The 600-present
render target images line also gives the most the pool held over its bound after a trim since the line before.

The result expected: fewer render target images destroyed and made new, where the pool goes over its bound.

The switch: RX_VK_TARGET_POOL_GRACE (new, kind kill, int, presents), 4 by default, as the branch shipped it; 0 is the
kill switch: no grace, the bound counts every image, as main does. Read once, at the first trim while VRAM is not short. Its
row is in gpu/vk/switches.def, and RX_VK_TARGET_POOL_MB's row says it is the trim's bound, which the grace may keep up to
twice. (RX_VK_IMAGE_REUSE, which turned off the same thing, is gone, as dyst asked.)

From bd3ea307 on exp/x86-asm-sync (its image-reuse work; main has the other half: a dead target's image pooled at its
retirement when the GPU is past it), with 224a29b8's grace under the idle limit.

Read first: pool_trim in gpu/vk/vk_texture.cpp, effective_grace and grace_ceiling in gpu/vk/target_pool.h, then
tests/test_target_pool_grace.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head 850ba5df on #2064's a9d04a2e (main
9dd41326), light job dy1996c of this PC's job queue, RX_CPM set (the Vulkan headers found): tests/run_all.py --strict --exact over tests/test_target_pool_grace.py, tests/test_switch_table.py, tests/test_dead_targets_sweep.py,
tests/test_target_retention.py, tests/test_present_source_held.py, tests/test_target_image_pool.py and
tests/test_vram_compact.py: 7 pass; tests/test_target_reuse_memory.py fails on the two points it failed on main @
f1f2dc5b in build job fb-vkfix-1 (destroy_image_later undeclared in its fixture, vmaGetAllocationInfo2 found), not rerun
on 9dd41326. gpu/vk/vk_texture.cpp compiled (syntax) with the game build's own commands. Earlier, at e88ea1b7 (jobs
fb-1996-1 to fb-1996-3): the grace's test commit failed on the PR's first code and passed at the fix.

The Test Farm ran e88ea1b7 (comment #1996 (comment), Kokiri
Forest, Linux NVIDIA and RADV): its picture check failed at both switch settings, but the pictures were taken right after a
stick-driven camera turn and show a different viewpoint on main and on the PR (no main-against-itself picture); and the grace
was not exercised: every log says the pool let go of nothing over its bound and was at most 0 MB over it.

It has NOT run in the game on this PC yet.

Still to test:

  • A scene and settings that take the pool over its bound (the farm's Kokiri run did not): Hyrule Castle Town's market or
    Hyrule Field, the highest Output resolution, the camera turning, on a card of 6 GB or less (issue #939) and a Tier 1
    discrete card: main @ 9dd41326 against this branch unset and with RX_VK_TARGET_POOL_GRACE=0, at least two starts a side,
    interleaved; expecting the pool's own lines to show it (the pool let go of N over its bound with N above 0 on main,
    at most N MB over its bound on the branch unset), fewer made new unset than with =0, the driver's VRAM peak against
    main, pictures at an input-free point the same as main within main against itself, no FATAL or device lost (on the Test
    Farm, or by hand)
  • Linux: build the renderer and run python3 -I -B tests/test_target_pool_grace.py, expecting PASS (by hand)

Measurements

Verdict: not measured in play yet. RX_VK_TARGET_POOL_GRACE ships at 4, as the branch shipped it; no measurement chose
that default. The farm's Kokiri run did not exercise the grace (the pool never over its bound), so its figures say nothing of
it; the A/B in Still to test does.

Risks

What could break: the pool holding more VRAM than its bound. Each image is in its grace for 4 presents at most, but while the
camera keeps turning and new shapes keep arriving, the pool can sit near twice the bound for as long as that lasts: at worst
one more bound's worth of render-target images than main's trim allows, the bound being RX_VK_TARGET_POOL_MB or a twelfth of
the VRAM the driver allows, 256 to 768 MB, so 256 to 768 MB more by default (as much more as RX_VK_TARGET_POOL_MB says when
set); not while VRAM is short. The ceiling of twice the bound is provisional, chosen, not derived from a measurement; the VRAM
peak against main decides it, on 6 GB cards most of all (issue #939). Turn it off with RX_VK_TARGET_POOL_GRACE=0. Renderer
code: the runtime is rebuilt; nothing changes for players' saves, options or caches. Overlap: #2054 (also siantm's) adds a lazy
retirement path that checks present_source; whichever of it and #2064 lands second adds dead_targets::present_held to it.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
Depends on #2064 (the present's source held, split from this PR in dyst's review): this branch is stacked on it. ## Summary The render target pool's bound counts what the pool holds at one moment, and the dead targets come to it several at once (a pass's targets, a few each present while the camera turns); over the bound the trim destroyed them, and the next presents' targets of the same shapes were made new. With this, an image put in the pool in the last `RX_VK_TARGET_POOL_GRACE` presents (4) is not counted out by the bound while the pool holds no more than twice the bound: until then its dead texture held it. The idle limit (`RX_VK_POOL_IDLE`) still takes it, the grace is kept under it (its value less one at most), and while VRAM is short there is no grace. The 600-present `render target images` line also gives the most the pool held over its bound after a trim since the line before. The result expected: fewer render target images destroyed and made new, where the pool goes over its bound. The switch: `RX_VK_TARGET_POOL_GRACE` (new, kind `kill`, int, presents), 4 by default, as the branch shipped it; `0` is the kill switch: no grace, the bound counts every image, as main does. Read once, at the first trim while VRAM is not short. Its row is in `gpu/vk/switches.def`, and `RX_VK_TARGET_POOL_MB`'s row says it is the trim's bound, which the grace may keep up to twice. (`RX_VK_IMAGE_REUSE`, which turned off the same thing, is gone, as dyst asked.) From bd3ea307 on `exp/x86-asm-sync` (its image-reuse work; main has the other half: a dead target's image pooled at its retirement when the GPU is past it), with 224a29b8's grace under the idle limit. Read first: `pool_trim` in `gpu/vk/vk_texture.cpp`, `effective_grace` and `grace_ceiling` in `gpu/vk/target_pool.h`, then `tests/test_target_pool_grace.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head `850ba5df` on #2064's `a9d04a2e` (main `9dd41326`), light job `dy1996c` of this PC's job queue, `RX_CPM` set (the Vulkan headers found): `tests/run_all.py --strict --exact` over `tests/test_target_pool_grace.py`, `tests/test_switch_table.py`, `tests/test_dead_targets_sweep.py`, `tests/test_target_retention.py`, `tests/test_present_source_held.py`, `tests/test_target_image_pool.py` and `tests/test_vram_compact.py`: 7 pass; `tests/test_target_reuse_memory.py` fails on the two points it failed on main @ f1f2dc5b in build job `fb-vkfix-1` (`destroy_image_later` undeclared in its fixture, `vmaGetAllocationInfo2` found), not rerun on 9dd41326. `gpu/vk/vk_texture.cpp` compiled (syntax) with the game build's own commands. Earlier, at e88ea1b7 (jobs `fb-1996-1` to `fb-1996-3`): the grace's test commit failed on the PR's first code and passed at the fix. The Test Farm ran e88ea1b7 (comment https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-65748, Kokiri Forest, Linux NVIDIA and RADV): its picture check failed at both switch settings, but the pictures were taken right after a stick-driven camera turn and show a different viewpoint on main and on the PR (no main-against-itself picture); and the grace was not exercised: every log says the pool let go of nothing over its bound and was at most 0 MB over it. **It has NOT run in the game on this PC yet.** **Still to test:** - A scene and settings that take the pool over its bound (the farm's Kokiri run did not): Hyrule Castle Town's market or Hyrule Field, the highest Output resolution, the camera turning, on a card of 6 GB or less (issue #939) and a Tier 1 discrete card: main @ 9dd41326 against this branch unset and with `RX_VK_TARGET_POOL_GRACE=0`, at least two starts a side, interleaved; expecting the pool's own lines to show it (`the pool let go of N over its bound` with N above 0 on main, `at most N MB over its bound` on the branch unset), fewer made new unset than with `=0`, the driver's VRAM peak against main, pictures at an input-free point the same as main within main against itself, no FATAL or device lost (on the Test Farm, or by hand) - Linux: build the renderer and run `python3 -I -B tests/test_target_pool_grace.py`, expecting PASS (by hand) ## Measurements **Verdict:** not measured in play yet. `RX_VK_TARGET_POOL_GRACE` ships at 4, as the branch shipped it; no measurement chose that default. The farm's Kokiri run did not exercise the grace (the pool never over its bound), so its figures say nothing of it; the A/B in Still to test does. ## Risks What could break: the pool holding more VRAM than its bound. Each image is in its grace for 4 presents at most, but while the camera keeps turning and new shapes keep arriving, the pool can sit near twice the bound for as long as that lasts: at worst one more bound's worth of render-target images than main's trim allows, the bound being `RX_VK_TARGET_POOL_MB` or a twelfth of the VRAM the driver allows, 256 to 768 MB, so 256 to 768 MB more by default (as much more as `RX_VK_TARGET_POOL_MB` says when set); not while VRAM is short. The ceiling of twice the bound is provisional, chosen, not derived from a measurement; the VRAM peak against main decides it, on 6 GB cards most of all (issue #939). Turn it off with `RX_VK_TARGET_POOL_GRACE=0`. Renderer code: the runtime is rebuilt; nothing changes for players' saves, options or caches. Overlap: #2054 (also siantm's) adds a lazy retirement path that checks `present_source`; whichever of it and #2064 lands second adds `dead_targets::present_held` to it. ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(vk): the render target pool's bound spares the images that came in the last presents (RX_VK_IMAGE_REUSE)
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 9s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
17c357dd55
Main already gives a dead render target's image to the pool at its retirement when the GPU is past it (destroy_later,
Hookshot-old's 7bba12ad), the half of the branch's image-reuse change that main has. What it lacks:

- The grace. The pool's bound is by what the pool holds at one moment, and the dead targets come to it several at once (a
  pass, 6-14 new targets a present while the camera turns); over the bound the trim destroyed them, 16 a present, and the
  next presents' targets of the same shapes were made new. Now an image put in the pool in the last
  RX_VK_TARGET_POOL_GRACE presents (4) is not counted out by the bound: until then its dead texture held it, so the VRAM held
  is no more than a present before. The idle limit (RX_VK_POOL_IDLE: 8, or 64 on an integrated GPU since #1681) still takes it, and while VRAM is short
  (pool_pressure) there is no grace. The grace must stay under the idle limit, or the bound gives nothing back (the branch's
  224a29b8 measured that: with 16 against main's 8 the pool grew to 1.4 GB over a 256 MB bound, tests/test_target_pool_room.py
  there).
- The image of a write-back that did not complete (the GPU may still be copying from it) and the image the present shows
  are not pooled at once by the eviction (destroy_later's pool_now); the dead targets' sweep and the retirement of images
  that served a new texture leave the present's image alone.

Measured on the branch (bd3ea307's notes, i7-9700, Kokiri Forest, the camera turning): BindImageMemory 3.2 % and
destroy_image 2.6 % of a core on the presenting thread, the cost this goes after; what it saves is not measured.

Test: tests/test_target_pool_grace.py runs the real pool (pool_put, pool_destroy, pool_trim and the switches) with
target_pool.h against stand-ins (main's pool since #1681: pool_unindex, the reaper's destroy_image_later) (the grace kept, the oldest past it going to the bound, the idle limit, no grace while VRAM
is short, =0 as before) and reads the eviction, the sweep and the retirement for the present's image. The checks that cut
destroy_later take its new signature.

Switches: RX_VK_IMAGE_REUSE (kill), on; =0 the bound counts every image, as before. RX_VK_TARGET_POOL_GRACE (tune), 4.

Switch reads: the test also runs RX_VK_IMAGE_REUSE and RX_VK_TARGET_POOL_GRACE as the source reads it, in fresh processes (unset, 0, 1, 2, off, each twice, the variable flipped after the first read: read once). RX_VK_TARGET_POOL_GRACE is read with strtoll and clamped to 0-1024 (not a number: 4).

Assisted-by: Claude Code
Member

Possibly related, for context:

  • PR #943 fix(vk): let render targets go as newer ones together cover them, and pool their images at once — Merged foundation for retiring and pooling completed target images
  • issue #939 Game: on a 6 GB card VRAM goes over the driver's allowance after a few area changes, Hyrule Field falls from 31 to 14 fps until a restart (GTX 1060, nightly-189) — Open 6 GB VRAM-pressure report includes target-image growth
Possibly related, for context: - PR #943 fix(vk): let render targets go as newer ones together cover them, and pool their images at once — Merged foundation for retiring and pooling completed target images - issue #939 Game: on a 6 GB card VRAM goes over the driver's allowance after a few area changes, Hyrule Field falls from 31 to 14 fps until a restart (GTX 1060, nightly-189) — Open 6 GB VRAM-pressure report includes target-image growth
BeanBot left a comment

Recommendation: Request changes. Regular eviction can erase the texture that the current present still uses, and a grace setting at or above the effective idle limit disables byte-cap eviction. The patch also leaves an existing pool fixture unable to compile its extracted trim function.

The grace gives recently retired render targets more time to be reused, which could reduce image creation and destruction while the camera moves. It keeps more image memory live across presents, and the retirement changes need a complete lifetime fix before they can protect every presentation route.

@fix will do (12)

  1. L1 gpu/vk/vk_texture.cpp:6050: Deferring pool insertion still erases the selected Texture and queues its image with the old last_value. (more on the line)
  2. L2 (minor) gpu/vk/vk_texture.cpp:4998: The new sweep exclusion relies on present_source, but do_present bypasses texture_for_present when it receives a null texture. (more on the line)
  3. L3 gpu/vk/vk_texture.cpp:594: The runtime never enforces the stated rule that grace stays below the effective idle limit. (more on the line)
  4. L4 (minor) gpu/vk/vk_texture.cpp:6049: The new failure condition delays reuse for write-backs that failed before submitting any GPU work. (more on the line)
  5. L5 tests/test_target_reuse_memory.py:436: This fixture extracts pool_trim without declaring or extracting its two new helpers. Its generated C++ now references undeclared image_reuse_on and pool_grace even once the existing base failure is addressed. Supply deterministic switch helpers and keep the checks for indexed trimming and reuse by size.
  6. L6 tests/test_target_pool_grace.py:146: The compiled pool fixture inherits RX_VK_TARGET_POOL_GRACE and RX_VK_POOL_IDLE. (more on the line)
  7. L7 tests/test_target_pool_grace.py:224: The compiled trim cases exercise the defaults and the kill switch. (more on the line)
  8. L8 tests/test_target_pool_grace.py:233: The lifetime checks match source strings. (more on the line)
  9. L9 (its part an edit can do) gpu/vk/vk_texture.cpp:599: Give grace its own byte ceiling above the usual trim target and log the peak excess between status lines.
  10. L10 (its part an edit can do): Record per-run deltas for exact reuse, reuse by size and new images so the frame-time result can be tied to the pool behavior.
  11. L11 (minor): The planned switch-off comparison assumes main behavior, but the source exclusions and failed-write-back delay run with either switch setting. A switch-off run can still retire different images. Describe it as a grace-only control, or land the retirement fix separately and use it on both sides of the grace comparison.
  12. L12 (minor) gpu/vk/switches.def:684: RX_VK_TARGET_POOL_MB still reads as a cap and the PR says grace is read at the first trim. (more on the line)

For the author (2) (a run, a measurement or a decision)

  • L9 gpu/vk/vk_texture.cpp:599: Measure peak pool bytes, process RAM and driver VRAM between pressure samples, including a heavy scene and a shared-memory device. (more on the line)
  • L10 (minor): Testing records Windows source checks but no game run, which the repository requires before opening renderer changes. Compare the exact head and base with the same save, repeatable route, driver, build and Auto settings. Report reuse and creation deltas, average FPS, 1% lows, median and p99 frame times for Kokiri Forest and a heavy scene. Include Tier 1 coverage, including Steam Deck and Windows and Linux NVIDIA and AMD.

Checks: Still running: CI / Conventional Commit title (pull_request), CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request), CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request), CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request), CI / Workflow lint (actionlint) (pull_request), CI / Website build and checks (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request), PR description / Description follows the template (pull_request_target).

More: does it help, other systems, switches, what was read

Does it help: Unproven. The earlier branch reported BindImageMemory at 3.2% of a core and image destruction at 2.6% of a core on the presenting thread in Kokiri Forest. Those figures locate the cost. No game run compares 17c357dd with 75317e1f or measures the savings, peak memory or frame pacing.

Other systems: Exact reuse and reuse by size share the larger pool. Reuse by size can take memory after one present and destroys the old image synchronously, so fewer reaper jobs alone cannot establish a replay-thread gain. Discrete GPUs and shared-memory devices use the same grace, including Steam Deck. Pressure and compaction still participate, but the regular trim can use a pressure sample up to nine presents old. Plain blit, headless capture and frame generation consume the selected source after texture maintenance. The diff leaves shader translation, the renderer API, saves, player settings, audio and input untouched.

Switches: RX_VK_IMAGE_REUSE is a new developer kill switch, on by default and read once. Off disables grace but leaves the retirement changes active. RX_VK_TARGET_POOL_GRACE is a new tuning switch, default 4 presents, parsed into 0–1024, with 0 disabling grace. Its effective upper bound must stay below RX_VK_POOL_IDLE, including overrides. Both have sorted switch-table rows. The on and 4-present defaults still need measurements, and the RX_VK_TARGET_POOL_MB row needs to describe the permitted overshoot.

Reviewed: 17c357dd55 against 75317e1f31: Read the seven-file diff, the commit and trailer, all five changed Python tests, both switch entries and their neighboring pool entries, and the changed renderer functions with their eviction, timeline, present, read-back, compaction and reaper callers. Read AGENTS.md, CONTRIBUTING.md, the Forgejo template and developer standards. Read the applicable architecture, switch, measurement and screenshot rules and the dependent source-test sections. Renderer and switch-table sections outside these paths were skimmed or left unread. The description contains the run summary. Raw results were unavailable, and there were no tester comments, earlier reviews, generated files or translations in the diff. The checkout has no docs/review-checklist.md or sibling Tooling repository.; nothing run (a code review).

Checked and fine:

  • Pool indexing and trim bookkeeping remain under pool_mu. The new static switch caches use C++ thread-safe initialization, and the present-source reads and writes in the reviewed maintenance paths are serialized by replay_mu.
  • The trim keeps oldest-first ordering and honors the existing idle predicate and pressure-specific trim limits. The existing timeout path still keeps busy write-back sources and advances last_value when a submitted copy fails to complete.
  • The commit contains an Assisted-by trailer. The diff contains synthetic fixtures and no game-derived assets, generated outputs, third-party edits or API version changes.
  • The new test uses standard-library Python and local temporary fixtures. Its compile-and-run behavior is documented, and it introduces no downloads or external service calls. The checked diff has no whitespace errors.

Testing: Read-only review. The author reports 75 of 88 checks passing on Windows and names 13 checks that also fail at the base. The missing trim dependencies are visible in the source even though that fixture already fails at the base. No Linux renderer build or game run is recorded. The supplied CI jobs are still running.

Overlaps and merge order: No overlapping pull request found in the supplied material or local history. Forgejo overlap status was unavailable offline.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** Regular eviction can erase the texture that the current present still uses, and a grace setting at or above the effective idle limit disables byte-cap eviction. The patch also leaves an existing pool fixture unable to compile its extracted trim function. The grace gives recently retired render targets more time to be reused, which could reduce image creation and destruction while the camera moves. It keeps more image memory live across presents, and the retirement changes need a complete lifetime fix before they can protect every presentation route. **`@fix` will do (12)** 1. **L1** `gpu/vk/vk_texture.cpp:6050`: Deferring pool insertion still erases the selected Texture and queues its image with the old last_value. (more on the line) 2. **L2** (minor) `gpu/vk/vk_texture.cpp:4998`: The new sweep exclusion relies on present_source, but do_present bypasses texture_for_present when it receives a null texture. (more on the line) 3. **L3** `gpu/vk/vk_texture.cpp:594`: The runtime never enforces the stated rule that grace stays below the effective idle limit. (more on the line) 4. **L4** (minor) `gpu/vk/vk_texture.cpp:6049`: The new failure condition delays reuse for write-backs that failed before submitting any GPU work. (more on the line) 5. **L5** `tests/test_target_reuse_memory.py:436`: This fixture extracts pool_trim without declaring or extracting its two new helpers. Its generated C++ now references undeclared image_reuse_on and pool_grace even once the existing base failure is addressed. Supply deterministic switch helpers and keep the checks for indexed trimming and reuse by size. 6. **L6** `tests/test_target_pool_grace.py:146`: The compiled pool fixture inherits RX_VK_TARGET_POOL_GRACE and RX_VK_POOL_IDLE. (more on the line) 7. **L7** `tests/test_target_pool_grace.py:224`: The compiled trim cases exercise the defaults and the kill switch. (more on the line) 8. **L8** `tests/test_target_pool_grace.py:233`: The lifetime checks match source strings. (more on the line) 9. **L9** (its part an edit can do) `gpu/vk/vk_texture.cpp:599`: Give grace its own byte ceiling above the usual trim target and log the peak excess between status lines. 10. **L10** (its part an edit can do): Record per-run deltas for exact reuse, reuse by size and new images so the frame-time result can be tied to the pool behavior. 11. **L11** (minor): The planned switch-off comparison assumes main behavior, but the source exclusions and failed-write-back delay run with either switch setting. A switch-off run can still retire different images. Describe it as a grace-only control, or land the retirement fix separately and use it on both sides of the grace comparison. 12. **L12** (minor) `gpu/vk/switches.def:684`: RX_VK_TARGET_POOL_MB still reads as a cap and the PR says grace is read at the first trim. (more on the line) **For the author (2)** (a run, a measurement or a decision) - **L9** `gpu/vk/vk_texture.cpp:599`: Measure peak pool bytes, process RAM and driver VRAM between pressure samples, including a heavy scene and a shared-memory device. (more on the line) - **L10** (minor): Testing records Windows source checks but no game run, which the repository requires before opening renderer changes. Compare the exact head and base with the same save, repeatable route, driver, build and Auto settings. Report reuse and creation deltas, average FPS, 1% lows, median and p99 frame times for Kokiri Forest and a heavy scene. Include Tier 1 coverage, including Steam Deck and Windows and Linux NVIDIA and AMD. **Checks:** Still running: `CI / Conventional Commit title (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request)`, `CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `CI / Website build and checks (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`, `PR description / Description follows the template (pull_request_target)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The earlier branch reported BindImageMemory at 3.2% of a core and image destruction at 2.6% of a core on the presenting thread in Kokiri Forest. Those figures locate the cost. No game run compares 17c357dd with 75317e1f or measures the savings, peak memory or frame pacing. **Other systems:** Exact reuse and reuse by size share the larger pool. Reuse by size can take memory after one present and destroys the old image synchronously, so fewer reaper jobs alone cannot establish a replay-thread gain. Discrete GPUs and shared-memory devices use the same grace, including Steam Deck. Pressure and compaction still participate, but the regular trim can use a pressure sample up to nine presents old. Plain blit, headless capture and frame generation consume the selected source after texture maintenance. The diff leaves shader translation, the renderer API, saves, player settings, audio and input untouched. **Switches:** RX_VK_IMAGE_REUSE is a new developer kill switch, on by default and read once. Off disables grace but leaves the retirement changes active. RX_VK_TARGET_POOL_GRACE is a new tuning switch, default 4 presents, parsed into 0–1024, with 0 disabling grace. Its effective upper bound must stay below RX_VK_POOL_IDLE, including overrides. Both have sorted switch-table rows. The on and 4-present defaults still need measurements, and the RX_VK_TARGET_POOL_MB row needs to describe the permitted overshoot. **Reviewed:** 17c357dd55ca against 75317e1f31ff: Read the seven-file diff, the commit and trailer, all five changed Python tests, both switch entries and their neighboring pool entries, and the changed renderer functions with their eviction, timeline, present, read-back, compaction and reaper callers. Read AGENTS.md, CONTRIBUTING.md, the Forgejo template and developer standards. Read the applicable architecture, switch, measurement and screenshot rules and the dependent source-test sections. Renderer and switch-table sections outside these paths were skimmed or left unread. The description contains the run summary. Raw results were unavailable, and there were no tester comments, earlier reviews, generated files or translations in the diff. The checkout has no docs/review-checklist.md or sibling Tooling repository.; nothing run (a code review). **Checked and fine:** - Pool indexing and trim bookkeeping remain under pool_mu. The new static switch caches use C++ thread-safe initialization, and the present-source reads and writes in the reviewed maintenance paths are serialized by replay_mu. - The trim keeps oldest-first ordering and honors the existing idle predicate and pressure-specific trim limits. The existing timeout path still keeps busy write-back sources and advances last_value when a submitted copy fails to complete. - The commit contains an Assisted-by trailer. The diff contains synthetic fixtures and no game-derived assets, generated outputs, third-party edits or API version changes. - The new test uses standard-library Python and local temporary fixtures. Its compile-and-run behavior is documented, and it introduces no downloads or external service calls. The checked diff has no whitespace errors. **Testing:** Read-only review. The author reports 75 of 88 checks passing on Windows and names 13 checks that also fail at the base. The missing trim dependencies are visible in the source even though that fixture already fails at the base. No Linux renderer build or game run is recorded. The supplied CI jobs are still running. **Overlaps and merge order:** No overlapping pull request found in the supplied material or local history. Forgejo overlap status was unavailable offline. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -680,3 +681,4 @@
SW(RX_VK_TAAU_FXAA, kill, int, "1: FXAA in the stand-in's shader", "0 gives the plain linear upscale as before; 2 draws the pixels FXAA changed in red.")
SW(RX_VK_TAAU_KEYS, hw, string, "fd029a317a9a4b94 where the network runs on software multiplies (or RX_VK_NO_F16), else '-' (the network runs)", "Program key prefixes whose upscale network is replaced by the renderer's TAAU stand-in; '-' replaces none.")
SW(RX_VK_TARGET_POOL_GRACE, tune, int, "4 presents (unset or not a number; under RX_VK_POOL_IDLE's 8, so the bound can act)", "Presents an image put in the target pool is not counted out by its bound (with RX_VK_IMAGE_REUSE), 0 to 1024 (clamped); 0: none. Read once, at the first trim.")
SW(RX_VK_TARGET_POOL_MB, hw, int, "a twelfth of the VRAM the driver allows, 256 to 768 MB", "Cap, in MB, on the pool of render targets kept for reuse.")
Member

L12 (minor): RX_VK_TARGET_POOL_MB still reads as a cap and the PR says grace is read at the first trim. A recent batch can exceed the stated cap, and a first trim under pressure skips the grace read. Document the cap as the normal trim target and give the grace read timing and effective limits in the table and developer switch reference.

**L12** (minor): RX_VK_TARGET_POOL_MB still reads as a cap and the PR says grace is read at the first trim. A recent batch can exceed the stated cap, and a first trim under pressure skips the grace read. Document the cap as the normal trim target and give the grace read timing and effective limits in the table and developer switch reference.
@ -566,2 +591,4 @@
const uint64_t cap = (pool_pressure >= 2) ? 0 : (pool_pressure == 1) ? (full_cap / 2) : full_cap;
const size_t most = (pool_pressure > 0) ? 64 : 16;
// (longshot, RX_VK_IMAGE_REUSE: what came in the last presents is not counted out by the bound, above. Not while VRAM is short)
const uint64_t grace = image_reuse_on() && !pool_pressure ? pool_grace() : 0;
Member

L3: The runtime never enforces the stated rule that grace stays below the effective idle limit. With RX_VK_TARGET_POOL_GRACE=64 on a default Steam Deck, or with the default grace and RX_VK_POOL_IDLE=2, every non-idle entry is protected. The byte cap then has no effect before pressure is detected. Clamp effective grace below the configured idle limit and cover the override in the compiled test.

**L3**: The runtime never enforces the stated rule that grace stays below the effective idle limit. With RX_VK_TARGET_POOL_GRACE=64 on a default Steam Deck, or with the default grace and RX_VK_POOL_IDLE=2, every non-idle entry is protected. The byte cap then has no effect before pressure is detected. Clamp effective grace below the configured idle limit and cover the override in the compiled test.
@ -570,2 +597,3 @@
Pooled& oldest = pool_by_age.front();
if (pool_bytes <= cap && !target_pool::idle_out(frame_no, oldest.since, idle)) break;
if (!target_pool::idle_out(frame_no, oldest.since, idle) &&
(pool_bytes <= cap || (grace && frame_no - oldest.since <= grace))) break;
Member

L9: Measure peak pool bytes, process RAM and driver VRAM between pressure samples, including a heavy scene and a shared-memory device. A 600-present snapshot can miss a whole grace window. The same images were live before retirement, but the branch can keep them while allocating the next set.

**L9**: Measure peak pool bytes, process RAM and driver VRAM between pressure samples, including a heavy scene and a shared-memory device. A 600-present snapshot can miss a whole grace window. The same images were live before retirement, but the branch can keep them while allocating the next set.
@ -4967,3 +4996,3 @@
bool any = false;
const auto candidate = [&](const Texture* tex) {
return tex->gpu_written && tex->first_render_frame && tex->guest_size &&
return tex != present_source && tex->gpu_written && tex->first_render_frame && tex->guest_size &&
Member

L2 (minor): The new sweep exclusion relies on present_source, but do_present bypasses texture_for_present when it receives a null texture. Blank presents can therefore keep excluding the previous source even when it is an otherwise eligible overlapped target. Set the source on every present, including null presents, or pass the selected source into maintenance.

**L2** (minor): The new sweep exclusion relies on present_source, but do_present bypasses texture_for_present when it receives a null texture. Blank presents can therefore keep excluding the previous source even when it is an otherwise eligible overlapped target. Set the source on every present, including null presents, or pass the selected source into maintenance.
@ -6017,1 +6047,3 @@
destroy_later(*tex, completed);
// (longshot, RX_VK_IMAGE_REUSE: a render target's image goes to the pool at once, destroy_later; not one whose write-back
// above did not complete, whose copy the GPU may still be at, nor the one this present shows)
const bool flush_failed = e.flush && !flushed_ok.count(tex);
Member

L4 (minor): The new failure condition delays reuse for write-backs that failed before submitting any GPU work. For example, a staging allocation failure leaves an otherwise completed target on the dead list for another present, so the next matching target can allocate a new image. A pending timeout already skips eviction through flush_later, and a failed submitted batch already raises last_value. Keep those existing protections and remove the blanket pool delay for failed write-backs.

**L4** (minor): The new failure condition delays reuse for write-backs that failed before submitting any GPU work. For example, a staging allocation failure leaves an otherwise completed target on the dead list for another present, so the next matching target can allocate a new image. A pending timeout already skips eviction through flush_later, and a failed submitted batch already raises last_value. Keep those existing protections and remove the blanket pool delay for failed write-backs.
@ -6018,0 +6047,4 @@
// (longshot, RX_VK_IMAGE_REUSE: a render target's image goes to the pool at once, destroy_later; not one whose write-back
// above did not complete, whose copy the GPU may still be at, nor the one this present shows)
const bool flush_failed = e.flush && !flushed_ok.count(tex);
destroy_later(*tex, completed, !flush_failed && tex != present_source);
Member

L1: Deferring pool insertion still erases the selected Texture and queues its image with the old last_value. When texture_for_present falls back to a differently described rendered image, a plain blit may leave its age and timeline value unchanged. If the tenth-present eviction selects that old, overlapped image, a later headless or frame-generation access can dereference the erased Texture, and the next dead-list drain can recycle the image before the present copy finishes. Exclude the active source from eviction selection and hold its image and views through completion of the actual consuming submission, including the separately submitted window copy.

**L1**: Deferring pool insertion still erases the selected Texture and queues its image with the old last_value. When texture_for_present falls back to a differently described rendered image, a plain blit may leave its age and timeline value unchanged. If the tenth-present eviction selects that old, overlapped image, a later headless or frame-generation access can dereference the erased Texture, and the next dead-list drain can recycle the image before the present copy finishes. Exclude the active source from eviction selection and hold its image and views through completion of the actual consuming submission, including the separately submitted window copy.
@ -0,0 +143,4 @@
# (-Wno-unused-variable: the pool's counters the trim does not touch come with the cut, as pool_take_memory's)
subprocess.run([cxx, "-std=c++20", "-O1", "-Wall", "-Wextra", "-Werror", "-Wno-unused-function", "-Wno-unused-variable",
"-Wno-missing-field-initializers", "-I", str(ROOT / "gpu" / "vk"), str(src), "-o", str(exe)], check=True)
r = subprocess.run([str(exe)], text=True, capture_output=True, timeout=30)
Member

L6: The compiled pool fixture inherits RX_VK_TARGET_POOL_GRACE and RX_VK_POOL_IDLE. A shell with grace set to 0 makes the default-grace test fail, and an idle override can change the age boundary. Clear both names case-insensitively for the default cases and pass explicit environments for the overrides.

**L6**: The compiled pool fixture inherits RX_VK_TARGET_POOL_GRACE and RX_VK_POOL_IDLE. A shell with grace set to 0 makes the default-grace test fail, and an idle override can change the age boundary. Clear both names case-insensitively for the default cases and pass explicit environments for the overrides.
@ -0,0 +221,4 @@
+ block(tex, "size_t pool_trim()"))
base = (FIXTURE.replace("/* DEAD */", block(tex, "struct Dead {") + ";").replace("/* SWITCHES */", switches)
.replace("/* POOL */", pool).replace("/* PUT_TRIM */", put_trim))
compiled(a.cxx, "pool_grace", base.replace("/* MAIN */", ON))
Member

L7: The compiled trim cases exercise the defaults and the kill switch. They never run a same-present trim with the kill switch on and grace set to 0. Removing the grace truthiness check at vk_texture.cpp:599 would wrongly protect age-zero entries and still pass. Run that case, and test the effective idle boundary with a configured grace at or above it.

**L7**: The compiled trim cases exercise the defaults and the kill switch. They never run a same-present trim with the kill switch on and grace set to 0. Removing the grace truthiness check at vk_texture.cpp:599 would wrongly protect age-zero entries and still pass. Run that case, and test the effective idle boundary with a configured grace at or above it.
@ -0,0 +230,4 @@
need("inline constexpr uint64_t kIdlePresents = 8;" in target_pool and
"inline constexpr uint64_t kIdlePresentsReuse = 64;" in target_pool,
"RX_VK_POOL_IDLE's defaults changed: the grace (4) must stay under them, or the bound gives nothing back")
later = block(tex, "void destroy_later(Texture& tex, uint64_t completed, bool pool_now = true)")
Member

L8: The lifetime checks match source strings. All of them can pass while regular eviction still erases the source before the present reads it. Exercise eviction and dead-list retirement with a selected fallback source and a stub completion signal. Assert that the texture remains usable for recording and that neither reuse nor destruction occurs before the consuming submission completes.

**L8**: The lifetime checks match source strings. All of them can pass while regular eviction still erases the source before the present reads it. Exercise eviction and dead-list retirement with a selected fallback source and a stub completion signal. Assert that the texture remains usable for recording and that neither reuse nor destruction occurs before the consuming submission completes.
siantm force-pushed perf/vk-image-reuse from 17c357dd55
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 9s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to e88ea1b701
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by dyst (reviewed)
beanstalk/linux+nvidia 2/1 fail
beanstalk/linux+radv 2/1 fail
beanstalk/windows+intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 0 running, 2 queued
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-21 04:53:21 +00:00
Compare
Author
Contributor

Thanks for the review (#1996 (comment)). The branch is rebased onto main @ f1f2dc5b; the PR's own commit is unchanged by the rebase (now 39c1c0bc). Two commits on top: cbc77c78 (the tests) and e88ea1b7 (the fix). Point by point:

  • L1 (#1996 (comment)): right. Not pooling the source at once still erased its Texture and queued its image. In e88ea1b7 texture_for_present marks the texture it picks, including the fallback in another description (Texture::presented). The eviction in texture_frame, dead_targets_sweep and reuse_retire_frame now skip a texture a present showed in the last dead_targets::kPresentHold (9) presents. So it is not erased, and its image and views stay while the present's recording, the headless and frame-generation paths and the window's copy use them. The window copy is only known to be done when its frame slot's fence is waited, at most kPresentSlotsMax (8) presents later and after that present's texture_frame; a static_assert ties the two constants. The hold counts presents, so it assumes the queue finishes the copy by the time that fence is waited, as present_image's own slot reuse does.
  • L2 (#1996 (comment)): right. do_present now calls texture_for_present for a null texture too, and it sets no source (e88ea1b7). The hold above no longer depends on present_source.
  • L3 (#1996 (comment)): right. target_pool::effective_grace keeps the grace at the idle limit less one at most, whatever both are set to (e88ea1b7). The compiled test runs RX_VK_TARGET_POOL_GRACE=8 and RX_VK_POOL_IDLE=2: the bound acts on an image as old as the idle limit.
  • L4 (#1996 (comment)): right. With the source no longer evicted, destroy_later is main's again, without pool_now (e88ea1b7). A submitted write-back that did not complete already raises last_value (flush_textures), and a busy one stays through flush_later. The four tests that had followed the signature are main's again.
  • L5 (review item 5): right. tests/test_target_reuse_memory.py's fixture now has fixed image_reuse_on (off) and pool_grace (0) stand-ins and the new counter, so its pool_trim compiles whatever the environment, and its indexed-trim and reuse-by-size checks are kept (cbc77c78). With the Vulkan headers, the PR's commit failed on the undeclared helpers; at the head it fails only as on main (destroy_image_later undeclared in its fixture, vmaGetAllocationInfo2 found), which this PR leaves alone.
  • L6 (#1996 (comment)): right. Each compiled case now runs in a process with RX_VK_TARGET_POOL_GRACE, RX_VK_POOL_IDLE and RX_VK_IMAGE_REUSE removed from its environment (any case) and then set as the case says (cbc77c78).
  • L7 (#1996 (comment)): right. Added a same-present trim with reuse on and RX_VK_TARGET_POOL_GRACE=0 (two of three age-0 images go), the idle boundary with a grace at or over the idle limit (L3), and twice the bound as the grace's ceiling (cbc77c78).
  • L8 (#1996 (comment)): mostly done. The real texture_for_present, dead_targets_sweep and reuse_retire_frame are now cut and run (cbc77c78). A fallback source that another target drew over is neither swept nor retired while other textures are shown, and it goes once the hold ends; a null present has no source. On the PR's code this case fails: the source is swept at the next present. texture_frame's eviction pass is run too, in tests/test_target_retention.py case 3: a texture shown in the 9 presents before, its storage written over, stays, then goes; on the PR's code it is evicted. The static_assert is still a source check. The hold is counted in presents, not tied to a completion signal (see L1).
  • L9 (#1996 (comment)): the part an edit can do is done in e88ea1b7. Images in their grace are held only while the pool is at most twice its bound (target_pool::grace_ceiling). The 600-present render target images line now gives the most the pool held over its bound after a trim since the previous line. Measuring peak pool bytes, process RAM and driver VRAM in a heavy scene and on a shared-memory device needs runs in the game; that is pending and in Still to test.
  • L10 (review item 10): pending runs in the game. The render target images counts are cumulative, so a run's deltas are its last line minus its first; Still to test now asks for those deltas (reused, made new, reused by size, most held over the bound) next to average FPS, 1% lows, median and p99 frame times, RAM and VRAM, for Kokiri Forest and a heavy area on the Tier 1 systems.
  • L11 (review item 11): right. The present's hold runs with either setting, so Still to test now calls RX_VK_IMAGE_REUSE=0 a grace-only control, and the description says the hold stays on.
  • L12 (#1996 (comment)): right. RX_VK_TARGET_POOL_MB's row now describes it as the trim's bound, which the grace may keep up to twice for a few presents. RX_VK_TARGET_POOL_GRACE's row gives the clamp under RX_VK_POOL_IDLE and says it is read at the first trim while VRAM is not short. RX_VK_IMAGE_REUSE=0's row says the present's hold stays (e88ea1b7). docs/dev/reference/switches.md has no rows for the pool's switches.

Checked on this PC at the head e88ea1b7 (main f1f2dc5b), through the job queue (fb-1996-1 to fb-1996-3, fb-1993-base): the test commit's checks fail on the PR's code and pass at the head; of the 205 checks --changed picks, the 52 that fail also fail on main @ f1f2dc5b; vk_texture.cpp and vk_replay.cpp compiled with the game build's own commands. The description's Summary, Testing and Risks are updated. Not run in the game on this PC yet.

Thanks for the review (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62996). The branch is rebased onto main @ f1f2dc5b; the PR's own commit is unchanged by the rebase (now 39c1c0bc). Two commits on top: cbc77c78 (the tests) and e88ea1b7 (the fix). Point by point: - **L1** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62987): right. Not pooling the source at once still erased its Texture and queued its image. In e88ea1b7 `texture_for_present` marks the texture it picks, including the fallback in another description (`Texture::presented`). The eviction in `texture_frame`, `dead_targets_sweep` and `reuse_retire_frame` now skip a texture a present showed in the last `dead_targets::kPresentHold` (9) presents. So it is not erased, and its image and views stay while the present's recording, the headless and frame-generation paths and the window's copy use them. The window copy is only known to be done when its frame slot's fence is waited, at most `kPresentSlotsMax` (8) presents later and after that present's `texture_frame`; a `static_assert` ties the two constants. The hold counts presents, so it assumes the queue finishes the copy by the time that fence is waited, as present_image's own slot reuse does. - **L2** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62988): right. `do_present` now calls `texture_for_present` for a null texture too, and it sets no source (e88ea1b7). The hold above no longer depends on `present_source`. - **L3** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62989): right. `target_pool::effective_grace` keeps the grace at the idle limit less one at most, whatever both are set to (e88ea1b7). The compiled test runs `RX_VK_TARGET_POOL_GRACE=8` and `RX_VK_POOL_IDLE=2`: the bound acts on an image as old as the idle limit. - **L4** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62990): right. With the source no longer evicted, `destroy_later` is main's again, without `pool_now` (e88ea1b7). A submitted write-back that did not complete already raises `last_value` (`flush_textures`), and a busy one stays through `flush_later`. The four tests that had followed the signature are main's again. - **L5** (review item 5): right. `tests/test_target_reuse_memory.py`'s fixture now has fixed `image_reuse_on` (off) and `pool_grace` (0) stand-ins and the new counter, so its `pool_trim` compiles whatever the environment, and its indexed-trim and reuse-by-size checks are kept (cbc77c78). With the Vulkan headers, the PR's commit failed on the undeclared helpers; at the head it fails only as on main (`destroy_image_later` undeclared in its fixture, `vmaGetAllocationInfo2` found), which this PR leaves alone. - **L6** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62991): right. Each compiled case now runs in a process with `RX_VK_TARGET_POOL_GRACE`, `RX_VK_POOL_IDLE` and `RX_VK_IMAGE_REUSE` removed from its environment (any case) and then set as the case says (cbc77c78). - **L7** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62992): right. Added a same-present trim with reuse on and `RX_VK_TARGET_POOL_GRACE=0` (two of three age-0 images go), the idle boundary with a grace at or over the idle limit (L3), and twice the bound as the grace's ceiling (cbc77c78). - **L8** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62993): mostly done. The real `texture_for_present`, `dead_targets_sweep` and `reuse_retire_frame` are now cut and run (cbc77c78). A fallback source that another target drew over is neither swept nor retired while other textures are shown, and it goes once the hold ends; a null present has no source. On the PR's code this case fails: the source is swept at the next present. `texture_frame`'s eviction pass is run too, in `tests/test_target_retention.py` case 3: a texture shown in the 9 presents before, its storage written over, stays, then goes; on the PR's code it is evicted. The `static_assert` is still a source check. The hold is counted in presents, not tied to a completion signal (see L1). - **L9** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62994): the part an edit can do is done in e88ea1b7. Images in their grace are held only while the pool is at most twice its bound (`target_pool::grace_ceiling`). The 600-present `render target images` line now gives the most the pool held over its bound after a trim since the previous line. Measuring peak pool bytes, process RAM and driver VRAM in a heavy scene and on a shared-memory device needs runs in the game; that is pending and in Still to test. - **L10** (review item 10): pending runs in the game. The `render target images` counts are cumulative, so a run's deltas are its last line minus its first; Still to test now asks for those deltas (reused, made new, reused by size, most held over the bound) next to average FPS, 1% lows, median and p99 frame times, RAM and VRAM, for Kokiri Forest and a heavy area on the Tier 1 systems. - **L11** (review item 11): right. The present's hold runs with either setting, so Still to test now calls `RX_VK_IMAGE_REUSE=0` a grace-only control, and the description says the hold stays on. - **L12** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-62995): right. `RX_VK_TARGET_POOL_MB`'s row now describes it as the trim's bound, which the grace may keep up to twice for a few presents. `RX_VK_TARGET_POOL_GRACE`'s row gives the clamp under `RX_VK_POOL_IDLE` and says it is read at the first trim while VRAM is not short. `RX_VK_IMAGE_REUSE=0`'s row says the present's hold stays (e88ea1b7). `docs/dev/reference/switches.md` has no rows for the pool's switches. Checked on this PC at the head e88ea1b7 (main f1f2dc5b), through the job queue (`fb-1996-1` to `fb-1996-3`, `fb-1993-base`): the test commit's checks fail on the PR's code and pass at the head; of the 205 checks `--changed` picks, the 52 that fail also fail on main @ f1f2dc5b; `vk_texture.cpp` and `vk_replay.cpp` compiled with the game build's own commands. The description's Summary, Testing and Risks are updated. Not run in the game on this PC yet.
Author
Contributor

@Beanstalk This changes the render target pool (gpu/vk): an image put in the pool in the last 4 presents (RX_VK_TARGET_POOL_GRACE) is not counted out by the pool's bound, so targets of the same shapes are reused instead of destroyed and made new while the camera turns, and the image the present shows is never pooled at once. RX_VK_IMAGE_REUSE, a kill switch on by default, turns the grace off with RX_VK_IMAGE_REUSE=0 (the present's image stays held). It has not run in the game on these PCs yet. Please play Kokiri Forest for three minutes turning the camera around, after a minute's warm-up, the PR against main on the same PC, on the PR's side with the switch unset and with RX_VK_IMAGE_REUSE=0, with a picture compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with Intel and the Steam Deck. The same picture, no crash, device lost or FATAL line; peak VRAM about main's; unset, more render target images reused and fewer made new in the log's render target images line than with it off, and frame time p99 equal to main's or better. Please report that line's counts.

@Beanstalk This changes the render target pool (gpu/vk): an image put in the pool in the last 4 presents (RX_VK_TARGET_POOL_GRACE) is not counted out by the pool's bound, so targets of the same shapes are reused instead of destroyed and made new while the camera turns, and the image the present shows is never pooled at once. RX_VK_IMAGE_REUSE, a kill switch on by default, turns the grace off with RX_VK_IMAGE_REUSE=0 (the present's image stays held). It has not run in the game on these PCs yet. Please play Kokiri Forest for three minutes turning the camera around, after a minute's warm-up, the PR against main on the same PC, on the PR's side with the switch unset and with RX_VK_IMAGE_REUSE=0, with a picture compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with Intel and the Steam Deck. The same picture, no crash, device lost or FATAL line; peak VRAM about main's; unset, more render target images reused and fewer made new in the log's render target images line than with it off, and frame time p99 equal to main's or better. Please report that line's counts.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

Description only (no push): Risks now says the grace's ceiling of twice the bound is provisional, not from a measurement, and its worst case: one more bound of render-target images after a trim than main's trim allows (the bound is RX_VK_TARGET_POOL_MB, else a twelfth of the VRAM the driver allows, 256 to 768 MB: 256 to 768 MB more by default) for up to the grace's 4 presents, not while VRAM is short. Still to test names the in-game VRAM peak against main as the run that settles it.

Description only (no push): Risks now says the grace's ceiling of twice the bound is provisional, not from a measurement, and its worst case: one more bound of render-target images after a trim than main's trim allows (the bound is RX_VK_TARGET_POOL_MB, else a twelfth of the VRAM the driver allows, 256 to 768 MB: 256 to 768 MB more by default) for up to the grace's 4 presents, not while VRAM is short. Still to test names the in-game VRAM peak against main as the run that settles it.
Author
Contributor

Description corrected (Testing; no push, the head is still e88ea1b7). 33 of the 52 checks it counted as failing on main as well were renderer checks that had not compiled, at the head or on main: this PC's run had no Vulkan headers, and under --strict they stopped at not found: vulkan_headers. Run again with the headers (RX_CPM set, --strict, 20 min per check) in build job fb-vkfix-1 at e88ea1b7 and on main @ f1f2dc5b: 18 pass here and on main, 15 fail on main too with the headers found. None fails only at this head. The per-check list is in Testing.

Description corrected (Testing; no push, the head is still e88ea1b7). 33 of the 52 checks it counted as failing on main as well were renderer checks that had not compiled, at the head or on main: this PC's run had no Vulkan headers, and under `--strict` they stopped at `not found: vulkan_headers`. Run again with the headers (`RX_CPM` set, `--strict`, 20 min per check) in build job `fb-vkfix-1` at e88ea1b7 and on main @ f1f2dc5b: 18 pass here and on main, 15 fail on main too with the headers found. None fails only at this head. The per-check list is in Testing.
dyst left a comment

Verdict: Comment. I'd approve this once it is out of WIP and the farm run is in. The grace is a small, bounded change to the trim that leaves the pooling points alone, every BeanBot point is fixed in the code and has a test that fails without the fix, and the hold on the present's source closes a real lifetime gap (on main, texture_frame runs between texture_for_present and present_image, so a stale fallback source could be evicted before the window copied it). What's left is the in-game run, and the VRAM peak it reports against main matters most.

For a player: fewer render-target images destroyed and made again while the camera turns, which should mean less work on the presenting thread. The cost is up to one more pool bound of VRAM (256 to 768 MB by default) while it does that. The gain isn't measured yet.

Reviewed: e88ea1b7 against f1f2dc5b (the merge base). Read in full where they changed: gpu/vk/vk_texture.cpp (pool_trim, image_reuse_on, pool_grace, texture_for_present, dead_targets_sweep, reuse_retire_frame, the eviction pass and the 600-present line), gpu/vk/vk_texture.h, gpu/vk/target_pool.h, gpu/vk/dead_targets.h, gpu/vk/vk_replay.cpp (do_present up to present_image), the gpu/vk/switches.def rows, tests/test_target_pool_grace.py, tests/test_target_retention.cpp and tests/test_target_reuse_memory.py. Also read the code they rely on: destroy_later, pool_put, pool_take_memory, compact_step's source check and the ASTC reuse retirement. I checked that the source-reading checks touching these functions (test_dead_targets_sweep.py, test_target_image_pool.py, test_image_reaper.py, test_mem_account.py) still find their strings. Nothing was run; this is a code review.
Fixed in this review: nothing.
Checked and fine:

  • BeanBot's points are fixed in the code, not only in the reply:
    • L1: the hold covers the only three places a Texture leaves the table: the eviction, the sweep and the retirement. The fallback source is marked too.
    • L2: a null present now clears present_source.
    • L3: effective_grace keeps the grace at the idle limit less one.
    • L4: destroy_later is back to main's code.
    • L5: the fixture has stubs for the two new helpers.
    • L6: each compiled case runs with a cleaned environment.
    • L7: the same-present case with GRACE=0 fails if the grace && test is dropped.
    • L8: the real texture_for_present, sweep and retirement are cut from the source and run, and retention case 3 runs the eviction pass.
    • L9: the ceiling and the over-bound peak are in the 600-present line.
    • L12: the switch rows are updated.
  • The hold's length holds up: presented is set before texture_frame's frame_no++, so the source is released at the 9th present's texture_frame. By then the slot fence of the present that last showed it has been waited (at most kPresentSlotsMax = 8 slots), and the static_assert ties the two constants together.
  • The trim stays oldest first. When the oldest image is in its grace, every image is, so the break condition is right. The idle limit still wins. Pressure turns the grace off. st_pool_over_peak is written and read under pool_mu.
  • A held ASTC source skipped by reuse_retire_frame stays a normal texture, and the eviction takes it later. Its image was copied, not shared, so nothing reads freed memory.
  • pool_grace parses as its test says: unset or not a number gives 4, the value is clamped to 0 to 1024, and it is read once.
  • Both switches ship at their intended defaults (on, 4 presents), as the standards ask for a WIP branch.
  • The new test only compiles fixtures in a temporary directory and runs them there. It downloads nothing and deletes nothing outside that directory.

Suggestions (the author may take or leave)

  • Rebase: it conflicts with current main in texture_for_present and do_present. Main added t->output_preview and dropped_output there. This is more than a textual conflict. A dropped output has to go through the null path (texture_for_present(dropped_output ? nullptr : t)), so it clears present_source as L2 wanted. The output_preview early return has to set presented as well, or the preview's texture isn't held. Ideally rebase before the farm builds it.
  • Risks wording: it says the pool holds up to twice the bound "for up to the grace's 4 presents". That is true of each image, but not of the pool. While the camera keeps turning and new shapes keep arriving, the pool can sit near twice the bound for as long as that lasts. Please say so, since it is what the VRAM peak against main has to show, most of all on 6 GB cards (issue #939 is already there).
  • vk_texture.cpp:5912: the compaction hold's first pass counts a held source in hold_dead, but the main loop then skips it. It is one texture over-counted, but adding the same present_held skip there keeps the two passes in step.
  • vk_texture.cpp:4879: compaction still excludes only present_source (the current present), not what present_held holds. Render targets are probably outside the compacted pool, but using present_held there too would make "the source is held for 9 presents" true for every path.
  • One topic: the present's hold fixes a lifetime bug that is on main and runs with either setting. As its own small fix PR it would land even if the grace's A/B goes against the grace, and the farm comparison would then be grace only.
  • Two off switches: RX_VK_IMAGE_REUSE=0 and RX_VK_TARGET_POOL_GRACE=0 turn off the same thing. Consider keeping one: the tune switch at 0 is the kill switch.
  • Overlap with #2054: that PR adds a lazy retirement path whose stays test checks tex == present_source. Whichever of the two lands second has to add dead_targets::present_held to that path, or the hold has a fourth way out.

Testing: no in-game run yet, on the author's PC or elsewhere. The checks pass at the head, and the author ran them against main through their job queue. CI is still pending. The farm request is open. It still needs one Windows NVIDIA run, a heavy scene and one lower-VRAM card, with the VRAM peak against main as the pass criterion. Approval waits for those runs.
Overlaps and merge order:

  • #2054 (also siantm's): same functions in vk_texture.cpp/.h (texture_for_present, the dead-target paths). Either can go first, but the second needs the hold added to 2054's lazy path.
  • #1952: touches only texture_touch, no overlap.
  • The vk_replay.cpp siblings (2059, 2053, 2052, 2031, 2030, 2028, 1995, 1994, 759) don't touch do_present's source line.
  • switches.def will conflict textually with most open PRs, as expected.
**Verdict: Comment.** I'd approve this once it is out of WIP and the farm run is in. The grace is a small, bounded change to the trim that leaves the pooling points alone, every BeanBot point is fixed in the code and has a test that fails without the fix, and the hold on the present's source closes a real lifetime gap (on main, `texture_frame` runs between `texture_for_present` and `present_image`, so a stale fallback source could be evicted before the window copied it). What's left is the in-game run, and the VRAM peak it reports against main matters most. For a player: fewer render-target images destroyed and made again while the camera turns, which should mean less work on the presenting thread. The cost is up to one more pool bound of VRAM (256 to 768 MB by default) while it does that. The gain isn't measured yet. **Reviewed:** e88ea1b7 against f1f2dc5b (the merge base). Read in full where they changed: `gpu/vk/vk_texture.cpp` (`pool_trim`, `image_reuse_on`, `pool_grace`, `texture_for_present`, `dead_targets_sweep`, `reuse_retire_frame`, the eviction pass and the 600-present line), `gpu/vk/vk_texture.h`, `gpu/vk/target_pool.h`, `gpu/vk/dead_targets.h`, `gpu/vk/vk_replay.cpp` (`do_present` up to `present_image`), the `gpu/vk/switches.def` rows, `tests/test_target_pool_grace.py`, `tests/test_target_retention.cpp` and `tests/test_target_reuse_memory.py`. Also read the code they rely on: `destroy_later`, `pool_put`, `pool_take_memory`, `compact_step`'s source check and the ASTC reuse retirement. I checked that the source-reading checks touching these functions (`test_dead_targets_sweep.py`, `test_target_image_pool.py`, `test_image_reaper.py`, `test_mem_account.py`) still find their strings. Nothing was run; this is a code review. **Fixed in this review:** nothing. **Checked and fine:** - BeanBot's points are fixed in the code, not only in the reply: - L1: the hold covers the only three places a Texture leaves the table: the eviction, the sweep and the retirement. The fallback source is marked too. - L2: a null present now clears `present_source`. - L3: `effective_grace` keeps the grace at the idle limit less one. - L4: `destroy_later` is back to main's code. - L5: the fixture has stubs for the two new helpers. - L6: each compiled case runs with a cleaned environment. - L7: the same-present case with `GRACE=0` fails if the `grace &&` test is dropped. - L8: the real `texture_for_present`, sweep and retirement are cut from the source and run, and retention case 3 runs the eviction pass. - L9: the ceiling and the over-bound peak are in the 600-present line. - L12: the switch rows are updated. - The hold's length holds up: `presented` is set before `texture_frame`'s `frame_no++`, so the source is released at the 9th present's `texture_frame`. By then the slot fence of the present that last showed it has been waited (at most `kPresentSlotsMax` = 8 slots), and the `static_assert` ties the two constants together. - The trim stays oldest first. When the oldest image is in its grace, every image is, so the break condition is right. The idle limit still wins. Pressure turns the grace off. `st_pool_over_peak` is written and read under `pool_mu`. - A held ASTC source skipped by `reuse_retire_frame` stays a normal texture, and the eviction takes it later. Its image was copied, not shared, so nothing reads freed memory. - `pool_grace` parses as its test says: unset or not a number gives 4, the value is clamped to 0 to 1024, and it is read once. - Both switches ship at their intended defaults (on, 4 presents), as the standards ask for a WIP branch. - The new test only compiles fixtures in a temporary directory and runs them there. It downloads nothing and deletes nothing outside that directory. **Suggestions** (the author may take or leave) - **Rebase:** it conflicts with current main in `texture_for_present` and `do_present`. Main added `t->output_preview` and `dropped_output` there. This is more than a textual conflict. A dropped output has to go through the null path (`texture_for_present(dropped_output ? nullptr : t)`), so it clears `present_source` as L2 wanted. The `output_preview` early return has to set `presented` as well, or the preview's texture isn't held. Ideally rebase before the farm builds it. - **Risks wording:** it says the pool holds up to twice the bound "for up to the grace's 4 presents". That is true of each image, but not of the pool. While the camera keeps turning and new shapes keep arriving, the pool can sit near twice the bound for as long as that lasts. Please say so, since it is what the VRAM peak against main has to show, most of all on 6 GB cards (issue #939 is already there). - `vk_texture.cpp:5912`: the compaction hold's first pass counts a held source in `hold_dead`, but the main loop then skips it. It is one texture over-counted, but adding the same `present_held` skip there keeps the two passes in step. - `vk_texture.cpp:4879`: compaction still excludes only `present_source` (the current present), not what `present_held` holds. Render targets are probably outside the compacted pool, but using `present_held` there too would make "the source is held for 9 presents" true for every path. - **One topic:** the present's hold fixes a lifetime bug that is on main and runs with either setting. As its own small fix PR it would land even if the grace's A/B goes against the grace, and the farm comparison would then be grace only. - **Two off switches:** `RX_VK_IMAGE_REUSE=0` and `RX_VK_TARGET_POOL_GRACE=0` turn off the same thing. Consider keeping one: the tune switch at 0 is the kill switch. - **Overlap with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2054:** that PR adds a lazy retirement path whose `stays` test checks `tex == present_source`. Whichever of the two lands second has to add `dead_targets::present_held` to that path, or the hold has a fourth way out. **Testing:** no in-game run yet, on the author's PC or elsewhere. The checks pass at the head, and the author ran them against main through their job queue. CI is still pending. The farm request is open. It still needs one Windows NVIDIA run, a heavy scene and one lower-VRAM card, with the VRAM peak against main as the pass criterion. Approval waits for those runs. **Overlaps and merge order:** - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2054 (also siantm's): same functions in `vk_texture.cpp`/`.h` (`texture_for_present`, the dead-target paths). Either can go first, but the second needs the hold added to 2054's lazy path. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1952: touches only `texture_touch`, no overlap. - The `vk_replay.cpp` siblings (2059, 2053, 2052, 2031, 2030, 2028, 1995, 1994, 759) don't touch `do_present`'s source line. - `switches.def` will conflict textually with most open PRs, as expected.
@ -567,1 +594,4 @@
const size_t most = (pool_pressure > 0) ? 64 : 16;
// (longshot, RX_VK_IMAGE_REUSE: what came in the last presents is not counted out by the bound while the pool holds no more
// than twice it, above; the grace under the idle limit. Not while VRAM is short: there RX_VK_TARGET_POOL_GRACE is not read)
const uint64_t grace = image_reuse_on() && !pool_pressure ? target_pool::effective_grace(pool_grace(), idle) : 0;
Member

Each image gets at most 4 presents of grace, but the pool as a whole can sit near twice the bound for as long as new shapes keep coming in while the camera turns. Risks should say that. The farm's VRAM peak against main is the number that settles it.

Each image gets at most 4 presents of grace, but the pool as a whole can sit near twice the bound for as long as new shapes keep coming in while the camera turns. Risks should say that. The farm's VRAM peak against main is the number that settles it.
@ -4926,1 +4959,4 @@
// (what the present shows, held for dead_targets::kPresentHold presents from here: its window copy's frame slot comes round
// again kPresentSlotsMax presents later at most. A present of nothing (t null) shows nothing: no source)
static_assert(dead_targets::kPresentHold > (uint64_t)kPresentSlotsMax);
Texture* texture_for_present(const nvn_tex* t) {
Member

Rebase note: main now returns early here for t->output_preview, and do_present passes null for a dropped output. Send the dropped output through texture_for_present(nullptr) so present_source is cleared (L2), and set presented on the output_preview return as well.

Rebase note: main now returns early here for t->output_preview, and do_present passes null for a dropped output. Send the dropped output through texture_for_present(nullptr) so present_source is cleared (L2), and set presented on the output_preview return as well.
Member
Beanstalk test farm · an earlier run: commit e88ea1b (the newer results are in a comment below)

Commit e88ea1b · approved by dyst (👍 on siantm's request) (reviewed) · dashboard

⚠️ Note: The PR's explicit reuse-on setting is equivalent to unset; the matrix uses 1 versus 0 because it cannot express unset as a PR-only cell.
⚠️ Note: The camera turn is 10,800 input frames, approximately three minutes at 60 fps; the farm cannot measure a segment while issuing stick inputs, so p99 and peak VRAM are measured immediately afterward, not during the turn.
⚠️ Note: Image counts are the last cumulative log values, not warm-up-subtracted deltas; the over-bound value is the maximum reported interval peak.

Started at 10:05 UTC.

Estimate: done in about 1 h 15 min, from the queue and the testers online now; some jobs can't start yet.

Target Result Reports VRAM peak (MB) Crashes
linux+nvidia ❌ fail (an outlier) 2 1 2 6,532 → 6,706 (+3%) none
linux+radv ❌ fail (an outlier) 2 1 2 6,912 → 6,720 (−3%) none
windows+intel ⏳ queued 0 of 1 — —
steamdeck ⏳ queued 0 of 1 — —

kokiri-camera · frame time p99 (ms)

Target main RX_VK_IMAGE_REUSE=0 (reference) RX_VK_IMAGE_REUSE=1
linux+nvidia 18.8 18.4 18.7 (+2%)
linux+radv 18.6 18.4 18.5 (+0%)
windows+intel — — —
steamdeck — — —

Why it failed

  • linux+nvidia: kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) screenshot.max_diff: limit 0.0
  • linux+nvidia: kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) screenshot.max_diff: limit 0.0
  • linux+nvidia: kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR): 8,200 → 8,414 (+2.6%); limit −1.0; the PR's own cells: RX_VK_IMAGE_REUSE=1 against RX_VK_IMAGE_REUSE=0 (RX_VK_IMAGE_REUSE=0 (PR only))
  • linux+nvidia: kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) after-turn.vram_peak_mb.max_delta_pct: 5,962 → 6,910 (+15.9%); limit 10.0
  • linux+radv: kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) screenshot.max_diff: limit 0.0
  • linux+radv: kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) screenshot.max_diff: limit 0.0
  • linux+radv: kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR): 8,588 → 8,651 (+0.7%); limit −1.0; the PR's own cells: RX_VK_IMAGE_REUSE=1 against RX_VK_IMAGE_REUSE=0 (RX_VK_IMAGE_REUSE=0 (PR only))
  • linux+radv: kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR): 8,286 → 8,371 (+1.0%); limit −1.0; the PR's own cells: RX_VK_IMAGE_REUSE=1 against RX_VK_IMAGE_REUSE=0 (RX_VK_IMAGE_REUSE=0 (PR only))
What was tested

What will be tested · AI plan (gpt-6.1-terra)

On Linux NVIDIA, Linux RADV, Windows Intel and Steam Deck, the plan compares main with the PR in Kokiri Forest after a one-minute warm-up and a sustained camera turn. It measures peak VRAM, frame time and render-target image counts, and compares a picture with main; crashes, device-lost or FATAL logs, picture differences, increased p99 or substantially higher VRAM fail. The PR's reuse-on and reuse-off counts are also compared. The run takes roughly 40 minutes per tester; a Windows Intel tester is not currently online, so that target will wait. No tester online now matches windows+intel: that target waits for one.

  • Where: linux+nvidia (1-2 reports), linux+radv (1-2 reports), windows+intel (1-2 reports), steamdeck (1-2 reports).
  • Matrix: 2 cells, each on main and the PR: RX_VK_IMAGE_REUSE 0 or 1 (PR only).
  • kokiri-camera: from the repository's save kokiri-start, then teleport to Kokiri Forest, 18 times: move the stick, take the picture forest to compare with main, measure after-turn for 5 s (after 0 s warm-up); 1 run on each side for each of 2 cells (2 game starts a run).
  • Measured: crashes, frame times, stutters and hitches, VRAM use, the game's log, numbers from the game's log.
  • The PR fails if: it crashes; or the PR's value_reused with RX_VK_IMAGE_REUSE=1 is more than 1% below RX_VK_IMAGE_REUSE=0; or the PR's value_made with RX_VK_IMAGE_REUSE=1 is more than -1% above RX_VK_IMAGE_REUSE=0; or a picture differs from main by more than 0%; or peak VRAM is more than 10% above main; or frame time (p99) is more than 0% above main; or forbidden log lines is above 0.
  • Time: about 25 min of game runs per tester (4 game starts), plus the two builds.
Measurements on `linux+nvidia`, for the PR description

Verdict: fail on linux+nvidia (2 reports): kokiri-camera screenshot.max_diff; kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+2.6%); kokiri-camera after-turn.vram_peak_mb.max_delta_pct (+15.9%) failed.

Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 5070, 620.70.6 AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 5080, 620.73.4 AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM
Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (@Beanstalk on this PR runs it again)

Before: main @ f1f2dc5 After: this PR @ e88ea1b
kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) · after-turn · peak VRAM (MB) 6,532 6,706 (+3%)
kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) · after-turn · frame time (p99) (ms) 18.8 18.4 (−2%)
kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) · forbidden log lines 0.0 0.0
kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) · after-turn · peak VRAM (MB) 5,802 6,404 (+10%)
kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) · after-turn · frame time (p99) (ms) 18.4 18.7 (+2%)
kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) · forbidden log lines 0.0 0.0

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (peak VRAM) Helps / doesn't help / untested
RX_VK_IMAGE_REUSE switch the PR adds (set on the PR side only) 0, 1 not in main the PR's default kokiri-camera, main without it → the PR with 0: 6,532 → 6,706 (+3%) doesn't help

As Markdown for the PR description:

## Measurements

**Verdict:** fail on linux+nvidia (2 reports): `kokiri-camera screenshot.max_diff`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+2.6%)`; `kokiri-camera after-turn.vram_peak_mb.max_delta_pct (+15.9%)` failed.

Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.70.6` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5080, 620.73.4` `AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM`  
Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (`@Beanstalk` on this PR runs it again)

| | Before: main @ f1f2dc5 | After: this PR @ e88ea1b |
|---|---|---|
| kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · peak VRAM (MB) | 6,532 | 6,706 (+3%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · frame time (p99) (ms) | 18.8 | 18.4 (−2%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · forbidden log lines | 0.0 | 0.0 |
| kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · peak VRAM (MB) | 5,802 | 6,404 (+10%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · frame time (p99) (ms) | 18.4 | 18.7 (+2%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · forbidden log lines | 0.0 | 0.0 |

**Flags and settings**

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (peak VRAM) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `RX_VK_IMAGE_REUSE` | switch the PR adds (set on the PR side only) | `0`, `1` | not in main | the PR's default | kokiri-camera, main without it → the PR with 0: 6,532 → 6,706 (+3%) | doesn't help |
Measurements on `linux+radv`, for the PR description

Verdict: fail on linux+radv (2 reports): kokiri-camera screenshot.max_diff; kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+0.7%); kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+1.0%) failed.

Hardware: 1: linux+amd+radv+dgpu AMD Radeon RX 9070 XT (RADV GFX1201), 26.1.99 AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpu AMD Radeon RX 9070 (RADV GFX1201), 26.0.8 AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM
Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (@Beanstalk on this PR runs it again)

Before: main @ f1f2dc5 After: this PR @ e88ea1b
kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) · after-turn · peak VRAM (MB) 6,912 6,720 (−3%)
kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) · after-turn · frame time (p99) (ms) 18.6 18.4 (−1%)
kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only) · forbidden log lines 0.0 0.0
kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) · after-turn · peak VRAM (MB) 7,006 6,928 (−1%)
kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) · after-turn · frame time (p99) (ms) 18.0 18.5 (+2%)
kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only) · forbidden log lines 0.0 0.0

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (peak VRAM) Helps / doesn't help / untested
RX_VK_IMAGE_REUSE switch the PR adds (set on the PR side only) 0, 1 not in main the PR's default kokiri-camera, main without it → the PR with 0: 6,912 → 6,720 (−3%) helps

As Markdown for the PR description:

## Measurements

**Verdict:** fail on linux+radv (2 reports): `kokiri-camera screenshot.max_diff`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+0.7%)`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+1.0%)` failed.

Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 9070 XT (RADV GFX1201), 26.1.99` `AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM`; 2: linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM`  
Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (`@Beanstalk` on this PR runs it again)

| | Before: main @ f1f2dc5 | After: this PR @ e88ea1b |
|---|---|---|
| kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · peak VRAM (MB) | 6,912 | 6,720 (−3%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · frame time (p99) (ms) | 18.6 | 18.4 (−1%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · forbidden log lines | 0.0 | 0.0 |
| kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · peak VRAM (MB) | 7,006 | 6,928 (−1%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · frame time (p99) (ms) | 18.0 | 18.5 (+2%) |
| kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · forbidden log lines | 0.0 | 0.0 |

**Flags and settings**

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (peak VRAM) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `RX_VK_IMAGE_REUSE` | switch the PR adds (set on the PR side only) | `0`, `1` | not in main | the PR's default | kokiri-camera, main without it → the PR with 0: 6,912 → 6,720 (−3%) | helps |
The testers' hardware
Target Report Ran on
linux+nvidia 1 linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 5070, 620.70.6 AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM
linux+nvidia 2 linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 5080, 620.73.4 AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM
linux+radv 1 linux+amd+radv+dgpu AMD Radeon RX 9070 XT (RADV GFX1201), 26.1.99 AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM
linux+radv 2 linux+amd+radv+dgpu AMD Radeon RX 9070 (RADV GFX1201), 26.0.8 AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>e88ea1b</code> (the newer results are in a comment below)</summary> Commit `e88ea1b` · approved by dyst (👍 on siantm's request) (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/1996) ⚠️ **Note:** The PR's explicit reuse-on setting is equivalent to unset; the matrix uses 1 versus 0 because it cannot express unset as a PR-only cell. ⚠️ **Note:** The camera turn is 10,800 input frames, approximately three minutes at 60 fps; the farm cannot measure a segment while issuing stick inputs, so p99 and peak VRAM are measured immediately afterward, not during the turn. ⚠️ **Note:** Image counts are the last cumulative log values, not warm-up-subtracted deltas; the over-bound value is the maximum reported interval peak. Started at 10:05 UTC. **Estimate:** done in about 1 h 15 min, from the queue and the testers online now; some jobs can't start yet. | Target | Result | Reports | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | | `linux+nvidia` | ❌ fail (an outlier) | 2 [1](https://beanstalk.magicbean.dev/reports/rp_f6e88257d882450d) [2](https://beanstalk.magicbean.dev/reports/rp_4566296543e2a357) | 6,532 → 6,706 (+3%) | none | | `linux+radv` | ❌ fail (an outlier) | 2 [1](https://beanstalk.magicbean.dev/reports/rp_c020f2e072f697bb) [2](https://beanstalk.magicbean.dev/reports/rp_9f6866ab6b20713f) | 6,912 → 6,720 (−3%) | none | | `windows+intel` | ⏳ queued | 0 of 1 | — | — | | `steamdeck` | ⏳ queued | 0 of 1 | — | — | **`kokiri-camera`** · frame time p99 (ms) | Target | main | `RX_VK_IMAGE_REUSE=0` (reference) | `RX_VK_IMAGE_REUSE=1` | | --- | --- | --- | --- | | `linux+nvidia` | 18.8 | 18.4 | 18.7 (+2%) | | `linux+radv` | 18.6 | 18.4 | 18.5 (+0%) | | `windows+intel` | — | — | — | | `steamdeck` | — | — | — | **Why it failed** - `linux+nvidia`: `kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only)` `screenshot.max_diff`: `limit 0.0` - `linux+nvidia`: `kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only)` `screenshot.max_diff`: `limit 0.0` - `linux+nvidia`: `kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only)` `value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR)`: `8,200 → 8,414 (+2.6%); limit −1.0; the PR's own cells: RX_VK_IMAGE_REUSE=1 against RX_VK_IMAGE_REUSE=0 (RX_VK_IMAGE_REUSE=0 (PR only))` - `linux+nvidia`: `kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only)` `after-turn.vram_peak_mb.max_delta_pct`: `5,962 → 6,910 (+15.9%); limit 10.0` - `linux+radv`: `kokiri-camera · RX_VK_IMAGE_REUSE=0 (PR only)` `screenshot.max_diff`: `limit 0.0` - `linux+radv`: `kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only)` `screenshot.max_diff`: `limit 0.0` - `linux+radv`: `kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only)` `value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR)`: `8,588 → 8,651 (+0.7%); limit −1.0; the PR's own cells: RX_VK_IMAGE_REUSE=1 against RX_VK_IMAGE_REUSE=0 (RX_VK_IMAGE_REUSE=0 (PR only))` - `linux+radv`: `kokiri-camera · RX_VK_IMAGE_REUSE=1 (PR only)` `value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR)`: `8,286 → 8,371 (+1.0%); limit −1.0; the PR's own cells: RX_VK_IMAGE_REUSE=1 against RX_VK_IMAGE_REUSE=0 (RX_VK_IMAGE_REUSE=0 (PR only))` <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) On Linux NVIDIA, Linux RADV, Windows Intel and Steam Deck, the plan compares main with the PR in Kokiri Forest after a one-minute warm-up and a sustained camera turn. It measures peak VRAM, frame time and render-target image counts, and compares a picture with main; crashes, device-lost or FATAL logs, picture differences, increased p99 or substantially higher VRAM fail. The PR's reuse-on and reuse-off counts are also compared. The run takes roughly 40 minutes per tester; a Windows Intel tester is not currently online, so that target will wait. No tester online now matches windows+intel: that target waits for one. - **Where:** linux+nvidia (1-2 reports), linux+radv (1-2 reports), windows+intel (1-2 reports), steamdeck (1-2 reports). - **Matrix:** 2 cells, each on main and the PR: RX_VK_IMAGE_REUSE `0` or `1` (PR only). - **kokiri-camera:** from the repository's save `kokiri-start`, then teleport to Kokiri Forest, 18 times: move the stick, take the picture forest to compare with main, measure after-turn for 5 s (after 0 s warm-up); 1 run on each side for each of 2 cells (2 game starts a run). - **Measured:** crashes, frame times, stutters and hitches, VRAM use, the game's log, numbers from the game's log. - **The PR fails if:** it crashes; or the PR's value_reused with RX_VK_IMAGE_REUSE=1 is more than 1% below RX_VK_IMAGE_REUSE=0; or the PR's value_made with RX_VK_IMAGE_REUSE=1 is more than -1% above RX_VK_IMAGE_REUSE=0; or a picture differs from main by more than 0%; or peak VRAM is more than 10% above main; or frame time (p99) is more than 0% above main; or forbidden log lines is above 0. - **Time:** about 25 min of game runs per tester (4 game starts), plus the two builds. </details> <details><summary>Measurements on `linux+nvidia`, for the PR description</summary> **Verdict:** fail on linux+nvidia (2 reports): `kokiri-camera screenshot.max_diff`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+2.6%)`; `kokiri-camera after-turn.vram_peak_mb.max_delta_pct (+15.9%)` failed. Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.70.6` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5080, 620.73.4` `AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM` Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (`@Beanstalk` on this PR runs it again) | | Before: main @ f1f2dc5 | After: this PR @ e88ea1b | |---|---|---| | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · peak VRAM (MB) | 6,532 | 6,706 (+3%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · frame time (p99) (ms) | 18.8 | 18.4 (−2%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · forbidden log lines | 0.0 | 0.0 | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · peak VRAM (MB) | 5,802 | 6,404 (+10%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · frame time (p99) (ms) | 18.4 | 18.7 (+2%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (peak VRAM) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_IMAGE_REUSE` | switch the PR adds (set on the PR side only) | `0`, `1` | not in main | the PR's default | kokiri-camera, main without it → the PR with 0: 6,532 → 6,706 (+3%) | doesn't help | As Markdown for the PR description: ```markdown ## Measurements **Verdict:** fail on linux+nvidia (2 reports): `kokiri-camera screenshot.max_diff`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+2.6%)`; `kokiri-camera after-turn.vram_peak_mb.max_delta_pct (+15.9%)` failed. Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.70.6` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5080, 620.73.4` `AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM` Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (`@Beanstalk` on this PR runs it again) | | Before: main @ f1f2dc5 | After: this PR @ e88ea1b | |---|---|---| | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · peak VRAM (MB) | 6,532 | 6,706 (+3%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · frame time (p99) (ms) | 18.8 | 18.4 (−2%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · forbidden log lines | 0.0 | 0.0 | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · peak VRAM (MB) | 5,802 | 6,404 (+10%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · frame time (p99) (ms) | 18.4 | 18.7 (+2%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (peak VRAM) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_IMAGE_REUSE` | switch the PR adds (set on the PR side only) | `0`, `1` | not in main | the PR's default | kokiri-camera, main without it → the PR with 0: 6,532 → 6,706 (+3%) | doesn't help | ``` </details> <details><summary>Measurements on `linux+radv`, for the PR description</summary> **Verdict:** fail on linux+radv (2 reports): `kokiri-camera screenshot.max_diff`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+0.7%)`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+1.0%)` failed. Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 9070 XT (RADV GFX1201), 26.1.99` `AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM`; 2: linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM` Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (`@Beanstalk` on this PR runs it again) | | Before: main @ f1f2dc5 | After: this PR @ e88ea1b | |---|---|---| | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · peak VRAM (MB) | 6,912 | 6,720 (−3%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · frame time (p99) (ms) | 18.6 | 18.4 (−1%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · forbidden log lines | 0.0 | 0.0 | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · peak VRAM (MB) | 7,006 | 6,928 (−1%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · frame time (p99) (ms) | 18.0 | 18.5 (+2%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (peak VRAM) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_IMAGE_REUSE` | switch the PR adds (set on the PR side only) | `0`, `1` | not in main | the PR's default | kokiri-camera, main without it → the PR with 0: 6,912 → 6,720 (−3%) | helps | As Markdown for the PR description: ```markdown ## Measurements **Verdict:** fail on linux+radv (2 reports): `kokiri-camera screenshot.max_diff`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+0.7%)`; `kokiri-camera value_made: RX_VK_IMAGE_REUSE=1 vs RX_VK_IMAGE_REUSE=0 (PR) (+1.0%)` failed. Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 9070 XT (RADV GFX1201), 26.1.99` `AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM`; 2: linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM` Scene: kokiri-camera, from the repository's save kokiri-start; 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); kokiri-camera: 1 game start a side, after-turn 5 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 (`@Beanstalk` on this PR runs it again) | | Before: main @ f1f2dc5 | After: this PR @ e88ea1b | |---|---|---| | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · peak VRAM (MB) | 6,912 | 6,720 (−3%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · after-turn · frame time (p99) (ms) | 18.6 | 18.4 (−1%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=0 (PR only)` · forbidden log lines | 0.0 | 0.0 | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · peak VRAM (MB) | 7,006 | 6,928 (−1%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · after-turn · frame time (p99) (ms) | 18.0 | 18.5 (+2%) | | kokiri-camera · `RX_VK_IMAGE_REUSE=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (peak VRAM) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_IMAGE_REUSE` | switch the PR adds (set on the PR side only) | `0`, `1` | not in main | the PR's default | kokiri-camera, main without it → the PR with 0: 6,912 → 6,720 (−3%) | helps | ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `linux+nvidia` | [1](https://beanstalk.magicbean.dev/reports/rp_f6e88257d882450d) | linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.70.6` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM` | | `linux+nvidia` | [2](https://beanstalk.magicbean.dev/reports/rp_4566296543e2a357) | linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5080, 620.73.4` `AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM` | | `linux+radv` | [1](https://beanstalk.magicbean.dev/reports/rp_c020f2e072f697bb) | linux+amd+radv+dgpu `AMD Radeon RX 9070 XT (RADV GFX1201), 26.1.99` `AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM` | | `linux+radv` | [2](https://beanstalk.magicbean.dev/reports/rp_9f6866ab6b20713f) | linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM` | </details> </details>
Author
Contributor

Re the Test Farm's results on e88ea1b7 (summary):

  • Linux NVIDIA: render-target images made with RX_VK_TARGET_POOL_GRACE at its default against =0: 8,200 → 8,414 (+2.6 %), where the grace was meant to make fewer; after-turn VRAM peak with the grace 5,962 → 6,910 (+15.9 %, limit 10 %); screenshot.max_diff over the limit in both cells (=0 and default).
  • Linux RADV: images made +0.7 % and +1.0 %; screenshot.max_diff over the limit in both cells; p99 within ±2 %.

The measurement goes against the grace. This pull request is on hold while the picture difference is traced: it shows with the switch at 0 as well, so it comes from a part that runs either way, and a =0 build should behave exactly as main. No push until that is found.

Re the Test Farm's results on e88ea1b7 ([summary](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-65748)): - Linux NVIDIA: render-target images made with `RX_VK_TARGET_POOL_GRACE` at its default against `=0`: 8,200 → 8,414 (+2.6 %), where the grace was meant to make fewer; after-turn VRAM peak with the grace 5,962 → 6,910 (+15.9 %, limit 10 %); `screenshot.max_diff` over the limit in both cells (`=0` and default). - Linux RADV: images made +0.7 % and +1.0 %; `screenshot.max_diff` over the limit in both cells; p99 within ±2 %. The measurement goes against the grace. This pull request is on hold while the picture difference is traced: it shows with the switch at `0` as well, so it comes from a part that runs either way, and a `=0` build should behave exactly as main. No push until that is found.
Author
Contributor

Correction to my comment above: reading the four reports' logs, the grace never acted in these runs (every PR log ends "the pool let go of 0 over its bound", over-bound peak 0 MB), so the =0/default gaps are not its doing: images made differ by +2.6, −3.3, +0.7 and +1.0 %, and the VRAM figure is one start's peak (the cell's mean fell, 5,962 → 5,877) on a tester whose two main cells differ by 8.9 %. The screenshots differ in viewpoint (the shot follows 18 rounds of right-stick input, so the end angle depends on frame timing), not in rendering. So the run neither supports nor goes against the grace; it is still unmeasured, and a run where the pool goes over its bound is what would settle it.

Correction to [my comment above](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-66254): reading the four reports' logs, the grace never acted in these runs (every PR log ends "the pool let go of 0 over its bound", over-bound peak 0 MB), so the `=0`/default gaps are not its doing: images made differ by +2.6, −3.3, +0.7 and +1.0 %, and the VRAM figure is one start's peak (the cell's mean fell, 5,962 → 5,877) on a tester whose two main cells differ by 8.9 %. The screenshots differ in viewpoint (the shot follows 18 rounds of right-stick input, so the end angle depends on frame timing), not in rendering. So the run neither supports nor goes against the grace; it is still unmeasured, and a run where the pool goes over its bound is what would settle it.
siantm force-pushed perf/vk-image-reuse from e88ea1b701
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by dyst (reviewed)
beanstalk/linux+nvidia 2/1 fail
beanstalk/linux+radv 2/1 fail
beanstalk/windows+intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 0 running, 2 queued
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 850ba5dfb5
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
2026-11-21 11:22:39 +00:00
Compare
Member

Beanstalk test farm

Commit 850ba5d · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `850ba5d` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/1996) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
siantm changed title from WIP: perf(vk): the render target pool's bound spares the images that came in the last presents (RX_VK_IMAGE_REUSE=0 to disable) to WIP: perf(vk): the render target pool's bound spares the images that came in the last presents (RX_VK_TARGET_POOL_GRACE=0 to disable) 2026-11-21 11:23:34 +00:00
Author
Contributor

Thanks for the review (#1996 (comment)). The branch is now stacked on #2064 and has 850ba5df as its head. The changes, point by point:

  • One topic: taken. The present's hold is #2064 now: test commit e016aef5, fix a9d04a2e, on main 9dd41326. Its game-free tests fail on main and pass there. The hold's parts are out of this PR's three commits, rebuilt on #2064 as 4678fd3b, 2e17a0e0 and 29a0e423. destroy_later and the four checks that follow its signature are main's from the first commit on. This PR now changes the grace alone.
  • Rebase (#1996 (comment)): done as you said, in #2064's a9d04a2e. do_present calls texture_for_present(dropped_output ? nullptr : t), so a dropped output clears present_source. The Output preview's return marks presented too. #2064's test runs both cases.
  • vk_texture.cpp:5912 and :4879: both in #2064's a9d04a2e. The compaction's first pass skips a held texture as the main loop does. tests/test_target_retention.cpp case 4 runs that pass: a held dead target is not counted as given back, and a live texture goes for the excess in its place. compact_step skips what present_held holds as well as present_source.
  • Two off switches: done in 850ba5df. RX_VK_TARGET_POOL_GRACE is the kill switch now (kill, int, 4 by default; =0: the bound counts every image, as main). RX_VK_IMAGE_REUSE is gone from the code, switches.def and the tests. tests/test_target_pool_grace.py runs =0 and checks the table's row.
  • Risks wording (#1996 (comment)): taken in the description. While the camera keeps turning and new shapes keep arriving, the pool can sit near twice the bound for as long as that lasts. That is 256 to 768 MB more by default. The VRAM peak against main decides it, on 6 GB cards most of all (#939).
  • #2054: noted in both descriptions. Whichever of #2054 and #2064 lands second adds dead_targets::present_held to #2054's lazy retirement path.

About the farm run on e88ea1b7: the grace was not exercised. Every log says the pool let go of nothing over its bound, at most 0 MB over it, so the run does not measure the grace. Still to test asks for a scene that takes the pool over its bound, with the pool's own lines as the evidence.

Checked on this PC, through the job queue (dy1996a, dy1996b, dy1996c):

  • Seven of the eight checks I named pass at 850ba5df. tests/test_target_reuse_memory.py fails, as it did on main @ f1f2dc5b.
  • #2064's checks pass at a9d04a2e and fail at its test commit.
  • vk_texture.cpp and vk_replay.cpp compile with the game build's own commands.

Not run in the game on this PC yet.

Thanks for the review (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-65721). The branch is now stacked on #2064 and has 850ba5df as its head. The changes, point by point: - **One topic:** taken. The present's hold is #2064 now: test commit e016aef5, fix a9d04a2e, on main 9dd41326. Its game-free tests fail on main and pass there. The hold's parts are out of this PR's three commits, rebuilt on #2064 as 4678fd3b, 2e17a0e0 and 29a0e423. `destroy_later` and the four checks that follow its signature are main's from the first commit on. This PR now changes the grace alone. - **Rebase** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-65719): done as you said, in #2064's a9d04a2e. `do_present` calls `texture_for_present(dropped_output ? nullptr : t)`, so a dropped output clears `present_source`. The Output preview's return marks `presented` too. #2064's test runs both cases. - **vk_texture.cpp:5912 and :4879:** both in #2064's a9d04a2e. The compaction's first pass skips a held texture as the main loop does. `tests/test_target_retention.cpp` case 4 runs that pass: a held dead target is not counted as given back, and a live texture goes for the excess in its place. `compact_step` skips what `present_held` holds as well as `present_source`. - **Two off switches:** done in 850ba5df. `RX_VK_TARGET_POOL_GRACE` is the kill switch now (`kill`, int, 4 by default; `=0`: the bound counts every image, as main). `RX_VK_IMAGE_REUSE` is gone from the code, `switches.def` and the tests. `tests/test_target_pool_grace.py` runs `=0` and checks the table's row. - **Risks wording** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1996#issuecomment-65720): taken in the description. While the camera keeps turning and new shapes keep arriving, the pool can sit near twice the bound for as long as that lasts. That is 256 to 768 MB more by default. The VRAM peak against main decides it, on 6 GB cards most of all (#939). - **#2054:** noted in both descriptions. Whichever of #2054 and #2064 lands second adds `dead_targets::present_held` to #2054's lazy retirement path. About the farm run on e88ea1b7: the grace was not exercised. Every log says the pool let go of nothing over its bound, at most 0 MB over it, so the run does not measure the grace. Still to test asks for a scene that takes the pool over its bound, with the pool's own lines as the evidence. Checked on this PC, through the job queue (`dy1996a`, `dy1996b`, `dy1996c`): - Seven of the eight checks I named pass at 850ba5df. `tests/test_target_reuse_memory.py` fails, as it did on main @ f1f2dc5b. - #2064's checks pass at a9d04a2e and fail at its test commit. - `vk_texture.cpp` and `vk_replay.cpp` compile with the game build's own commands. Not run in the game on this PC yet.
Author
Contributor

@Beanstalk This changes the render target pool's trim (gpu/vk/vk_texture.cpp, pool_trim): an image put in the pool in the last 4 presents is not counted out by the pool's bound; RX_VK_TARGET_POOL_GRACE (4 by default) sets that, and RX_VK_TARGET_POOL_GRACE=0 turns it off and gives main's trim. It is on #2064, whose commit is in its diff. The question is the VRAM peak against main. The grace only acts when the pool goes over its bound, so please use scenes that take it there: Castle Town Market from the market-entrance save, and Hyrule Field running with the camera turning, at the highest Output resolution; on a card with 6 GB or less and on a Tier 1 discrete card. Please take each picture at a fixed point with no input, right after the save settles, with one main-against-itself picture; then the PR against main on the same PC, on the PR's side with RX_VK_TARGET_POOL_GRACE unset and with it at 0, at least two starts a side, interleaved. From the game's log: the "render target images" line's "the pool let go of N over its bound" with N above 0 on main and with =0 (if N is 0, the run does not test the grace: please report that), and "at most N MB over its bound" on the PR unset. Please report images made new and reused, unset against =0, and the driver's VRAM peak against main. The same picture within main's own noise, no crash, device lost or FATAL line.

@Beanstalk This changes the render target pool's trim (gpu/vk/vk_texture.cpp, pool_trim): an image put in the pool in the last 4 presents is not counted out by the pool's bound; RX_VK_TARGET_POOL_GRACE (4 by default) sets that, and RX_VK_TARGET_POOL_GRACE=0 turns it off and gives main's trim. It is on #2064, whose commit is in its diff. The question is the VRAM peak against main. The grace only acts when the pool goes over its bound, so please use scenes that take it there: Castle Town Market from the market-entrance save, and Hyrule Field running with the camera turning, at the highest Output resolution; on a card with 6 GB or less and on a Tier 1 discrete card. Please take each picture at a fixed point with no input, right after the save settles, with one main-against-itself picture; then the PR against main on the same PC, on the PR's side with RX_VK_TARGET_POOL_GRACE unset and with it at 0, at least two starts a side, interleaved. From the game's log: the "render target images" line's "the pool let go of N over its bound" with N above 0 on main and with =0 (if N is 0, the run does not test the grace: please report that), and "at most N MB over its bound" on the PR unset. Please report images made new and reused, unset against =0, and the driver's VRAM peak against main. The same picture within main's own noise, no crash, device lost or FATAL line.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-image-reuse:siantm-perf/vk-image-reuse'
git switch 'siantm-perf/vk-image-reuse'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1996
No description provided.