WIP: perf(vk): a draw keeps its program across texture registrations and uniform updates that do not touch its answers #795

Draft
dyst wants to merge 2 commits from dyst/Longshot:perf/vk-program-pick-fast into main
Member

Type: perf · Risk: low · Tested on: Windows 11 (the game-free checks; the game A/B is next) · Needs: a game run on NVIDIA, AMD and Intel

Why

A draw finds its shader program variant through a fast path that only held while no texture had been registered and no uniform updated since, and the game does both between most draws as it streams. So most draws of the same program with the same textures went through the full pick (a hash, a map lookup, rebuilding the answers' handles) for the same answer. Found in an audit of the renderer's per-draw path; no issue on the tracker.

What changed

For programs whose texture answers are all read from c2, the fast path now holds while the picks entry it came from is unchanged and none of the slots its answers name was registered anew. Programs with handle programs or c3+ handles, and compute, keep the exact checks.

  • shaders: Pick::gen, ProgFast::pick/pick_gen, pick_slots_kept and the slots path in program_for (gpu/vk/vk_shader.cpp)
  • tests: tests/test_pick_slots.py replays random binds, registrations, updates and draws through the real program_for and checks the same program for every draw

Measurements

Verdict: not measured yet: A/B runs in the game (this PR against main on one base, interleaved) are next and will replace this section.

Flags and settings

One switch for an A/B.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_PICK_REG_GEN=1 The fast path only while nothing was registered or updated - unset On: the old checks measurement pending leave unset; =1 for an A/B

Testing

Tested: Windows 11, llvm-mingw (the builder's v2.0.14 tools): the new and changed checks; every check that reads the
changed code; -fsyntax-only of the changed renderer files with the build's flags and headers; python -I -B tests/run_all.py on this branch and on main @ aa95d35f, same PC and environment: the same results apart from the new test_pick_slots; the failures main has here are named in the first comment.

Not tested: the game yet. This PR is WIP until its A/B is in (next: this PR against main on one dev_packs base of
main @ aa95d35f, on an RTX 3080 with a Ryzen 9 3900X, Windows 11; AMD and Intel need other testers).

Must be tested:

  • Any OS and GPU: Kokiri Forest and Castle Town a few minutes, expecting the same picture and the log's vk: program picks: line counting most kept picks by their slots (Test Farm: @Beanstalk any, those scenes, the log line)

Risks

What could break: A program kept whose variant should have changed with a texture's type: a material drawn with the wrong variant (wrong colours) until its next full pick. The slots its answers depend on are checked by version.

Turning it off: RX_VK_PICK_REG_GEN=1

Compatibility: gpu/vk/vk_shader.cpp is one of the shader translator's stamped files: a player's shader caches are translated again after the update (as with every change to it). No settings or vk ABI change.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing says the game is not tested yet; only game-free checks and a syntax check are named, and game files changed.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks. Not ticked yet: Measurements only says not measured yet, and the per-pick FlatMap lookup cost it adds is unmeasured.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A game-free test added for the fix, failing on main and passing here.

🤖 Generated with Claude Code

**Type:** perf · **Risk:** low · **Tested on:** Windows 11 (the game-free checks; the game A/B is next) · **Needs:** a game run on NVIDIA, AMD and Intel ## Why A draw finds its shader program variant through a fast path that only held while no texture had been registered and no uniform updated since, and the game does both between most draws as it streams. So most draws of the same program with the same textures went through the full pick (a hash, a map lookup, rebuilding the answers' handles) for the same answer. Found in an audit of the renderer's per-draw path; no issue on the tracker. ## What changed For programs whose texture answers are all read from c2, the fast path now holds while the picks entry it came from is unchanged and none of the slots its answers name was registered anew. Programs with handle programs or c3+ handles, and compute, keep the exact checks. - shaders: `Pick::gen`, `ProgFast::pick`/`pick_gen`, `pick_slots_kept` and the slots path in `program_for` (`gpu/vk/vk_shader.cpp`) - tests: `tests/test_pick_slots.py` replays random binds, registrations, updates and draws through the real `program_for` and checks the same program for every draw ## Measurements **Verdict:** not measured yet: A/B runs in the game (this PR against main on one base, interleaved) are next and will replace this section. ### Flags and settings One switch for an A/B. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_PICK_REG_GEN=1` | The fast path only while nothing was registered or updated | - | unset | On: the old checks | measurement pending | leave unset; `=1` for an A/B | ## Testing **Tested:** Windows 11, llvm-mingw (the builder's v2.0.14 tools): the new and changed checks; every check that reads the changed code; `-fsyntax-only` of the changed renderer files with the build's flags and headers; python -I -B tests/run_all.py on this branch and on main @ aa95d35f, same PC and environment: the same results apart from the new `test_pick_slots`; the failures main has here are named in the first comment. **Not tested:** the game yet. This PR is WIP until its A/B is in (next: this PR against main on one dev_packs base of main @ aa95d35f, on an RTX 3080 with a Ryzen 9 3900X, Windows 11; AMD and Intel need other testers). **Must be tested:** - Any OS and GPU: Kokiri Forest and Castle Town a few minutes, expecting the same picture and the log's `vk: program picks:` line counting most kept picks `by their slots` (Test Farm: @Beanstalk any, those scenes, the log line) ## Risks **What could break:** A program kept whose variant should have changed with a texture's type: a material drawn with the wrong variant (wrong colours) until its next full pick. The slots its answers depend on are checked by version. **Turning it off:** `RX_VK_PICK_REG_GEN=1` **Compatibility:** `gpu/vk/vk_shader.cpp` is one of the shader translator's stamped files: a player's shader caches are translated again after the update (as with every change to it). No settings or vk ABI change. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [ ] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing says the game is not tested yet; only game-free checks and a syntax check are named, and game files changed. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [ ] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. Not ticked yet: Measurements only says not measured yet, and the per-pick FlatMap lookup cost it adds is unmeasured. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A game-free test added for the fix, failing on `main` and passing here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
perf(vk): a draw keeps its program across texture registrations and uniform updates that do not touch its answers
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 6s
Third-party parts / As their notes say (pull_request) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
62e59cc76d
The program pick's fast path (the last two picks, prog_fast) stood only while no texture at all had been registered and no
uniform updated since, and the game does both between most draws as it streams: a draw of the same program with the same
textures went through the full pick (the inputs' hash, the map, the answers' handles and a compare) for the same answer.

A kept pick now remembers the picks entry it came from (Pick::gen moves with the entry's program and handles). For a graphics
program whose answers are all read from c2 (answer_stage_mask != ~0) and whose stages' textures are the same, the fast path
stands while that entry is unchanged and none of the slots its handles name was registered anew (pick_slots_kept), and keeps
the program as the full pick would. Programs with handle programs or c3+ handles, and compute, keep the exact checks.
RX_VK_PICK_REG_GEN=1: as before.

tests/test_pick_slots.py replays random streams of binds, registrations, uniform updates and draws through the real
program_for and checks the same program is picked for every draw with and without the switch.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Author
Member

The checks on this PC (Windows 11, RTX 3080, Ryzen 9 3900X, llvm-mingw from the builder's v2.0.14 tools): python -I -B tests/run_all.py on main @ aa95d35f fails these 19 here, and so does this branch: test_appimage_player_build.py, test_bake_portability.py, test_cpm_discovery.py, test_cpp_preflight.py, test_crash_dialog.py, test_env_on.py, test_fpx_sticky.py, test_lift_cleanup_error.py, test_linux_preflight.py, test_make_game_cache.py, test_make_game_prepare.py, test_missing_nup.py, test_oot_state_tap.py, test_options_budget_once.py, test_readback_late.py, test_spawn_emit.py, test_tested_configurations.py, test_vk_pgo.py, test_walk_key.py. Any other failure in a full run on this branch was rerun on its own and passed (the full runs shared the PC with dev_packs builds: timing checks).

Next: an interleaved A/B in the game against main on one dev_packs base of aa95d35f; the numbers will replace the Measurements section.

The checks on this PC (Windows 11, RTX 3080, Ryzen 9 3900X, llvm-mingw from the builder's v2.0.14 tools): `python -I -B tests/run_all.py` on main @ aa95d35f fails these 19 here, and so does this branch: `test_appimage_player_build.py`, `test_bake_portability.py`, `test_cpm_discovery.py`, `test_cpp_preflight.py`, `test_crash_dialog.py`, `test_env_on.py`, `test_fpx_sticky.py`, `test_lift_cleanup_error.py`, `test_linux_preflight.py`, `test_make_game_cache.py`, `test_make_game_prepare.py`, `test_missing_nup.py`, `test_oot_state_tap.py`, `test_options_budget_once.py`, `test_readback_late.py`, `test_spawn_emit.py`, `test_tested_configurations.py`, `test_vk_pgo.py`, `test_walk_key.py`. Any other failure in a full run on this branch was rerun on its own and passed (the full runs shared the PC with dev_packs builds: timing checks). Next: an interleaved A/B in the game against main on one dev_packs base of aa95d35f; the numbers will replace the Measurements section.
HumanBean force-pushed perf/vk-program-pick-fast from 62e59cc76d
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 6s
Third-party parts / As their notes say (pull_request) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
to 71eca88277
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Has been cancelled
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (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
2026-11-15 18:46:45 +00:00
Compare
Owner

Rebased onto main @ 7bacf846. One conflict in gpu/vk/vk_shader.cpp (program_for): main added a comment block above Pick& pk = picks[key] while this PR moved that line below the keep lambda; I kept the PR's order and moved the comment with the line. Pushed as 71eca882. No tests were run here; the test boxes stay yours.

Rebased onto `main` @ 7bacf846. One conflict in gpu/vk/vk_shader.cpp (program_for): main added a comment block above `Pick& pk = picks[key]` while this PR moved that line below the `keep` lambda; I kept the PR's order and moved the comment with the line. Pushed as 71eca882. No tests were run here; the test boxes stay yours.
fix(vk): a kept pick names its entry of picks by key, as picks is a FlatMap since #231
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 5s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 5s
Third-party parts / As their notes say (pull_request) Successful in 8s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 7s
2b66bff0f6
The rebase onto main (#231's flat caches) left ProgFast holding a pointer into picks across draws. FlatMap's inserts
move every entry (flat_map.h), so after the table grew, pick_slots_kept read a freed array. A kept pick now keeps its
entry's key and looks it up again; the lookup's pointer is used at once, before any insert. The kept picks still
forget their entries at the 65,536-entry clear. tests/test_pick_slots.py follows (and includes flat_map.h, which its
fixture needs since the rebase).

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

A follow-up to this morning's rebase, pushed as 2b66bff0 on top of it.

The rebase onto main brought in #231 (#231), which made picks a FlatMap. A FlatMap insert can move every entry (flat_map.h), where an unordered_map never moved one. This PR's ProgFast::pick kept a pointer into picks from one draw to the next, so once a draw with a new key made the table grow, pick_slots_kept read f.pick->gen and f.pick->handles from the freed array. That isn't a text conflict, so neither the rebase nor the forge showed it.

The fix: a kept pick keeps its entry's key (has_pick, pick_key) and pick_slots_kept looks the entry up again (picks.find), returning it for immediate use before any insert. keep() takes the key alongside the entry. At the 65,536-entry clear the kept picks still forget their entries, as before. tests/test_pick_slots.py follows: its needles name the key, it checks no Pick pointer is kept, and its fixture includes flat_map.h, which it needed since the rebase anyway.

No tests were run here; the test boxes stay yours. Please check it against your intent, in particular that pick_slots_kept now does one FlatMap lookup per kept pick, which should be cheap next to the full pick it saves.

A follow-up to this morning's rebase, pushed as 2b66bff0 on top of it. The rebase onto `main` brought in #231 (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/231), which made `picks` a `FlatMap`. A `FlatMap` insert can move every entry (`flat_map.h`), where an `unordered_map` never moved one. This PR's `ProgFast::pick` kept a pointer into `picks` from one draw to the next, so once a draw with a new key made the table grow, `pick_slots_kept` read `f.pick->gen` and `f.pick->handles` from the freed array. That isn't a text conflict, so neither the rebase nor the forge showed it. The fix: a kept pick keeps its entry's key (`has_pick`, `pick_key`) and `pick_slots_kept` looks the entry up again (`picks.find`), returning it for immediate use before any insert. `keep()` takes the key alongside the entry. At the 65,536-entry clear the kept picks still forget their entries, as before. `tests/test_pick_slots.py` follows: its needles name the key, it checks no `Pick` pointer is kept, and its fixture includes `flat_map.h`, which it needed since the rebase anyway. No tests were run here; the test boxes stay yours. Please check it against your intent, in particular that `pick_slots_kept` now does one `FlatMap` lookup per kept pick, which should be cheap next to the full pick it saves.
Author
Member

Thanks @HumanBean: 2b66bff0 is the right fix, and I missed this. I reviewed the first version assuming picks was an unordered_map, whose entries never move. Since #231 it is a FlatMap, and ProgFast::pick held a pointer into it from one draw to the next, so a grown table left that pointer on freed memory.

Read against the intent, the fix keeps it:

  • A kept pick keeps its entry's key and gen, and pick_slots_kept finds the entry again with picks.find. The pointer it returns is used at once, by the keep before any insert.
  • The gen check still catches an entry overwritten under the same key.
  • Both kept picks forget their entries at the 65,536-entry clear, so a remade entry starting its gen again cannot be taken for the old one.
  • The cost is one FlatMap lookup per kept pick, small next to the full pick it saves.

This stays WIP. Its tests haven't been run on the rebased branch (test_pick_slots with flat_map.h, and the vk_shader.cpp checks), and it has no measurement yet: the one RX_VK_BENCH run so far is too few to call. The stamped-file cost holds: shipping it re-translates players' shader caches.

Thanks @HumanBean: 2b66bff0 is the right fix, and I missed this. I reviewed the first version assuming picks was an unordered_map, whose entries never move. Since #231 it is a FlatMap, and `ProgFast::pick` held a pointer into it from one draw to the next, so a grown table left that pointer on freed memory. Read against the intent, the fix keeps it: - A kept pick keeps its entry's key and gen, and `pick_slots_kept` finds the entry again with `picks.find`. The pointer it returns is used at once, by the keep before any insert. - The gen check still catches an entry overwritten under the same key. - Both kept picks forget their entries at the 65,536-entry clear, so a remade entry starting its gen again cannot be taken for the old one. - The cost is one FlatMap lookup per kept pick, small next to the full pick it saves. This stays WIP. Its tests haven't been run on the rebased branch (test_pick_slots with flat_map.h, and the vk_shader.cpp checks), and it has no measurement yet: the one RX_VK_BENCH run so far is too few to call. The stamped-file cost holds: shipping it re-translates players' shader caches.
Owner

Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).

  • Tested on my own PC: not ticked: Testing says the game is not tested yet; only game-free checks and a syntax check are named, and game files changed. Run it yourself on your PC (in the game, for a change the game runs) and say where and what you saw in Testing's Tested; or, when the fix's own case can't be run by hand, add a **Not testable by hand:** line saying why and what stands in for it. Then tick it.
  • Nothing gets worse that I know of: not ticked: Measurements only says not measured yet, and the per-pick FlatMap lookup cost it adds is unmeasured. Measure that cost and state it in Risks, then tick it.
Brought up to the [ready-for-review standard](https://git.magicbean.dev/MagicBeanDev/Longshot/src/branch/main/CONTRIBUTING.md#ready-for-review-out-of-wip) (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know). - *Tested on my own PC*: not ticked: Testing says the game is not tested yet; only game-free checks and a syntax check are named, and game files changed. Run it yourself on your PC (in the game, for a change the game runs) and say where and what you saw in Testing's *Tested*; or, when the fix's own case can't be run by hand, add a `**Not testable by hand:**` line saying why and what stands in for it. Then tick it. - *Nothing gets worse that I know of*: not ticked: Measurements only says not measured yet, and the per-pick FlatMap lookup cost it adds is unmeasured. Measure that cost and state it in Risks, then tick it.
Contributor

#795 on today's main: the standard test, no change in fps or CPU

I measured this PR on a second PC, on today's main.

Verdict: no measurable change in fps or CPU time a frame. The arms' medians are 67.79 against 67.14 fps and 69.9
against 69.2 CPU ms. With three pairs, the harness calls a result under 5 % diagnostic. Frame times, the game clock and
the GPU didn't move either.

The renderer's own replay times did move. In all three PR runs, draw is lower than in every control run (5.70-5.84
against 6.24-6.86 ms a frame), and so are descriptors (2.27-2.33 against 2.58-2.92). The render thread's jobs a frame
are the same in both arms (13.75 against 13.72 ms), so the frame doesn't get shorter.

The new path is taken but rarely here: by their slots is about 0.7 % of all picks. At 3.4 M picks the PR runs log
21,350-23,105 picks kept by their slots, and the total kept is the same as the control's (2,384,106-2,390,146 against
2,383,134-2,386,106).

What was run

  • Base: Longshot main @ ef6038ab (2026-11-18 03:06Z), built as one development base with llvm-mingw 20261104, as
    the official builds are. Control and PR share the same longshot.exe (0a53b387). The renderer DLL is the base's
    (ed1771bb) for the control and the PR's (2d430447) for the PR arm, built over the same base from the same objects
    (scripts/dev_packs.py).
  • How the PR was applied: your two commits, 71eca882 and 2b66bff0 (head 2b66bff0), were cherry-picked onto
    ef6038ab. 71eca882 had one conflict, in gpu/vk/vk_shader.cpp program_for, in the comment block above the
    prog_fast loop. Main's #1390 (03788b38) has since deleted the RX_VK_PICK_BIND_GEN kill switch: its comment
    sentence and the static const bool by_bind line. I kept main's comment line, dropped by_bind (unused on main), and
    kept all of the PR's new lines (the by_reg comment, by_reg, by_slots). 2b66bff0 applied cleanly. The resulting
    diff against ef6038ab has exactly the added and removed lines of your branch against its base 7bacf846 (288+/15-).
  • Shader preparation: vk_shader.cpp is a stamped translator file. The PR runtime was prepared again before any run
    with the game's own --prepare-shaders --compile-shaders most, as the builder does. It took 32 min here (the
    programs 10.4 min, then the pipelines). The counts match the base's preparation: 38,809 programs, 46,598 new, 69
    failed; 32,825 noted pipelines and 9,689 compute pipelines. Players get this re-prepare with the update, as the PR
    says.
  • PC: Ryzen 7 5700X3D (8 cores, 16 threads), Radeon RX 9070 XT, AMD's Windows driver 26.11.1, Windows 11.
  • Harness: our standard test (std_test.py 604af9c9, run_profile.py 6d998641). It runs Hyrule Field from a fixed
    save, with the camera turning at full speed (right stick held from the load). The game runs in a 1280x720 window
    (16:9), with the frame rate unlocked (HOS_FPS_MAX=240) and the game clock checked (HOS_FPS_LOG=1, 1.000 ±
    0.01). The render thread is on (RX_VK_ASYNC=1, as Threaded rendering Auto gives a 16-thread CPU), and the fixed
    test settings file is used. The window is 20 s after the load, with 3 alternating pairs, no warm-up and no
    replacements.
  • Background load: a small fixed GPU load runs beside the game in every run of both arms: 500 blended quads a
    frame at 100 fps, in its own window. On this PC, AMD's driver otherwise keeps the RX 9070 XT at ~1,550-1,850 MHz
    because the game's bursty load never reaches its boost threshold. Runs then measure a slower GPU and compare
    poorly. With the load, both arms run at ~2,450-2,580 MHz.
  • Order: each runtime had one unmeasured first start before the A/B. No runtime copy, pack or shader preparation ran
    within 15 min before the runs, and a disk-write probe was clean (max 0.4 ms).

Numbers

Per run, in run order. RT jobs and RT idle are the render thread's own line (vk: the render thread (600 presents ...): its jobs a frame, split into submits, presents and others). draw, descriptors and programs come from
vk: a frame's replay time (ms). Each is the mean of the last two lines inside the window. error lines counts lines
with error, fail, VUID, lost or validation. In every run of both arms it is one line, the crash watcher's start line.

run fps CPU ms p99 ms worst ms >50 ms >100 ms clock gpu_ms gpu_mhz RT jobs ms submits presents others RT idle draw ms descriptors ms programs ms error lines
ctl-0 67.79 73.4 20.8 81.2 1 0 1.000 7.35 2558 13.72 2.52 3.65 7.55 1.01 6.24 2.58 0.99 1
pr-0 67.14 71.8 23.5 74.9 1 0 1.000 7.30 2538 13.72 3.21 3.66 6.86 0.99 5.70 2.27 0.89 1
pr-1 68.64 68.8 20.4 76.8 1 0 1.000 7.35 2575 13.75 2.96 3.71 7.08 1.04 5.77 2.28 0.90 1
ctl-1 67.89 69.9 20.0 78.4 1 0 1.001 7.35 2542 13.62 2.54 3.54 7.54 0.87 6.30 2.63 0.97 1
ctl-2 64.59 66.9 21.0 53.8 1 0 1.000 7.60 2466 14.16 2.47 3.96 7.72 1.21 6.86 2.92 1.09 1
pr-2 66.04 69.2 20.4 68.8 1 0 1.000 7.50 2471 13.93 2.54 4.07 7.33 1.17 5.84 2.33 0.91 1
control, median 67.79 69.9 20.8 81.2 (max) 3 (sum) 0 1.000 7.35 2542 13.72 2.52 3.65 7.55 1.01 6.30 2.63 0.99
PR, median 67.14 69.2 20.4 76.8 (max) 3 (sum) 0 1.000 7.35 2538 13.75 2.96 3.71 7.08 1.04 5.77 2.28 0.90

No run was rejected, and no frame went over 100 ms in any run. The one frame over 50 ms in every run is the same in
both arms.

Checked, not checked

  • Checked: the checks that read the changed files (tests/run_all.py --changed ef6038ab) on the cherry-picked tree,
    and the same checks on ef6038ab. tests/test_pick_slots.py passes. The 4 failures (test_dev_packs,
    test_linux_pressure, test_recorder_sync, test_switch_table) fail on ef6038ab too, on this PC.
    test_switch_table.py gains one line here, "RX_VK_PICK_REG_GEN is read (gpu/vk/vk_shader.cpp) and has no row in
    gpu/vk/switches.def". Main's switch table (#1300) wants a row for it when you rebase.
  • Correctness glance: no new error lines in any run (see above). The same programs failed in the preparation as on
    the base (69). I also made one extra unmeasured run per runtime with RX_VK_SHOTS (a picture every 600 presents)
    and looked at the pictures. They showed the menu, the load and the turning field with the HUD, and nothing was wrong:
    no missing or wrong-coloured textures, objects or HUD parts. This is a glance, not an image comparison: the camera is
    at a different angle in each run.
  • Not checked: other scenes (the standard test is Hyrule Field only), RX_VK_PICK_REG_GEN=1 (the PR's off switch;
    the control is main without the PR), NVIDIA, Intel, Linux and the Steam Deck. No image comparison, no validation
    layers, no code review.

How to reproduce

git -C <main checkout> worktree add --detach wt-m-795 ef6038ab
git -C wt-m-795 cherry-pick 71eca882 2b66bff0   # resolve vk_shader.cpp as described above
./with_lock.sh 60 "pack" ./devpacks.sh pack base/ef6038ab dyst-795 --tree wt-m-795
./with_lock.sh 75 "rt" ./devpacks.sh rt base/ef6038ab rt-dyst-795 dyst-795   # prepares the shaders (32 min here)
./with_lock.sh 30 "rt" ./devpacks.sh rt base/ef6038ab rt-dyst-ctl
python -I std_test.py --runtime rt-dyst-ctl --name dyab795 --arm "pr@rt-dyst-795=" --options-ini test-profile-169.ini

(devpacks.sh is this PC's front for scripts/dev_packs.py; std_test.py is our standard-test harness.)

## #795 on today's main: the standard test, no change in fps or CPU I measured this PR on a second PC, on today's main. **Verdict:** no measurable change in fps or CPU time a frame. The arms' medians are 67.79 against 67.14 fps and 69.9 against 69.2 CPU ms. With three pairs, the harness calls a result under 5 % diagnostic. Frame times, the game clock and the GPU didn't move either. The renderer's own replay times did move. In all three PR runs, `draw` is lower than in every control run (5.70-5.84 against 6.24-6.86 ms a frame), and so are `descriptors` (2.27-2.33 against 2.58-2.92). The render thread's jobs a frame are the same in both arms (13.75 against 13.72 ms), so the frame doesn't get shorter. The new path is taken but rarely here: `by their slots` is about 0.7 % of all picks. At 3.4 M picks the PR runs log 21,350-23,105 picks kept by their slots, and the total kept is the same as the control's (2,384,106-2,390,146 against 2,383,134-2,386,106). ### What was run - **Base:** Longshot main @ ef6038ab (2026-11-18 03:06Z), built as one development base with llvm-mingw 20261104, as the official builds are. Control and PR share the same `longshot.exe` (0a53b387). The renderer DLL is the base's (ed1771bb) for the control and the PR's (2d430447) for the PR arm, built over the same base from the same objects (`scripts/dev_packs.py`). - **How the PR was applied:** your two commits, 71eca882 and 2b66bff0 (head 2b66bff0), were cherry-picked onto ef6038ab. 71eca882 had one conflict, in `gpu/vk/vk_shader.cpp` `program_for`, in the comment block above the `prog_fast` loop. Main's #1390 (03788b38) has since deleted the `RX_VK_PICK_BIND_GEN` kill switch: its comment sentence and the `static const bool by_bind` line. I kept main's comment line, dropped `by_bind` (unused on main), and kept all of the PR's new lines (the `by_reg` comment, `by_reg`, `by_slots`). 2b66bff0 applied cleanly. The resulting diff against ef6038ab has exactly the added and removed lines of your branch against its base 7bacf846 (288+/15-). - **Shader preparation:** `vk_shader.cpp` is a stamped translator file. The PR runtime was prepared again before any run with the game's own `--prepare-shaders --compile-shaders most`, as the builder does. It took 32 min here (the programs 10.4 min, then the pipelines). The counts match the base's preparation: 38,809 programs, 46,598 new, 69 failed; 32,825 noted pipelines and 9,689 compute pipelines. Players get this re-prepare with the update, as the PR says. - **PC:** Ryzen 7 5700X3D (8 cores, 16 threads), Radeon RX 9070 XT, AMD's Windows driver 26.11.1, Windows 11. - **Harness:** our standard test (`std_test.py` 604af9c9, `run_profile.py` 6d998641). It runs Hyrule Field from a fixed save, with the camera turning at full speed (right stick held from the load). The game runs in a 1280x720 window (16:9), with the frame rate unlocked (`HOS_FPS_MAX=240`) and the game clock checked (`HOS_FPS_LOG=1`, 1.000 ± 0.01). The render thread is on (`RX_VK_ASYNC=1`, as Threaded rendering Auto gives a 16-thread CPU), and the fixed test settings file is used. The window is 20 s after the load, with 3 alternating pairs, no warm-up and no replacements. - **Background load:** a small fixed GPU load runs beside the game in every run of both arms: 500 blended quads a frame at 100 fps, in its own window. On this PC, AMD's driver otherwise keeps the RX 9070 XT at ~1,550-1,850 MHz because the game's bursty load never reaches its boost threshold. Runs then measure a slower GPU and compare poorly. With the load, both arms run at ~2,450-2,580 MHz. - **Order:** each runtime had one unmeasured first start before the A/B. No runtime copy, pack or shader preparation ran within 15 min before the runs, and a disk-write probe was clean (max 0.4 ms). ### Numbers Per run, in run order. `RT jobs` and `RT idle` are the render thread's own line (`vk: the render thread (600 presents ...)`: its jobs a frame, split into submits, presents and others). `draw`, `descriptors` and `programs` come from `vk: a frame's replay time (ms)`. Each is the mean of the last two lines inside the window. `error lines` counts lines with error, fail, VUID, lost or validation. In every run of both arms it is one line, the crash watcher's start line. | run | fps | CPU ms | p99 ms | worst ms | >50 ms | >100 ms | clock | gpu_ms | gpu_mhz | RT jobs ms | submits | presents | others | RT idle | draw ms | descriptors ms | programs ms | error lines | |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| | ctl-0 | 67.79 | 73.4 | 20.8 | 81.2 | 1 | 0 | 1.000 | 7.35 | 2558 | 13.72 | 2.52 | 3.65 | 7.55 | 1.01 | 6.24 | 2.58 | 0.99 | 1 | | pr-0 | 67.14 | 71.8 | 23.5 | 74.9 | 1 | 0 | 1.000 | 7.30 | 2538 | 13.72 | 3.21 | 3.66 | 6.86 | 0.99 | 5.70 | 2.27 | 0.89 | 1 | | pr-1 | 68.64 | 68.8 | 20.4 | 76.8 | 1 | 0 | 1.000 | 7.35 | 2575 | 13.75 | 2.96 | 3.71 | 7.08 | 1.04 | 5.77 | 2.28 | 0.90 | 1 | | ctl-1 | 67.89 | 69.9 | 20.0 | 78.4 | 1 | 0 | 1.001 | 7.35 | 2542 | 13.62 | 2.54 | 3.54 | 7.54 | 0.87 | 6.30 | 2.63 | 0.97 | 1 | | ctl-2 | 64.59 | 66.9 | 21.0 | 53.8 | 1 | 0 | 1.000 | 7.60 | 2466 | 14.16 | 2.47 | 3.96 | 7.72 | 1.21 | 6.86 | 2.92 | 1.09 | 1 | | pr-2 | 66.04 | 69.2 | 20.4 | 68.8 | 1 | 0 | 1.000 | 7.50 | 2471 | 13.93 | 2.54 | 4.07 | 7.33 | 1.17 | 5.84 | 2.33 | 0.91 | 1 | | **control, median** | **67.79** | **69.9** | 20.8 | 81.2 (max) | 3 (sum) | 0 | 1.000 | 7.35 | 2542 | 13.72 | 2.52 | 3.65 | 7.55 | 1.01 | 6.30 | 2.63 | 0.99 | | | **PR, median** | **67.14** | **69.2** | 20.4 | 76.8 (max) | 3 (sum) | 0 | 1.000 | 7.35 | 2538 | 13.75 | 2.96 | 3.71 | 7.08 | 1.04 | 5.77 | 2.28 | 0.90 | | No run was rejected, and no frame went over 100 ms in any run. The one frame over 50 ms in every run is the same in both arms. ### Checked, not checked - **Checked:** the checks that read the changed files (`tests/run_all.py --changed ef6038ab`) on the cherry-picked tree, and the same checks on ef6038ab. `tests/test_pick_slots.py` passes. The 4 failures (`test_dev_packs`, `test_linux_pressure`, `test_recorder_sync`, `test_switch_table`) fail on ef6038ab too, on this PC. `test_switch_table.py` gains one line here, "RX_VK_PICK_REG_GEN is read (gpu/vk/vk_shader.cpp) and has no row in gpu/vk/switches.def". Main's switch table (#1300) wants a row for it when you rebase. - **Correctness glance:** no new error lines in any run (see above). The same programs failed in the preparation as on the base (69). I also made one extra unmeasured run per runtime with `RX_VK_SHOTS` (a picture every 600 presents) and looked at the pictures. They showed the menu, the load and the turning field with the HUD, and nothing was wrong: no missing or wrong-coloured textures, objects or HUD parts. This is a glance, not an image comparison: the camera is at a different angle in each run. - **Not checked:** other scenes (the standard test is Hyrule Field only), `RX_VK_PICK_REG_GEN=1` (the PR's off switch; the control is main without the PR), NVIDIA, Intel, Linux and the Steam Deck. No image comparison, no validation layers, no code review. ### How to reproduce ``` git -C <main checkout> worktree add --detach wt-m-795 ef6038ab git -C wt-m-795 cherry-pick 71eca882 2b66bff0 # resolve vk_shader.cpp as described above ./with_lock.sh 60 "pack" ./devpacks.sh pack base/ef6038ab dyst-795 --tree wt-m-795 ./with_lock.sh 75 "rt" ./devpacks.sh rt base/ef6038ab rt-dyst-795 dyst-795 # prepares the shaders (32 min here) ./with_lock.sh 30 "rt" ./devpacks.sh rt base/ef6038ab rt-dyst-ctl python -I std_test.py --runtime rt-dyst-ctl --name dyab795 --arm "pr@rt-dyst-795=" --options-ini test-profile-169.ini ``` (`devpacks.sh` is this PC's front for `scripts/dev_packs.py`; `std_test.py` is our standard-test harness.)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 5s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 5s
Third-party parts / As their notes say (pull_request) Successful in 8s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 7s
This pull request has changes conflicting with the target branch.
  • gpu/vk/vk_shader.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-program-pick-fast:dyst-perf/vk-program-pick-fast'
git switch 'dyst-perf/vk-program-pick-fast'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!795
No description provided.