perf(vk): add RX_VK_MESH_FAST mesh program, bank, and UBO descriptor fast paths #2946

Open
siantm wants to merge 1 commit from siantm/Longshot:perf/vk-mesh-prog-bank-ubo into main
Contributor

Summary

On Switch 2 / NVN2, Task (6), Mesh (7), and UBO-heavy world draws repeated shader selection, driver-bank fills, program flag scans, null-sampler verification loops, and barrier stat locking on every draw. This PR removes those bottlenecks behind RX_VK_MESH_FAST (default 1, wired to HOS_AB), reducing draw_ms (-0.185 ms, -2.37%) and wait_gpu_ms (-0.186 ms, -7.88%) to improve Market frame time by -0.182 ms (+1.34% FPS, 95% CI +0.87% to +1.84%).

What this changes:

  • Mesh program fast path (gpu/vk/vk_shader.cpp): Extends answer_stage_mask to stages 1, 6, 7 and routes ProgramKind::Mesh through the TLS prog_fast + picks lookup via program_pick instead of taking global shader_mu and re-checking codes_of/mesh_key/still_valid on every mesh draw.
  • Task/Mesh BankCache narrowing (gpu/vk/vk_draw.cpp): Keys uniform_range() BankCache on s.tex_gen[bank_stage] for c2 (index == 2) and s.ssbo_gen[bank_stage] for c0 within kPointerTable (n <= 0x880) instead of invalidating on every UBO bind (s.bind_gen), keeping c.size current on FC_BANK_SAME hits.
  • Cached Program flags & widened ubo_delta_safe (gpu/vk/vk_shader.h, vk_shader.cpp, vk_progcache.cpp, vk_draw.cpp): Precomputes stage_mask and cached_flags (kProgUboDeltaSafe, kProgUboDeltaSafeGlobal, kProgWritesSsbo) once at translation/load, allowing info.native_global_bounds shaders onto the ubo_delta fast path when all SSBOs are in c0 and all textures in c2.
  • Command & descriptor overhead (gpu/vk/draw_key.h, vk_draw.cpp, vk_replay.cpp): Unrolls/hoists branches with single-resize in words_append and words_same_store, tracks DescWriter::has_null_sampler so bind_descriptors skips the null-sampler scan when false, and skips unconditional st_barrier_flags_mu locking in NOP_BARRIER unless call_count_on() is enabled.

Key files to read first: vk_shader.h, vk_shader.cpp, vk_draw.cpp, draw_key.h, and vk_replay.cpp.

Testing

Tested: Windows 11, NVIDIA GeForce RTX 4060 (driver 621.40, 591.74 / Vulkan 1.4):

  • Ran 3×90s queued in-run HOS_AB=RX_VK_MESH_FAST=0,3,0 sessions in market (1280x720, 50% internal res, V-Sync off, uncapped HOS_FPS_MAX=1000, 89 paired periods) via dev.py ab: 0 crashes, 0 visual/Vulkan errors, and consistent speedup in all 3 runs (AB1..AB3).
  • python -X utf8 -I tests/test_vk_mesh_fast.py: passed.
  • python -X utf8 -I tests/test_draw_side_effects.py: passed.
  • python -X utf8 -I tests/test_hos_ab.py: passed.
  • python -X utf8 -I tests/test_bank_gen.py: passed.
  • python -X utf8 -I tests/test_pick_tex_gen.py: passed.
  • Not run as a full mise run test suite on this branch (test_vk_mesh_fast.py, test_draw_side_effects.py, test_hos_ab.py, test_bank_gen.py, test_pick_tex_gen.py ran here directly). Pre-existing baseline failures on main @ 4908cc6da (test_switch_table.py, test_tex_desc_memo.py, test_recording_admission.py, and pre-existing spirv_pack::Store fixture errors in vk_progcache tests) are unrelated to this PR.

Still to test:

  • @Beanstalk: Linux (RADV) smoke and shader/mesh draw parity run on main, plus GPU/scene sweep (Hyrule Field, Fire Temple, Kokiri Forest) to confirm no visual or performance regression outside RTX 4060 Market.
  • @Beanstalk: CI full test suite (mise run test) on Linux and Windows.

Measurements

