perf(vk): render targets moved by the game's layout shifts keep their images: no re-creation and re-upload (1 % low +13 %, POC) #2454

Open
Veix wants to merge 2 commits from Veix/Longshot:wip/render-target-handover into main
Contributor

Summary

A proof of concept for testing and feedback, not for merging as is: when the game's render-target layout moves, the moved targets take over unused images of their own kind instead of getting new ones. On the walking route's second Castle Town stay the frames over 20 ms drop from 63.5 to 26 (3 runs against 2, interleaved), the 1 % low rises from 41.2 to 46.4 fps, an area entry settles at once (the castle: no frame over 20 ms after 0.25 s, against 7-9 s on main), and 29 % less image memory is made and destroyed.

The game packs its render targets bottom-up into one pool, every frame (the allocator f_8005ed00). When a target appears or goes (a pass that runs only some frames, an effect, a view), every target behind it moves to a new address. The renderer keys its images by address and create info, so each moved target is a new texture: 12-44 new images in one frame, 20-29 ms frames in the market. The game itself just re-initialises the same targets at their new places.

What this changes (gpu/vk/vk_texture.cpp, all on by default here):

  • The hand-over (RX_VK_TEST_HANDOVER=3, =0 off): a render target made new takes the image of an unused target of exactly its create info (not used in this present), so the moved target needs no new image (the 20-29 ms frames). Never a donor, each rule from what was seen without it:
    • one that carries content: read before it was drawn in a present (its last frame's picture is still needed). Without it: the castle went wrong (a median of 1.8 ms, ~150 fps: passes that build on their last frame lost it);
    • one drawn and not read since (a terrain tile drawn when a chunk comes in, sampled frames later). Without it: Hyrule Field's terrain popped in black for a frame;
    • one of several levels or layers drawn in one present only (RX_VK_TEST_DONOR_ONCE, =0 off): drawn at an area's load and read every few presents, like the far LODs' 260x260 RG8 of 9 levels and a 128x128 cube of 8. Without it: far LODs in Hyrule Field darker than on main until seen up close (their drawing given away, then loaded from memory, which never had it). Single-level targets are left out of this rule: the market's layout targets are often drawn in one present before they move, and the rule on all of them took most of the gain back (frames over 20 ms 18 -> 43-51).
  • The deferred clear (RX_VK_TEST_HANDOVER_CLEAR=2; =1 clears at once, as a new image): a handed-over image is cleared at its first write; a first read keeps the donor's content when the donor was the only candidate (a 3840x2160 R32F target the game reads before it draws it each frame). Without a clear: the donor's old picture showed where the game draws only part of a new target (pop-in). Cleared at once instead: the R32F target lost its content and was loaded from memory, 32 MB, almost every time it moved. With several candidates the content is not kept: which one was the predecessor is not known, and another target's picture would be wrong.
  • The carry (RX_VK_TEST_CARRY=1, =0 off): a texture made by a read takes its unambiguous predecessor's image and content (exactly one of its size and exact format, GPU-drawn, used in the last two presents and not this one, 256 KB or more; no integer formats) instead of a 32 MB load from memory. Without it: those loads (3840x2160 RGBA8 and R8 targets made by a read, read before drawn), as spikes, for example when Link bumps into people in the market. Integer formats are left out: a 960x540 RG16UI buffer (ids, not a picture) is never carried.
  • The upscalers' depth guard (vk_temporal.cpp, vk_fsr3_inputs.cpp): "the scene depth may be gone" now checks the depth texture's own id in the destroy log, not whether any texture was destroyed (a hand-over destroys one mid-frame; DLAA left its place before the bloom: a full-screen exposure flicker).
  • LONGSHOT_TEST_DIAG=1 (off by default): the investigation's logs and tooling. Without it nothing of it runs: no log lines, no polling. (The in-play D-pad down / F10 toggle of the first version is switched off: content made while it was off stayed off until an area change, which confused comparisons.)

It is one commit: a local test branch squashed onto current main, its code left as it was tested (and a second one that switches the in-play toggle off). Diagnostics and experiments in it, not meant for a clean version (the logs and the host's per-present work only with LONGSHOT_TEST_DIAG=1): the per-frame render-target pool logs in host/nvn_native.c (HOS_LOG_RT_POOL, the "TEST inits present" lines), the LONGSHOT_TEST_FORCE17 / LONGSHOT_TEST_RTPROBE lift patches in nx2/build.py (off unless set at build time) with R3 / F9 in the host, RX_VK_MOVE_DIAG, RX_VK_LOG_WENT, the "TEST" log lines in vk_texture.cpp (hand-overs, donors needed again, carries, made new), and test switches (RX_VK_TEST_HANDOVER_MIN_KB, _POOL_FIRST, RX_VK_TEST_DONOR_READ, RX_VK_TEST_DEFER_UNIQUE, RX_VK_TEST_ONE_LEVEL, RX_VK_TEST_CARRY=2). None of the switches has a row in switches.def (the log names them as unknown).

Read first: handover_take and carry_take in vk_texture.cpp, the hand-over branch in create, and texture_touch's deferred clear.

Testing

Please no automatic fixes on this branch (@fix, bot pushes): it is for testing and feedback, and its next form is a clean branch.

Tested: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, 3840x2160 DLAA. The walking route (Castle Town, the castle, Castle Town again) and free play in Castle Town and Hyrule Field, by hand, with each part switched on and off. Seen and fixed along the way: pop-in of new targets (the clear), a full-screen exposure flicker with DLAA (the depth guard), far LODs in Hyrule Field darker than on main (the drawn-once rule). With all of it on: no pop-in, flicker or dark LODs seen. The squashed commit builds on current main (Windows, llvm-mingw, without the test build switches).

Still to test:

  • Any PC: play with it, and compare with a start with RX_VK_TEST_HANDOVER=0 and RX_VK_TEST_CARRY=0 (the hand-over and the carry off); report anything that looks different (by hand)
  • AMD and Intel cards, a Steam Deck, cards of 8 GB or less: the same, and VRAM against off (by hand)
  • Linux: the build and a run (by hand)

Measurements

Verdict: on the second Castle Town stay, frames over 20 ms 63.5 -> 26 (-59 %), 1 % low 41.2 -> 46.4 fps (+13 %), p99 21.5 -> 19.6 ms, fps 62.95 -> 63.9; loads of 30 MB or more 10.5 -> 1.3; image memory made and destroyed 404 -> 287 MB/s. The castle entry is smooth after 0.17-0.25 s (7-9 s on main). The game's part of a frame is 0.17 ms longer: a caveat of this implementation (below).

Setup: Windows 11, Ryzen 9 9900X, RTX 4070 SUPER 12 GB, driver 621.24; 3840x2160 DLAA, uncapped, V-Sync off, the frame gate off, RX_VK_LOAD=start (every shader loaded before the title, so none is made during a run); the walking route (Castle Town, the castle, Castle Town again). Interleaved: PR, main, PR, main, then one more PR run of this exact commit (the logs off). The second Castle Town stay from 5 s after its entry to its end; the entries over the 10 s after the area change; the image memory and VRAM over the whole run. main built from 8aa5ab87 into a second game folder with the same options and shader cache.

Before: main @ 8aa5ab87 (2 runs) After: this PR @ f5cf931c (3 runs) Change (the averages)
fps 63.1 / 62.8 64.0 / 63.8 / 64.0 62.95 -> 63.9: +1.6 %
p99 frame time 21.7 / 21.3 ms 19.6 / 19.7 / 19.5 ms 21.5 -> 19.6 ms: -1.9 ms (-9 %)
1 % low 40.0 / 42.3 fps 46.3 / 46.6 / 46.3 fps 41.2 -> 46.4 fps: +13 %
Frames over 20 ms 60 / 67 28 / 28 / 22 63.5 -> 26: -59 %
Frames over 33 ms 1 / 0 1 / 1 / 1 0.5 -> 1: the same (a frame or two)
The game's part of a frame 8.44 / 8.45 ms 8.63 / 8.57 / 8.62 ms 8.45 -> 8.61 ms: +0.16 ms (+1.9 %), worse (the caveat below)
Frames loading 30 MB or more 10 / 11 1 / 0 / 3 10.5 -> 1.3: -88 %
Image memory made and destroyed (the reaper's line) 389 / 418 MB/s 266 / 293 / 302 MB/s 404 -> 287 MB/s: -29 %
Highest VRAM in play 7,448 / 7,466 MB 7,121 / 7,402 / 7,064 MB 7,457 -> 7,196 MB: -261 MB (-3.5 %)
Castle entry: frames over 20 ms, the last of them 5 at 6.9 s / 7 at 9.5 s 5 at 0.17 s / 4 at 0.25 s / 4 at 0.17 s smooth after 8.2 s -> 0.2 s
Market entry: frames over 20 ms / 33 ms / 50 ms 24 / 6 / 3, 27 / 8 / 2 12 / 6 / 3, 17 / 8 / 3, 20 / 7 / 4 over 20 ms 25.5 -> 16.3: -36 %; over 33 / 50 ms about the same, 7 -> 7 and 2.5 -> 3.3 (the area's load)

The first two PR runs had the logs on (LONGSHOT_TEST_DIAG did not exist yet); the third is this commit as it is. The longest stall of an entry (the game loading the area, 33-86 ms) is the same on both sides.

Caveat, the game's part (+0.17 ms): the main thread's own CPU time is unchanged (4.24 against 4.34 ms); the game waits for the render thread more often: its catch-ups (a finish, a readback) 6.4 -> 11 per 600 frames, its queue full 1 -> 9-13 times. With the carry off (RX_VK_TEST_CARRY=0, one run) the catch-ups fall to 2, the game's part to 8.51 ms, and the rest of the gain stays (frames over 20 ms 18, p99 18.9 ms). So it is the carry as it is done here: it walks every texture for each texture made by a read, and a carried texture is marked drawn by the GPU, which likely makes the game's later access wait for a write-back. To be done more efficiently in a clean version (candidates by size and format; the carried texture's state).

Risks

  • Not for merging: the test code and logs are in, the switches have no rows in switches.def, MKWVK_API_VERSION is not bumped for the diagnostic callback in vk_api.h.
  • A donor wrongly judged free shows as a target with wrong or missing content (pop-in, dark or stale areas). RX_VK_TEST_HANDOVER=0 turns the hand-over off, RX_VK_TEST_CARRY=0 the carry (at the start).
  • The carry costs the game's part 0.17 ms a frame as it is (Measurements).
  • Nothing changes in saves, longshot_options.ini or the caches.

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 fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • MKWVK_API_VERSION bumped (MkwVkHost or MkwVkRenderer in gpu/vk/vk_api.h changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Screenshots of the same spot on main and here, for a change that shows on screen.
  • 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.
## Summary **A proof of concept for testing and feedback, not for merging as is: when the game's render-target layout moves, the moved targets take over unused images of their own kind instead of getting new ones. On the walking route's second Castle Town stay the frames over 20 ms drop from 63.5 to 26 (3 runs against 2, interleaved), the 1 % low rises from 41.2 to 46.4 fps, an area entry settles at once (the castle: no frame over 20 ms after 0.25 s, against 7-9 s on `main`), and 29 % less image memory is made and destroyed.** The game packs its render targets bottom-up into one pool, every frame (the allocator `f_8005ed00`). When a target appears or goes (a pass that runs only some frames, an effect, a view), every target behind it moves to a new address. The renderer keys its images by address and create info, so each moved target is a new texture: 12-44 new images in one frame, 20-29 ms frames in the market. The game itself just re-initialises the same targets at their new places. What this changes (`gpu/vk/vk_texture.cpp`, all on by default here): - **The hand-over** (`RX_VK_TEST_HANDOVER=3`, `=0` off): a render target made new takes the image of an unused target of exactly its create info (not used in this present), so the moved target needs no new image (the 20-29 ms frames). Never a donor, each rule from what was seen without it: - one that **carries content**: read before it was drawn in a present (its last frame's picture is still needed). Without it: the castle went wrong (a median of 1.8 ms, ~150 fps: passes that build on their last frame lost it); - one **drawn and not read since** (a terrain tile drawn when a chunk comes in, sampled frames later). Without it: Hyrule Field's terrain popped in black for a frame; - one **of several levels or layers drawn in one present only** (`RX_VK_TEST_DONOR_ONCE`, `=0` off): drawn at an area's load and read every few presents, like the far LODs' 260x260 RG8 of 9 levels and a 128x128 cube of 8. Without it: far LODs in Hyrule Field darker than on `main` until seen up close (their drawing given away, then loaded from memory, which never had it). Single-level targets are left out of this rule: the market's layout targets are often drawn in one present before they move, and the rule on all of them took most of the gain back (frames over 20 ms 18 -> 43-51). - **The deferred clear** (`RX_VK_TEST_HANDOVER_CLEAR=2`; `=1` clears at once, as a new image): a handed-over image is cleared at its first write; a first read keeps the donor's content when the donor was the only candidate (a 3840x2160 R32F target the game reads before it draws it each frame). Without a clear: the donor's old picture showed where the game draws only part of a new target (pop-in). Cleared at once instead: the R32F target lost its content and was loaded from memory, 32 MB, almost every time it moved. With several candidates the content is not kept: which one was the predecessor is not known, and another target's picture would be wrong. - **The carry** (`RX_VK_TEST_CARRY=1`, `=0` off): a texture made by a read takes its unambiguous predecessor's image and content (exactly one of its size and exact format, GPU-drawn, used in the last two presents and not this one, 256 KB or more; no integer formats) instead of a 32 MB load from memory. Without it: those loads (3840x2160 RGBA8 and R8 targets made by a read, read before drawn), as spikes, for example when Link bumps into people in the market. Integer formats are left out: a 960x540 RG16UI buffer (ids, not a picture) is never carried. - **The upscalers' depth guard** (`vk_temporal.cpp`, `vk_fsr3_inputs.cpp`): "the scene depth may be gone" now checks the depth texture's own id in the destroy log, not whether any texture was destroyed (a hand-over destroys one mid-frame; DLAA left its place before the bloom: a full-screen exposure flicker). - **`LONGSHOT_TEST_DIAG=1`** (off by default): the investigation's logs and tooling. Without it nothing of it runs: no log lines, no polling. (The in-play D-pad down / F10 toggle of the first version is switched off: content made while it was off stayed off until an area change, which confused comparisons.) It is one commit: a local test branch squashed onto current `main`, its code left as it was tested (and a second one that switches the in-play toggle off). Diagnostics and experiments in it, not meant for a clean version (the logs and the host's per-present work only with `LONGSHOT_TEST_DIAG=1`): the per-frame render-target pool logs in `host/nvn_native.c` (`HOS_LOG_RT_POOL`, the "TEST inits present" lines), the `LONGSHOT_TEST_FORCE17` / `LONGSHOT_TEST_RTPROBE` lift patches in `nx2/build.py` (off unless set at build time) with R3 / F9 in the host, `RX_VK_MOVE_DIAG`, `RX_VK_LOG_WENT`, the "TEST" log lines in `vk_texture.cpp` (hand-overs, donors needed again, carries, made new), and test switches (`RX_VK_TEST_HANDOVER_MIN_KB`, `_POOL_FIRST`, `RX_VK_TEST_DONOR_READ`, `RX_VK_TEST_DEFER_UNIQUE`, `RX_VK_TEST_ONE_LEVEL`, `RX_VK_TEST_CARRY=2`). None of the switches has a row in `switches.def` (the log names them as unknown). Read first: `handover_take` and `carry_take` in `vk_texture.cpp`, the hand-over branch in `create`, and `texture_touch`'s deferred clear. ## Testing **Please no automatic fixes on this branch (`@fix`, bot pushes): it is for testing and feedback, and its next form is a clean branch.** **Tested:** Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, 3840x2160 DLAA. The walking route (Castle Town, the castle, Castle Town again) and free play in Castle Town and Hyrule Field, by hand, with each part switched on and off. Seen and fixed along the way: pop-in of new targets (the clear), a full-screen exposure flicker with DLAA (the depth guard), far LODs in Hyrule Field darker than on `main` (the drawn-once rule). With all of it on: no pop-in, flicker or dark LODs seen. The squashed commit builds on current `main` (Windows, llvm-mingw, without the test build switches). **Still to test:** - Any PC: play with it, and compare with a start with `RX_VK_TEST_HANDOVER=0` and `RX_VK_TEST_CARRY=0` (the hand-over and the carry off); report anything that looks different (by hand) - AMD and Intel cards, a Steam Deck, cards of 8 GB or less: the same, and VRAM against off (by hand) - Linux: the build and a run (by hand) ## Measurements **Verdict:** on the second Castle Town stay, frames over 20 ms 63.5 -> 26 (-59 %), 1 % low 41.2 -> 46.4 fps (+13 %), p99 21.5 -> 19.6 ms, fps 62.95 -> 63.9; loads of 30 MB or more 10.5 -> 1.3; image memory made and destroyed 404 -> 287 MB/s. The castle entry is smooth after 0.17-0.25 s (7-9 s on `main`). The game's part of a frame is 0.17 ms longer: a caveat of this implementation (below). Setup: Windows 11, Ryzen 9 9900X, RTX 4070 SUPER 12 GB, driver 621.24; 3840x2160 DLAA, uncapped, V-Sync off, the frame gate off, `RX_VK_LOAD=start` (every shader loaded before the title, so none is made during a run); the walking route (Castle Town, the castle, Castle Town again). Interleaved: PR, main, PR, main, then one more PR run of this exact commit (the logs off). The second Castle Town stay from 5 s after its entry to its end; the entries over the 10 s after the area change; the image memory and VRAM over the whole run. `main` built from 8aa5ab87 into a second game folder with the same options and shader cache. | | Before: main @ 8aa5ab87 (2 runs) | After: this PR @ f5cf931c (3 runs) | Change (the averages) | |---|---|---|---| | fps | 63.1 / 62.8 | 64.0 / 63.8 / 64.0 | 62.95 -> 63.9: **+1.6 %** | | p99 frame time | 21.7 / 21.3 ms | 19.6 / 19.7 / 19.5 ms | 21.5 -> 19.6 ms: **-1.9 ms (-9 %)** | | 1 % low | 40.0 / 42.3 fps | 46.3 / 46.6 / 46.3 fps | 41.2 -> 46.4 fps: **+13 %** | | Frames over 20 ms | 60 / 67 | 28 / 28 / 22 | 63.5 -> 26: **-59 %** | | Frames over 33 ms | 1 / 0 | 1 / 1 / 1 | 0.5 -> 1: the same (a frame or two) | | The game's part of a frame | 8.44 / 8.45 ms | 8.63 / 8.57 / 8.62 ms | 8.45 -> 8.61 ms: **+0.16 ms (+1.9 %)**, worse (the caveat below) | | Frames loading 30 MB or more | 10 / 11 | 1 / 0 / 3 | 10.5 -> 1.3: **-88 %** | | Image memory made and destroyed (the reaper's line) | 389 / 418 MB/s | 266 / 293 / 302 MB/s | 404 -> 287 MB/s: **-29 %** | | Highest VRAM in play | 7,448 / 7,466 MB | 7,121 / 7,402 / 7,064 MB | 7,457 -> 7,196 MB: **-261 MB (-3.5 %)** | | Castle entry: frames over 20 ms, the last of them | 5 at 6.9 s / 7 at 9.5 s | 5 at 0.17 s / 4 at 0.25 s / 4 at 0.17 s | smooth after **8.2 s -> 0.2 s** | | Market entry: frames over 20 ms / 33 ms / 50 ms | 24 / 6 / 3, 27 / 8 / 2 | 12 / 6 / 3, 17 / 8 / 3, 20 / 7 / 4 | over 20 ms 25.5 -> 16.3: **-36 %**; over 33 / 50 ms about the same, 7 -> 7 and 2.5 -> 3.3 (the area's load) | The first two PR runs had the logs on (`LONGSHOT_TEST_DIAG` did not exist yet); the third is this commit as it is. The longest stall of an entry (the game loading the area, 33-86 ms) is the same on both sides. **Caveat, the game's part (+0.17 ms):** the main thread's own CPU time is unchanged (4.24 against 4.34 ms); the game waits for the render thread more often: its catch-ups (a finish, a readback) 6.4 -> 11 per 600 frames, its queue full 1 -> 9-13 times. With the carry off (`RX_VK_TEST_CARRY=0`, one run) the catch-ups fall to 2, the game's part to 8.51 ms, and the rest of the gain stays (frames over 20 ms 18, p99 18.9 ms). So it is the carry as it is done here: it walks every texture for each texture made by a read, and a carried texture is marked drawn by the GPU, which likely makes the game's later access wait for a write-back. To be done more efficiently in a clean version (candidates by size and format; the carried texture's state). ## Risks - Not for merging: the test code and logs are in, the switches have no rows in `switches.def`, `MKWVK_API_VERSION` is not bumped for the diagnostic callback in `vk_api.h`. - A donor wrongly judged free shows as a target with wrong or missing content (pop-in, dark or stale areas). `RX_VK_TEST_HANDOVER=0` turns the hand-over off, `RX_VK_TEST_CARRY=0` the carry (at the start). - The carry costs the game's part 0.17 ms a frame as it is (Measurements). - Nothing changes in saves, `longshot_options.ini` or the caches. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] 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). - [x] 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 fix: a game-free test that fails on `main` and passes here. - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [ ] `MKWVK_API_VERSION` bumped (`MkwVkHost` or `MkwVkRenderer` in `gpu/vk/vk_api.h` changed). - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [ ] Screenshots of the same spot on `main` and here, for a change that shows on screen. - [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): render targets moved by the game's layout take over an unused image of their kind instead of a new one (POC, all on)
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 7s
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
f5cf931ce3
Proof of concept for testing and feedback, not for merging as it is: the code is the
local test branch squashed, with its test logs, switches and diagnostics left in.

The game packs its render targets bottom-up in one pool every frame; when one target
appears or goes, every target behind it moves to a new address, and the renderer (which
keys images by address) makes 12-44 new images at once: 20-29 ms frames in the market.

- RX_VK_TEST_HANDOVER=3 (default): a render target made new takes the image of an
  unused target of exactly its create info; never one that carries content (read before
  drawn in a present), one drawn and not read since, or one of levels/layers drawn in one
  present only (the far LODs drawn at an area's load).
- RX_VK_TEST_HANDOVER_CLEAR=2 (default): the handed-over image is cleared at its first
  write; a first read keeps the donor's content when the donor was the only candidate.
- RX_VK_TEST_CARRY=1 (default): a texture made by a read takes its unambiguous
  predecessor's image and content instead of a 32 MB load from memory (no integer formats).
- The upscalers' "scene depth may be gone" guard checks the depth texture's own id.
- LONGSHOT_TEST_DIAG=1 (off by default): the test logs and tooling of the investigation,
  and the D-pad down / F10 switch that turns all of the above off and on in play.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, 3840x2160 DLAA: the walking route (Castle Town, the castle, Castle Town again) 3 runs of this PR against 2 of main, interleaved, and free play in Castle Town and Hyrule Field by hand. No pop-in, flicker or dark LODs seen with it on; numbers in Measurements.

Tested in game: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, 3840x2160 DLAA: the walking route (Castle Town, the castle, Castle Town again) 3 runs of this PR against 2 of main, interleaved, and free play in Castle Town and Hyrule Field by hand. No pop-in, flicker or dark LODs seen with it on; numbers in Measurements.
Member

Possibly related, for context:

  • PR #2273 WIP: perf(vk): texture RAM cache, a proof of concept with its diagnostics (not for merging as is) — Open texture-memory POC in same Vulkan texture code; possible overlap and shared diagnostics.
  • PR #1996 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) — Open render-target pool reuse work; related resource lifecycle approach, though this PR hands off live images rather than extending pool grace.
  • issue #1268 Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) — Open issue on stutters from bursts of new textures and GPU-fence waits; adjacent performance symptom.
  • PR #1681 perf(vk): render targets take a pooled image's memory by size, and the pool holds longer on integrated GPUs — Merged render-target memory reuse/pooling for size-compatible images; prior art, distinct from exact-kind image handover.
Possibly related, for context: - PR #2273 WIP: perf(vk): texture RAM cache, a proof of concept with its diagnostics (not for merging as is) — Open texture-memory POC in same Vulkan texture code; possible overlap and shared diagnostics. - PR #1996 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) — Open render-target pool reuse work; related resource lifecycle approach, though this PR hands off live images rather than extending pool grace. - issue #1268 Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) — Open issue on stutters from bursts of new textures and GPU-fence waits; adjacent performance symptom. - PR #1681 perf(vk): render targets take a pooled image's memory by size, and the pool holds longer on integrated GPUs — Merged render-target memory reuse/pooling for size-compatible images; prior art, distinct from exact-kind image handover.
Veix changed title from WIP: perf(vk): render targets moved by the game's layout take over an unused image of their kind instead of a new one (POC, all on) to WIP: perf(vk): render targets moved by the game's layout shifts keep their images: no re-creation and re-upload (1 % low +13 %, POC) 2026-11-24 11:46:36 +00:00
Veix changed title from WIP: perf(vk): render targets moved by the game's layout shifts keep their images: no re-creation and re-upload (1 % low +13 %, POC) to perf(vk): render targets moved by the game's layout shifts keep their images: no re-creation and re-upload (1 % low +13 %, POC) 2026-11-24 17:27:20 +00:00
test(vk): the D-pad / F10 toggle switched off (testers' areas stayed in the state they were made in)
Some checks failed
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
PR description / Description follows the template (pull_request_target) Failing after 6s
0c4f855051
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some checks failed
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
PR description / Description follows the template (pull_request_target) Failing after 6s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'wip/render-target-handover:Veix-wip/render-target-handover'
git switch 'Veix-wip/render-target-handover'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!2454
No description provided.