Verdict: faster: +1.34% FPS (+1.36% mean frame time reduction when enabled; -0.182 ms per frame, 95% CI +0.87% to +1.84%, 89 paired periods across 3 in-run HOS_AB sessions; 1% Low +1.98%, 0.1% Low +0.24%).

Setup: Windows 11, NVIDIA GeForce RTX 4060 (driver 621.40); Market, child (crowded) (window 1280x720); quality preset Custom, resolution 50% (768x432), output res 1280x720, frame generation Off, vsync Off; uncapped (HOS_FPS_MAX=1000); the frame trace (RX_VK_FRAME_TRACE=1), 90 s each after a warm-up until no frame waited for a pipeline, 3 runs, RX_VK_MESH_FAST flipped every 3 s within each run (HOS_AB=RX_VK_MESH_FAST=0,3,0).

Baseline: both columns are one build, v3.2.0-186-gd693b9dd0 (not main): RX_VK_MESH_FAST=0 (side 1) against RX_VK_MESH_FAST unset / 1 (side 0) on it.

Before, RX_VK_MESH_FAST=0: this PR @ d693b9dd0 After, RX_VK_MESH_FAST unset: this PR @ d693b9dd0 Δ
FPS (pooled perf.py ab) 73.7 74.7 +1.34%
Mean frame time 13.57 ms 13.39 ms -0.18 ms
Median frame time 13.31 ms 13.15 ms -0.16 ms
P99 frame time 16.94 ms 16.66 ms -0.28 ms
Avg / P50 / 1% Low / 0.1% Low FPS 73.67 / 75.13 / 59.03 / 49.78 74.70 / 76.10 / 60.20 / 49.90 +1.40% / +1.29% / +1.98% / +0.24%
draw_ms (programs / desc / cmds) 7.815 ms (1.301 / 2.930 / 2.377) 7.629 ms (1.245 / 2.860 / 2.325) -0.185 ms (-2.37%)
wait_gpu_ms 2.361 ms 2.175 ms -0.186 ms (-7.88%)
Frames >= 50 ms per minute 0.00 0.00 +0.00
AB1: 5740 frames, side 0 (ON) 75.0 fps, side 1 (OFF) 74.1 fps, side 1 -1.16% fps
AB2: 6002 frames, side 0 (ON) 74.6 fps, side 1 (OFF) 73.6 fps, side 1 -1.25% fps
AB3: 5772 frames, side 0 (ON) 74.5 fps, side 1 (OFF) 73.3 fps, side 1 -1.58% fps
POOLED_DIFF: 89 periods, side 1 - side 0 = +0.1820 ms (+1.36%, fps -1.34%), 95% CI [+0.1169, +0.2466] ms (+0.87% to +1.84%)
[hos host] vk: switches set (10): HOS_AB=RX_VK_MESH_FAST=0,3,0 (diag), HOS_AUDIO_MUTE=1 (diag), HOS_DISCORD=0 (kill), HOS_FPS_MAX=1000 (player), HOS_WINDOW_NOACTIVATE=1 (diag), RX_VK_FRAME_TRACE=1 (diag)

Risks

  • Correctness / invalidation: If an info.native_global_bounds shader reads c3+ UBO values to index dynamic SSBO/texture addresses outside c0/c2, or if a Task/Mesh c0 table reads > 0x880 entries without n > 0x880, descriptor updates could go stale; guarded by explicit ProgramFastFlags checks (c0 only, no written SSBOs, no image descriptors, textures in c2, n <= 0x880).
  • Rollback / toggle: Setting RX_VK_MESH_FAST=0 disables every optimization in this PR at runtime, or reverting the commit removes it completely.
  • No save/options/cache impact: Saves, longshot_options.ini, and shader/pipeline caches are unaffected.

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.
## Summary On Switch 2 / NVN2, Task (`6`), Mesh (`7`), and UBO-heavy world draws repeated shader selection, driver-bank fills, program flag scans, null-sampler verification loops, and barrier stat locking on every draw. This PR removes those bottlenecks behind `RX_VK_MESH_FAST` (default `1`, wired to `HOS_AB`), reducing `draw_ms` (`-0.185 ms`, `-2.37%`) and `wait_gpu_ms` (`-0.186 ms`, `-7.88%`) to improve Market frame time by **-0.182 ms** (**+1.34% FPS**, 95% CI `+0.87%` to `+1.84%`). What this changes: - **Mesh program fast path (`gpu/vk/vk_shader.cpp`):** Extends `answer_stage_mask` to stages `1, 6, 7` and routes `ProgramKind::Mesh` through the TLS `prog_fast` + `picks` lookup via `program_pick` instead of taking global `shader_mu` and re-checking `codes_of`/`mesh_key`/`still_valid` on every mesh draw. - **Task/Mesh `BankCache` narrowing (`gpu/vk/vk_draw.cpp`):** Keys `uniform_range()` `BankCache` on `s.tex_gen[bank_stage]` for `c2` (`index == 2`) and `s.ssbo_gen[bank_stage]` for `c0` within `kPointerTable` (`n <= 0x880`) instead of invalidating on every UBO bind (`s.bind_gen`), keeping `c.size` current on `FC_BANK_SAME` hits. - **Cached `Program` flags & widened `ubo_delta_safe` (`gpu/vk/vk_shader.h`, `vk_shader.cpp`, `vk_progcache.cpp`, `vk_draw.cpp`):** Precomputes `stage_mask` and `cached_flags` (`kProgUboDeltaSafe`, `kProgUboDeltaSafeGlobal`, `kProgWritesSsbo`) once at translation/load, allowing `info.native_global_bounds` shaders onto the `ubo_delta` fast path when all SSBOs are in `c0` and all textures in `c2`. - **Command & descriptor overhead (`gpu/vk/draw_key.h`, `vk_draw.cpp`, `vk_replay.cpp`):** Unrolls/hoists branches with single-`resize` in `words_append` and `words_same_store`, tracks `DescWriter::has_null_sampler` so `bind_descriptors` skips the null-sampler scan when false, and skips unconditional `st_barrier_flags_mu` locking in `NOP_BARRIER` unless `call_count_on()` is enabled. Key files to read first: [vk_shader.h](file:///gpu/vk/vk_shader.h), [vk_shader.cpp](file:///gpu/vk/vk_shader.cpp), [vk_draw.cpp](file:///gpu/vk/vk_draw.cpp), [draw_key.h](file:///gpu/vk/draw_key.h), and [vk_replay.cpp](file:///gpu/vk/vk_replay.cpp). ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 (driver `621.40`, `591.74` / Vulkan 1.4): - Ran 3×90s queued in-run `HOS_AB=RX_VK_MESH_FAST=0,3,0` sessions in `market` (`1280x720`, 50% internal res, V-Sync off, uncapped `HOS_FPS_MAX=1000`, `89` paired periods) via `dev.py ab`: 0 crashes, 0 visual/Vulkan errors, and consistent speedup in all 3 runs (`AB1..AB3`). - `python -X utf8 -I tests/test_vk_mesh_fast.py`: passed. - `python -X utf8 -I tests/test_draw_side_effects.py`: passed. - `python -X utf8 -I tests/test_hos_ab.py`: passed. - `python -X utf8 -I tests/test_bank_gen.py`: passed. - `python -X utf8 -I tests/test_pick_tex_gen.py`: passed. - Not run as a full `mise run test` suite on this branch (`test_vk_mesh_fast.py`, `test_draw_side_effects.py`, `test_hos_ab.py`, `test_bank_gen.py`, `test_pick_tex_gen.py` ran here directly). Pre-existing baseline failures on `main @ 4908cc6da` (`test_switch_table.py`, `test_tex_desc_memo.py`, `test_recording_admission.py`, and pre-existing `spirv_pack::Store` fixture errors in `vk_progcache` tests) are unrelated to this PR. **Still to test:** - `@Beanstalk`: Linux (RADV) smoke and shader/mesh draw parity run on `main`, plus GPU/scene sweep (Hyrule Field, Fire Temple, Kokiri Forest) to confirm no visual or performance regression outside RTX 4060 Market. - `@Beanstalk`: CI full test suite (`mise run test`) on Linux and Windows. ## Measurements **Verdict:** faster: **+1.34% FPS** (`+1.36%` mean frame time reduction when enabled; **-0.182 ms** per frame, 95% CI **`+0.87%` to `+1.84%`**, `89` paired periods across 3 in-run `HOS_AB` sessions; `1% Low +1.98%`, `0.1% Low +0.24%`). Setup: Windows 11, NVIDIA GeForce RTX 4060 (driver `621.40`); Market, child (crowded) (window `1280x720`); quality preset Custom, resolution 50% (`768x432`), output res `1280x720`, frame generation Off, vsync Off; uncapped (`HOS_FPS_MAX=1000`); the frame trace (`RX_VK_FRAME_TRACE=1`), 90 s each after a warm-up until no frame waited for a pipeline, 3 runs, `RX_VK_MESH_FAST` flipped every 3 s within each run (`HOS_AB=RX_VK_MESH_FAST=0,3,0`). **Baseline:** both columns are one build, `v3.2.0-186-gd693b9dd0` (not `main`): `RX_VK_MESH_FAST=0` (`side 1`) against `RX_VK_MESH_FAST` unset / `1` (`side 0`) on it. | | Before, RX_VK_MESH_FAST=0: this PR @ d693b9dd0 | After, RX_VK_MESH_FAST unset: this PR @ d693b9dd0 | Δ | |---|---|---|---| | FPS (pooled `perf.py ab`) | 73.7 | 74.7 | +1.34% | | Mean frame time | 13.57 ms | 13.39 ms | -0.18 ms | | Median frame time | 13.31 ms | 13.15 ms | -0.16 ms | | P99 frame time | 16.94 ms | 16.66 ms | -0.28 ms | | Avg / P50 / 1% Low / 0.1% Low FPS | 73.67 / 75.13 / 59.03 / 49.78 | 74.70 / 76.10 / 60.20 / 49.90 | +1.40% / +1.29% / +1.98% / +0.24% | | `draw_ms` (`programs` / `desc` / `cmds`) | 7.815 ms (`1.301` / `2.930` / `2.377`) | 7.629 ms (`1.245` / `2.860` / `2.325`) | -0.185 ms (-2.37%) | | `wait_gpu_ms` | 2.361 ms | 2.175 ms | -0.186 ms (-7.88%) | | Frames >= 50 ms per minute | 0.00 | 0.00 | +0.00 | ```text AB1: 5740 frames, side 0 (ON) 75.0 fps, side 1 (OFF) 74.1 fps, side 1 -1.16% fps AB2: 6002 frames, side 0 (ON) 74.6 fps, side 1 (OFF) 73.6 fps, side 1 -1.25% fps AB3: 5772 frames, side 0 (ON) 74.5 fps, side 1 (OFF) 73.3 fps, side 1 -1.58% fps POOLED_DIFF: 89 periods, side 1 - side 0 = +0.1820 ms (+1.36%, fps -1.34%), 95% CI [+0.1169, +0.2466] ms (+0.87% to +1.84%) [hos host] vk: switches set (10): HOS_AB=RX_VK_MESH_FAST=0,3,0 (diag), HOS_AUDIO_MUTE=1 (diag), HOS_DISCORD=0 (kill), HOS_FPS_MAX=1000 (player), HOS_WINDOW_NOACTIVATE=1 (diag), RX_VK_FRAME_TRACE=1 (diag) ``` ## Risks - **Correctness / invalidation:** If an `info.native_global_bounds` shader reads `c3+` UBO values to index dynamic SSBO/texture addresses outside `c0`/`c2`, or if a Task/Mesh `c0` table reads `> 0x880` entries without `n > 0x880`, descriptor updates could go stale; guarded by explicit `ProgramFastFlags` checks (`c0` only, no written SSBOs, no image descriptors, textures in `c2`, `n <= 0x880`). - **Rollback / toggle:** Setting `RX_VK_MESH_FAST=0` disables every optimization in this PR at runtime, or reverting the commit removes it completely. - **No save/options/cache impact:** Saves, `longshot_options.ini`, and shader/pipeline caches are unaffected. ## 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. - [x] `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 - [x] 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. - [x] 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): add RX_VK_MESH_FAST mesh program, bank, and UBO descriptor fast paths
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 4s
d693b9dd0f
Routes ProgramKind::Mesh through TLS prog_fast/picks (stages 1, 6, 7), narrows Task/Mesh BankCache invalidation to tex_gen/ssbo_gen (c0 <= 0x880), precomputes Program flags with widened ubo_delta_safe for native_global_bounds in c0/c2, optimizes words_append/words_same_store, tracks has_null_sampler, and skips unconditional NOP_BARRIER flag mutex locking. All optimizations toggle via RX_VK_MESH_FAST (default 1, wired to HOS_AB).

Assisted-by: Antigravity
Author
Contributor

Tested in game: Windows 11 RTX 4060 Market 3x90s HOS_AB=RX_VK_MESH_FAST=0,3,0 (89 periods): +1.34% FPS (74.7 vs 73.7), -0.182 ms (95% CI +0.87% to +1.84%), +1.98% 1% Low FPS, -2.37% draw_ms

Tested in game: Windows 11 RTX 4060 Market 3x90s HOS_AB=RX_VK_MESH_FAST=0,3,0 (89 periods): +1.34% FPS (74.7 vs 73.7), -0.182 ms (95% CI +0.87% to +1.84%), +1.98% 1% Low FPS, -2.37% draw_ms
Member

Possibly related, for context:

  • PR #2339 WIP: perf(vk): cache Task/Mesh c2/c0 banks by stage gen and pointer_table per stage — Open PR for the same Task/Mesh c2/c0 bank generation cache optimization.
  • PR #2899 perf(vk): add UBO descriptor delta fast path, 8-slot ub_gap_cache, and lock-free invalidate exits — Merged UBO descriptor fast path; this PR extends adjacent descriptor hot paths.
Possibly related, for context: - PR #2339 WIP: perf(vk): cache Task/Mesh c2/c0 banks by stage gen and pointer_table per stage — Open PR for the same Task/Mesh c2/c0 bank generation cache optimization. - PR #2899 perf(vk): add UBO descriptor delta fast path, 8-slot ub_gap_cache, and lock-free invalidate exits — Merged UBO descriptor fast path; this PR extends adjacent descriptor hot paths.
Member

#2946: Deck measurement

Measurements on a Steam Deck LCD (RADV VANGOGH, Mesa 26.2.0-devel, Vulkan 1.4, AC power, GPU clock pinned at 1600 MHz), 2026-12-01.

Build: base 87045899 plus a dev-pack of main (4908cc6d) with #2932, #2946 and #2952 merged (merge head e72783d7), renderer and host both from that tree. Settings per arm: 1280x800 output, the game's own upscaler, quality preset Custom/0, shadows 1, V-Sync off, no fps cap, no overlays. Route: slot 05 save, Hyrule Field anchor, 1,200 presents of warm-up, then three passes of walking, panning, full-stick turns and a walk-and-circle. Play window is 30-97 % of each frame trace. Arms are separate launches, interleaved in time, identical except for the switch set.

HOS_AB is not usable on this platform yet: the A/B thread does not start (ab: the A/B's thread did not start). Root cause: glibc refuses a thread stack smaller than the executable's static TLS block plus a guard page and a rest stack, and this host binary's block is 61,936 bytes, so the 64 KiB CreateThread request in host/hos_ab.c is refused with EINVAL. A fix (a CreateThread stack under the executable's static TLS block) is in review as #2971, so these numbers come from separate launches rather than the in-run A/B.

50 % render, stack of the three switches, 5 runs on against 4 off:

metric on off delta permutation p
fps 36.07 35.17 +0.90 (+2.57 %) 0.048
mean frame 27.74 ms 28.44 ms -0.71 ms (-2.48 %) 0.056
median frame 26.70 ms 27.50 ms -0.80 ms (-2.89 %) 0.008
p99 frame 52.6 ms 53.6 ms -2.0 % within spread
frames over 60 ms 0.63 % 0.64 % none within spread

Median ranges are separated (worst on-run 27.07 ms, best off-run 27.10 ms); fps ranges overlap. Run-to-run spread on this machine is 3-12 %, larger than the effect, so the medians are the firmer statement. p is an exact permutation test over run labels (all 126 splits of nine runs; 0.008 is the floor of that test).

Phase medians, two paired samples (ms, on against off): desc_ms 2.81/2.78 against 3.18 (-11.6 %/-12.6 %), programs_ms 1.45/1.44 against 1.62 (-10.5 %/-11.1 %), draw_ms 10.13/9.94 against 10.76 (-5.9 %/-7.6 %), cmds_ms 4.37/4.24 against 4.45 (-1.8 %/-4.7 %), game_ms unchanged in one sample and -6.0 % in the other (noise).

100 % render (the Deck's default), 3 runs a side: fps 31.34 against 30.67 (+2.21 %, p 0.15), median frame 31.12 against 31.34 ms (-0.22 ms, p 0.25). The host phases move the same way (desc_ms -7.5 to -10.4 %, programs_ms -8.9 to -12.1 %, draw_ms -2.9 to -6.8 %, render -1.8 to -2.7 %), but gpu_wait_ms rises by 0.91 to 1.01 ms (+36 to +42 %) in all three pairs, so at native resolution the host saving is largely spent waiting for the GPU. That is expected for a GPU-bound frame and is not a fault of the change.

Limits: one scene, one save, one machine; Deck LCD only; the switches were moved together, so this table does not separate the three PRs from each other. Raw traces are on my Deck and archived locally, available on request.

For this PR specifically: #2946's share of the gain is visible by subtraction. A build of #2932 + #2952 + #2958 (without #2946, the largest set that merges without editing anyone's code) gives desc_ms -5.1 to -8.5 % and draw_ms -2.6 to -5.2 % at 50 %, against desc_ms -11.6 to -12.6 % here. The mesh bank and UBO descriptor fast paths therefore carry a good half of the descriptor win, which is the largest single phase saving we measured on this hardware.

One conflict note for the queue: #2946 does not merge cleanly on top of #2954 (vk_internal.h, vk_progcache.cpp, vk_shader.cpp) or #2958 (vk_draw.cpp). Those two merge with each other and with #2952's test file alone; #2946 and #2952 merge cleanly. If both families are wanted, one of them needs a rebase.

## #2946: Deck measurement Measurements on a Steam Deck LCD (RADV VANGOGH, Mesa 26.2.0-devel, Vulkan 1.4, AC power, GPU clock pinned at 1600 MHz), 2026-12-01. Build: base `87045899` plus a dev-pack of `main` (`4908cc6d`) with #2932, #2946 and #2952 merged (merge head `e72783d7`), renderer and host both from that tree. Settings per arm: 1280x800 output, the game's own upscaler, quality preset Custom/0, shadows 1, V-Sync off, no fps cap, no overlays. Route: slot 05 save, Hyrule Field anchor, 1,200 presents of warm-up, then three passes of walking, panning, full-stick turns and a walk-and-circle. Play window is 30-97 % of each frame trace. Arms are separate launches, interleaved in time, identical except for the switch set. `HOS_AB` is not usable on this platform yet: the A/B thread does not start (`ab: the A/B's thread did not start`). Root cause: glibc refuses a thread stack smaller than the executable's static TLS block plus a guard page and a rest stack, and this host binary's block is 61,936 bytes, so the 64 KiB `CreateThread` request in `host/hos_ab.c` is refused with EINVAL. A fix (a `CreateThread` stack under the executable's static TLS block) is in review as #2971, so these numbers come from separate launches rather than the in-run A/B. **50 % render, stack of the three switches, 5 runs on against 4 off:** | metric | on | off | delta | permutation p | |---|---|---|---|---| | fps | 36.07 | 35.17 | +0.90 (+2.57 %) | 0.048 | | mean frame | 27.74 ms | 28.44 ms | -0.71 ms (-2.48 %) | 0.056 | | median frame | 26.70 ms | 27.50 ms | -0.80 ms (-2.89 %) | 0.008 | | p99 frame | 52.6 ms | 53.6 ms | -2.0 % | within spread | | frames over 60 ms | 0.63 % | 0.64 % | none | within spread | Median ranges are separated (worst on-run 27.07 ms, best off-run 27.10 ms); fps ranges overlap. Run-to-run spread on this machine is 3-12 %, larger than the effect, so the medians are the firmer statement. p is an exact permutation test over run labels (all 126 splits of nine runs; 0.008 is the floor of that test). Phase medians, two paired samples (ms, on against off): `desc_ms` 2.81/2.78 against 3.18 (-11.6 %/-12.6 %), `programs_ms` 1.45/1.44 against 1.62 (-10.5 %/-11.1 %), `draw_ms` 10.13/9.94 against 10.76 (-5.9 %/-7.6 %), `cmds_ms` 4.37/4.24 against 4.45 (-1.8 %/-4.7 %), `game_ms` unchanged in one sample and -6.0 % in the other (noise). **100 % render (the Deck's default), 3 runs a side:** fps 31.34 against 30.67 (+2.21 %, p 0.15), median frame 31.12 against 31.34 ms (-0.22 ms, p 0.25). The host phases move the same way (`desc_ms` -7.5 to -10.4 %, `programs_ms` -8.9 to -12.1 %, `draw_ms` -2.9 to -6.8 %, render -1.8 to -2.7 %), but `gpu_wait_ms` rises by 0.91 to 1.01 ms (+36 to +42 %) in all three pairs, so at native resolution the host saving is largely spent waiting for the GPU. That is expected for a GPU-bound frame and is not a fault of the change. Limits: one scene, one save, one machine; Deck LCD only; the switches were moved together, so this table does not separate the three PRs from each other. Raw traces are on my Deck and archived locally, available on request. For this PR specifically: #2946's share of the gain is visible by subtraction. A build of #2932 + #2952 + #2958 (without #2946, the largest set that merges without editing anyone's code) gives `desc_ms` -5.1 to -8.5 % and `draw_ms` -2.6 to -5.2 % at 50 %, against `desc_ms` -11.6 to -12.6 % here. The mesh bank and UBO descriptor fast paths therefore carry a good half of the descriptor win, which is the largest single phase saving we measured on this hardware. One conflict note for the queue: #2946 does not merge cleanly on top of #2954 (`vk_internal.h`, `vk_progcache.cpp`, `vk_shader.cpp`) or #2958 (`vk_draw.cpp`). Those two merge with each other and with #2952's test file alone; #2946 and #2952 merge cleanly. If both families are wanted, one of them needs a rebase.
Member

One caveat to add to the table above, from a second pass over the same traces: the size of the effect depends on where the trace is windowed. Trimming to 30-97 % gives +2.6 % fps and -2.9 % median frame; 20-90 % gives +3.7 % and -2.8 %; 40-99 % gives +1.4 % and -2.0 %. The direction is the same in all three, and I did not choose a window after the fact, but treat 2-3 % as a range rather than a point.

Two further limits worth naming: the arms ran in blocks (switch set A, then B) rather than strictly alternating, so thermal or cache drift cannot be separated from the switch set with these runs; and with nine runs the smallest attainable permutation p is 0.008, which is exactly the median's value, so that figure is the floor of the test rather than a precise probability.

One caveat to add to the table above, from a second pass over the same traces: the size of the effect depends on where the trace is windowed. Trimming to 30-97 % gives +2.6 % fps and -2.9 % median frame; 20-90 % gives +3.7 % and -2.8 %; 40-99 % gives +1.4 % and -2.0 %. The direction is the same in all three, and I did not choose a window after the fact, but treat 2-3 % as a range rather than a point. Two further limits worth naming: the arms ran in blocks (switch set A, then B) rather than strictly alternating, so thermal or cache drift cannot be separated from the switch set with these runs; and with nine runs the smallest attainable permutation p is 0.008, which is exactly the median's value, so that figure is the floor of the test rather than a precise probability.
Author
Contributor

Thank you @omgitsgela for the thorough Steam Deck LCD (RADV) measurements (+2.57% FPS, -2.89% median frame, desc_ms -11.6%..-12.6%, programs_ms -10.5%..-11.1%) and the detailed breakdown across windowing choices and the GPU-bound 100% render case. We are ready to rebase cleanly onto whichever merge order maintainers choose with #2954 and #2958.

Thank you @omgitsgela for the thorough Steam Deck LCD (RADV) measurements (+2.57% FPS, -2.89% median frame, `desc_ms` -11.6%..-12.6%, `programs_ms` -10.5%..-11.1%) and the detailed breakdown across windowing choices and the GPU-bound 100% render case. We are ready to rebase cleanly onto whichever merge order maintainers choose with #2954 and #2958.
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 4s
This pull request has changes conflicting with the target branch.
  • gpu/vk/switches.def
  • gpu/vk/vk_draw.cpp
  • gpu/vk/vk_internal.h
  • gpu/vk/vk_shader.cpp
  • tests/loaded_modules_drop_test.cpp
  • tests/recording_admission_test.cpp
  • tests/sampler_admission_test.cpp
  • tests/test_hos_ab.py
Some workflows are waiting to be reviewed.
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-mesh-prog-bank-ubo:siantm-perf/vk-mesh-prog-bank-ubo'
git switch 'siantm-perf/vk-mesh-prog-bank-ubo'
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!2946
No description provided.