feat(vk): split the mesh fallback's cost with a record-export stub switch (#1477 BC-0) #1531

Open
omgitsgela wants to merge 8 commits from omgitsgela/Longshot:perf/1477-bc0-fb-export-split into main
Contributor

Type: feat · Risk: low · Tested on: Steam Deck LCD (VanGogh, RADV), desktop mode · Needs: none (the Deck arms are done; off unless a diag switch is set, a default run emits byte-identically)

TL;DR

We know the compute mesh fallback costs the Deck 6.8 ms a frame, but not how much of that is the game's own shader work versus the emulator's bookkeeping — and the answer decides which fix to build first. This PR adds a test-only switch that skips just the emulator's part (writing the vertex records) while the game's programs keep running, and measures the difference on the Deck: our share is about 1.5 ms, so the game's decode is the bigger half and the campaign re-ranks to attack it first. Both variants are compiled and validated through the real SPIR-V back end by the extended layout test.

Breakdown

  • Who it helps: anyone following the #1477 performance campaign; no player-visible change.
  • What was wrong: the fallback's 6.8 ms a frame could not be split into the game's decode versus our record-export traffic, so candidate priorities were guesses.
  • What changes: a diag switch, RX_VK_MESH_FB_NO_EXPORT=1, that leaves the record payload unwritten while validity words and the draw's counts stay — a frame-time difference that isolates our traffic.
  • What does not change: everything with the switch unset: defaults, native mesh, the generated vertex stage, saved games, the options file.
  • How it was checked: A B B A Deck runs on one build (switch off vs on), plus the extended layout test: 48 emitted modules spirv-val clean (was 36), the stub twin must compile, validate, and lose the payload loads.
  • What is still open: the campaign's next candidate (BC-2, specializing the hot decode programs) builds on this number; nothing here is unfinished.
  • Risk: low: dead code unless the switch is set; worst case is a measurement build that renders garbage, which the docs and the switch row both say.

Why

#1477 asks how much of the compute mesh fallback's cost is the game's work versus ours. The 6.8 ms a frame from the #2245 measurements cannot be spent until it is split: the guest mesh program's decode ALU, or our export traffic (shared-memory loads and the VRAM stores that hand records to the vertex stage). The split decides the order of attack — restructure our export (BC-1) or retarget the hot decode programs to native triangle pipelines (BC-2). See #1477; the ceiling and clock pairs that bound the same question from other sides are in its comments 46711 and 47445.

What changed

Both record writers fork at emit time on a new RuntimeInfo flag, set only from the env at translation: the stub path stores each record's validity word and returns, so allocation, dispatch, and the indirect draw stay real while the payload stops. Nothing else in the frame runs differently, and the switch's name is under the program cache stamp's RX_VK_MESH sweep, so a stubbed program is never read back by a run that did not ask for it.

  • gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_mesh.cpp — WriteFallbackLines (soa) and the inline aos loop in MeshFallbackEpilogue: the emit-time fork, one path per module.
  • gpu/vk/eden/shader_recompiler/runtime_info.h — mesh_fallback_no_export, documented with what it really measures (the slots hold whatever the records buffer last carried — reused across programs, header-only reset — so the picture is stale garbage and the delta folds in raster-side change; the fb spans read that back out).
  • gpu/vk/vk_shader.cpp — mesh_fb_no_export() read once; set at the task and mesh fallback sites only; the generated vertex stage deliberately never sees it, so its translation is identical in both arms.
  • gpu/vk/switches.def, docs/development.md — the switch's rows.
  • tests/mesh_fallback_layout_ir.cpp + tests/test_mesh_fallback_layout.py — every shape and layout also emits a noexport twin: it must compile, pass spirv-val (spv1.6 and vulkan1.3), and lose the payload export's shared-memory loads versus its full twin (store count alone cannot see it — one aos OpStore served both kinds). 48 modules validated, was 36. This test caught the OpIAdd arity bug a Deck build had just hit; that failure mode is local now.

Measurements

Verdict: the instrument works and answers the question — our export traffic is ~1.5 ms of the fallback's 6.8 ms; the game's decode (~5.3 ms) is the bulk, which re-ranks #1477 to BC-2 first.

Hardware: Steam Deck LCD, AMD Custom GPU 0405 (RADV VANGOGH), Mesa of that stack, Zen 2 4C/8T, 16 GB shared.
Scene: Hyrule Field (child save copy, slot 05), 1280x800 output, render resolution 4 (50%), shadows 1, quality preset, vsync off, no fps cap (HOS_FPS_MAX=1000).
Method: A B B A on ONE build (rt-rc6-bc0, this PR's tree): default, stub, default, stub; the scripted route (warm 1200 presents, walks, pans, full-stick turns, circle) twice per arm; medians of per-frame frame-times.csv; 10 Hz busy+sclk sampler; env confirmed per arm from the switches-set log line.
Baseline: both columns are this PR's build with the switch unset vs set — main is not the comparison because both arms must share one binary for the difference to isolate the switch.
How to reproduce: the Deck LCD, the copied Hyrule Field save, ~/longshot-investigation/mesh2245-arm3.sh route with RX_VK_MESH_SHADERS=compute, then RX_VK_MESH_FB_NO_EXPORT=1 for the stub arm; rows docs/tested/2026-11-17-bc0-export-stub-warm-omgitsgela-run15.md (with run14 ceiling and run16 clock pair bounding the same question).

Before: this PR @ c7f339a6, switch unset (e1/e3) After, RX_VK_MESH_FB_NO_EXPORT=1: this PR @ c7f339a6 (e2/e4)
steady warm median (2 runs each) 30.9 fps (32.4/32.3 ms) 32.5 fps (30.5/31.1 ms)
maneuver quarter median 23.7 fps 24.2
saved a frame — ~1.5 ms
busy / sclk in play 99% / 1300 MHz 99% / 1300 MHz
e1 default  warm med 32.4 ms = 30.9 fps | quarter 41.4 ms = 24.2 | busy 99 sclk 1300
e2 stub     warm med 30.5 ms = 32.8 fps | quarter 39.2 ms = 25.5
e3 default  warm med 32.3 ms = 30.9 fps | quarter 42.9 ms = 23.3
e4 stub     warm med 31.1 ms = 32.1 fps | quarter 43.4 ms = 23.0
#1477 comment 47400 posts the full table with the ceiling pair beside it

Flags and settings

This PR adds one switch, shipped off as written.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_MESH_FB_NO_EXPORT=1 diag: stub the fallback's record payload export did not exist exists, unset = no effect the picture becomes stale garbage; frame time isolates our export traffic helps: measurement builds for #1477; never in a normal run off: only for testing

Testing

Tested: Steam Deck LCD desktop mode, this exact build (rt-rc6-bc0, so=20578111): four full scripted route runs (A B B A), no crash, no amdgpu kernel lines, fallback draws still executing (frame times move exactly the export's share, and the stub arms' game log shows the programs running); switch effect confirmed per arm via the switches set log line. Game-free: tests/test_mesh_fallback_layout.py 62 cases 0 failed with 48 modules spirv-val clean including the stub twins (VM toolchain, NDK spirv-val); tests/test_mesh_fallback*.py, tests/test_switch_table.py (my row passes; the table's pre-existing main failures named below), stamp tests, and the full tests/run_all.py suite (this tree 602/37/126; every failure shared with a same-day clean-main run). A delegated review independently compiled the back end, validated both forks, and verified the cache-stamp isolation with line cites (#1477 comment 46725).

Not tested: Windows/other GPUs for the stub arms (it is a measurement switch; the emitted variants are validated tool-side for every fallback shape); no other titles measured with it yet.

Must be tested: Windows, llvm-mingw cross-compile (I have no Windows toolchain on this host): the build-windows.yml job on this PR (by hand: read the check on the PR page), expecting the Windows build green for this branch's emit_spirv_mesh.cpp, runtime_info.h and vk_shader.cpp, since all three compile on Windows too. Nothing else: the default path is unchanged by construction (byte-identical emit, reviewer-verified), and the Deck ran the switch both ways.

Risks

What could break: nothing for a normal run — the forks are only emitted when the flag is set at translation, the vertex stage never sees it, and the cache stamp keeps stubbed programs out of unstubbed runs. Worst realistic case: someone sets the switch in a normal run and sees garbage; the switch row, the docs row and the log line all say it is a measurement build.

Turning it off: unset the variable (it is never on by default; the program cache re-keys automatically).

Compatibility: Nothing changes for a player: no save, ini, ABI or tool change; the new switch's name is hashed into the program-cache stamp only when set, so caches behave exactly as with any RX_VK_MESH* switch.

Issues

See #1477 (this is BC-0 of the campaign plan; results posted there as comments 46711, 46725, 47400, 47445).

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.
  • 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.
  • 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 on the merged head (main @ 9af4808f merged in): 606 passed / 36 failed / 126 skipped — all 36 also fail on that main itself (run individually at 9af4808f: exit 1; none caused by this PR; listed here: bug_report_defaults, cpu_report, crt_options, damage_debug_menu, dev_packs, discover, display_startup_failure, dlss_feature_size, failed_compile_keeps_objects, guest_imported, hud_layout_row, invalidate_quick, invalidate_vcore, libc_hooks, lift_lookups, link_skip, linux_pressure, linux_update, log_open_failure, mirror_budget, missing_nup, mods_size_table, pending_guest_import, pipeline_play_cache, present_thread, profiling_mode, psychov35_fsr3_fg, readback_timeout_source, run_all_changed, slow_frames, switch_table, target_image_pool, upscaler_rows, vcore_escape, walk, walk_key). Before the merge: this branch @ 920899c2 was 602/37/126 against main @ 347aa6e8's 599/40/126, same story.
  • 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.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths — the touched files compile in the Vulkan back end on both; no path handling changes (name verification: the release Windows job builds these files; see Must be tested).
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Docs updated.
**Type:** feat · **Risk:** low · **Tested on:** Steam Deck LCD (VanGogh, RADV), desktop mode · **Needs:** none (the Deck arms are done; off unless a diag switch is set, a default run emits byte-identically) ## TL;DR We know the compute mesh fallback costs the Deck 6.8 ms a frame, but not how much of that is the game's own shader work versus the emulator's bookkeeping — and the answer decides which fix to build first. This PR adds a test-only switch that skips just the emulator's part (writing the vertex records) while the game's programs keep running, and measures the difference on the Deck: our share is about 1.5 ms, so the game's decode is the bigger half and the campaign re-ranks to attack it first. Both variants are compiled and validated through the real SPIR-V back end by the extended layout test. ## Breakdown - **Who it helps:** anyone following the #1477 performance campaign; no player-visible change. - **What was wrong:** the fallback's 6.8 ms a frame could not be split into the game's decode versus our record-export traffic, so candidate priorities were guesses. - **What changes:** a diag switch, `RX_VK_MESH_FB_NO_EXPORT=1`, that leaves the record payload unwritten while validity words and the draw's counts stay — a frame-time difference that isolates our traffic. - **What does not change:** everything with the switch unset: defaults, native mesh, the generated vertex stage, saved games, the options file. - **How it was checked:** A B B A Deck runs on one build (switch off vs on), plus the extended layout test: 48 emitted modules spirv-val clean (was 36), the stub twin must compile, validate, and lose the payload loads. - **What is still open:** the campaign's next candidate (BC-2, specializing the hot decode programs) builds on this number; nothing here is unfinished. - **Risk:** low: dead code unless the switch is set; worst case is a measurement build that renders garbage, which the docs and the switch row both say. ## Why #1477 asks how much of the compute mesh fallback's cost is the *game's* work versus *ours*. The 6.8 ms a frame from the #2245 measurements cannot be spent until it is split: the guest mesh program's decode ALU, or our export traffic (shared-memory loads and the VRAM stores that hand records to the vertex stage). The split decides the order of attack — restructure our export (BC-1) or retarget the hot decode programs to native triangle pipelines (BC-2). See #1477; the ceiling and clock pairs that bound the same question from other sides are in its comments 46711 and 47445. ## What changed Both record writers fork at emit time on a new `RuntimeInfo` flag, set only from the env at translation: the stub path stores each record's validity word and returns, so allocation, dispatch, and the indirect draw stay real while the payload stops. Nothing else in the frame runs differently, and the switch's name is under the program cache stamp's `RX_VK_MESH` sweep, so a stubbed program is never read back by a run that did not ask for it. - `gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_mesh.cpp` — `WriteFallbackLines` (soa) and the inline aos loop in `MeshFallbackEpilogue`: the emit-time fork, one path per module. - `gpu/vk/eden/shader_recompiler/runtime_info.h` — `mesh_fallback_no_export`, documented with what it really measures (the slots hold whatever the records buffer last carried — reused across programs, header-only reset — so the picture is stale garbage and the delta folds in raster-side change; the fb spans read that back out). - `gpu/vk/vk_shader.cpp` — `mesh_fb_no_export()` read once; set at the task and mesh fallback sites only; the generated vertex stage deliberately never sees it, so its translation is identical in both arms. - `gpu/vk/switches.def`, `docs/development.md` — the switch's rows. - `tests/mesh_fallback_layout_ir.cpp` + `tests/test_mesh_fallback_layout.py` — every shape and layout also emits a `noexport` twin: it must compile, pass spirv-val (spv1.6 and vulkan1.3), and lose the payload export's shared-memory loads versus its full twin (store count alone cannot see it — one aos `OpStore` served both kinds). 48 modules validated, was 36. This test caught the `OpIAdd` arity bug a Deck build had just hit; that failure mode is local now. ## Measurements **Verdict: the instrument works and answers the question — our export traffic is ~1.5 ms of the fallback's 6.8 ms; the game's decode (~5.3 ms) is the bulk, which re-ranks #1477 to BC-2 first.** Hardware: Steam Deck LCD, AMD Custom GPU 0405 (RADV VANGOGH), Mesa of that stack, Zen 2 4C/8T, 16 GB shared. Scene: Hyrule Field (child save copy, slot 05), 1280x800 output, render resolution 4 (50%), shadows 1, quality preset, vsync off, no fps cap (`HOS_FPS_MAX=1000`). Method: A B B A on ONE build (`rt-rc6-bc0`, this PR's tree): default, stub, default, stub; the scripted route (warm 1200 presents, walks, pans, full-stick turns, circle) twice per arm; medians of per-frame `frame-times.csv`; 10 Hz busy+sclk sampler; env confirmed per arm from the switches-set log line. Baseline: both columns are this PR's build with the switch unset vs set — main is not the comparison because both arms must share one binary for the difference to isolate the switch. How to reproduce: the Deck LCD, the copied Hyrule Field save, `~/longshot-investigation/mesh2245-arm3.sh` route with `RX_VK_MESH_SHADERS=compute`, then `RX_VK_MESH_FB_NO_EXPORT=1` for the stub arm; rows `docs/tested/2026-11-17-bc0-export-stub-warm-omgitsgela-run15.md` (with run14 ceiling and run16 clock pair bounding the same question). | | Before: this PR @ c7f339a6, switch unset (e1/e3) | After, RX_VK_MESH_FB_NO_EXPORT=1: this PR @ c7f339a6 (e2/e4) | |---|---|---| | steady warm median (2 runs each) | 30.9 fps (32.4/32.3 ms) | 32.5 fps (30.5/31.1 ms) | | maneuver quarter median | 23.7 fps | 24.2 | | saved a frame | — | **~1.5 ms** | | busy / sclk in play | 99% / 1300 MHz | 99% / 1300 MHz | ``` e1 default warm med 32.4 ms = 30.9 fps | quarter 41.4 ms = 24.2 | busy 99 sclk 1300 e2 stub warm med 30.5 ms = 32.8 fps | quarter 39.2 ms = 25.5 e3 default warm med 32.3 ms = 30.9 fps | quarter 42.9 ms = 23.3 e4 stub warm med 31.1 ms = 32.1 fps | quarter 43.4 ms = 23.0 #1477 comment 47400 posts the full table with the ceiling pair beside it ``` ### Flags and settings This PR adds one switch, shipped off as written. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_MESH_FB_NO_EXPORT=1` | diag: stub the fallback's record payload export | did not exist | exists, unset = no effect | the picture becomes stale garbage; frame time isolates our export traffic | helps: measurement builds for #1477; never in a normal run | off: only for testing | ## Testing **Tested:** Steam Deck LCD desktop mode, this exact build (`rt-rc6-bc0`, so=20578111): four full scripted route runs (A B B A), no crash, no amdgpu kernel lines, fallback draws still executing (frame times move exactly the export's share, and the stub arms' game log shows the programs running); switch effect confirmed per arm via the `switches set` log line. Game-free: `tests/test_mesh_fallback_layout.py` 62 cases 0 failed with 48 modules spirv-val clean including the stub twins (VM toolchain, NDK spirv-val); `tests/test_mesh_fallback*.py`, `tests/test_switch_table.py` (my row passes; the table's pre-existing main failures named below), stamp tests, and the full `tests/run_all.py` suite (this tree 602/37/126; every failure shared with a same-day clean-main run). A delegated review independently compiled the back end, validated both forks, and verified the cache-stamp isolation with line cites (#1477 comment 46725). **Not tested:** Windows/other GPUs for the stub arms (it is a measurement switch; the emitted variants are validated tool-side for every fallback shape); no other titles measured with it yet. **Must be tested:** Windows, llvm-mingw cross-compile (I have no Windows toolchain on this host): the `build-windows.yml` job on this PR (by hand: read the check on the PR page), expecting the Windows build green for this branch's `emit_spirv_mesh.cpp`, `runtime_info.h` and `vk_shader.cpp`, since all three compile on Windows too. Nothing else: the default path is unchanged by construction (byte-identical emit, reviewer-verified), and the Deck ran the switch both ways. ## Risks **What could break:** nothing for a normal run — the forks are only emitted when the flag is set at translation, the vertex stage never sees it, and the cache stamp keeps stubbed programs out of unstubbed runs. Worst realistic case: someone sets the switch in a normal run and sees garbage; the switch row, the docs row and the log line all say it is a measurement build. **Turning it off:** unset the variable (it is never on by default; the program cache re-keys automatically). **Compatibility:** Nothing changes for a player: no save, ini, ABI or tool change; the new switch's name is hashed into the program-cache stamp only when set, so caches behave exactly as with any `RX_VK_MESH*` switch. ## Issues See #1477 (this is BC-0 of the campaign plan; results posted there as comments 46711, 46725, 47400, 47445). ## 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). - [x] 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. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [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` on the merged head (main @ 9af4808f merged in): 606 passed / 36 failed / 126 skipped — **all 36 also fail on that main itself** (run individually at 9af4808f: exit 1; none caused by this PR; listed here: bug_report_defaults, cpu_report, crt_options, damage_debug_menu, dev_packs, discover, display_startup_failure, dlss_feature_size, failed_compile_keeps_objects, guest_imported, hud_layout_row, invalidate_quick, invalidate_vcore, libc_hooks, lift_lookups, link_skip, linux_pressure, linux_update, log_open_failure, mirror_budget, missing_nup, mods_size_table, pending_guest_import, pipeline_play_cache, present_thread, profiling_mode, psychov35_fsr3_fg, readback_timeout_source, run_all_changed, slow_frames, switch_table, target_image_pool, upscaler_rows, vcore_escape, walk, walk_key). Before the merge: this branch @ 920899c2 was 602/37/126 against main @ 347aa6e8's 599/40/126, same story. - [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] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths — the touched files compile in the Vulkan back end on both; no path handling changes (name verification: the release Windows job builds these files; see Must be tested). - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Docs updated.
RX_VK_MESH_FB_NO_EXPORT=1 leaves the fallback records' attribute lines unwritten while their validity words and the draw's counts stay: the picture runs one frame stale, and the difference between arms splits the game's decode work from the emulator's record-export traffic. An emit-time fork, so only one path exists in the module, and the switch name sits under the program cache stamp's RX_VK_MESH sweep so a stubbed module is never read back by a run that did not ask for it.

Measurement builds only, diag kind, never on for a player.

Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
The Deck's build caught what no VM test could see at the time: OpIAdd needs its result type, and the two adds the stub fork moved lost it. Fixed, and the layout IR test now emits a noexport twin for every shape and layout (48 modules validated, was 36): the twin must compile, pass spirv-val, and lose the payload export's shared-memory loads. A BC-0 compile error is now a local test failure before a Deck build ever sees it.

Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
The reviewer was right that one frame stale overpromises: the records buffer is shared across programs and only its header is reset, so with export off from startup the payload is never seeded by this path at all. The arms' delta folds in whatever the stale positions do in the raster, which the fb spans read back out alongside.

Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
docs: the record-export stub switch's row (#1477 BC-0)
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
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
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
920899c237
Assisted-by: Hermes
Co-Authored-By: Hermes <[email protected]>
Author
Contributor

Tested in game: Steam Deck LCD (VanGogh, RADV, Mesa 26.1.2), desktop mode, this exact build (rt-rc6-bc0, so=20578111): the scripted Hyrule Field route run four times A B B A (default, stub, default, stub). Defaults: normal play, unchanged (steady pair median 30.9 fps, matching the pre-PR arms). Stub switch set: the programs still run and frames move by the export's ~1.5 ms; the picture is stale garbage exactly as documented; no crash, no amdgpu kernel lines, no hang.

Tested in game: Steam Deck LCD (VanGogh, RADV, Mesa 26.1.2), desktop mode, this exact build (rt-rc6-bc0, so=20578111): the scripted Hyrule Field route run four times A B B A (default, stub, default, stub). Defaults: normal play, unchanged (steady pair median 30.9 fps, matching the pre-PR arms). Stub switch set: the programs still run and frames move by the export's ~1.5 ms; the picture is stale garbage exactly as documented; no crash, no amdgpu kernel lines, no hang.
Merge main into perf/1477-bc0-fb-export-split (#1531 current with main; no conflicts)
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
1ec4bac6f6
omgitsgela changed title from WIP: feat(vk): split the mesh fallback's cost with a record-export stub switch (#1477 BC-0) to feat(vk): split the mesh fallback's cost with a record-export stub switch (#1477 BC-0) 2026-11-18 02:59:54 +00:00
Contributor

Read for a Steam Deck OLED run of this (head 1ec4bac6f, built as main @ 9af4808f plus exactly this PR; only longshot_vk.so differs from that main; the PR's test_mesh_fallback_layout.py gives 62 cases, 48 modules spirv-val clean here too, and the 8 failures of the changed set all fail on that main). The arms are queued behind tonight's runs; three things from reading it that may be useful before then.

  1. A possible over-count in what the stub measures. With RX_VK_MESH_FB_NO_EXPORT=1 the export's loads of the workgroup attributes are gone, so the guest's stores into that workgroup memory become write-only. If ACO then drops those stores, and with them the guest arithmetic that only fed them, the stub removes part of the game's decode as well, and the "export" share (about 1.5 of 6.8 ms) would be too large and the decode share (about 5.3) too small. The layout test pins that the loads are gone in the SPIR-V; nothing pins what the driver keeps after that. One way to settle it without a GPU timer: compare the two arms' compiled sizes for the hot programs (RADV_DEBUG=shaderstats, or the instruction counts from the driver's shader dump) for 739acd678ae08655 and d905f52b7517c681. If the stub arm's code shrinks by much more than the export's own loads and stores, decode went with it. A stub that keeps the loads and drops only the record stores (or writes the loaded values to one dummy word) would bound it from the other side. I will run the shaderstats comparison on the OLED with the arms.

  2. The keyed fb mesh prog <key> rows are not in this PR. They come from #1460's measurement commit (46973fff6), which neither this branch nor main carries, and the "fb span rows:" canary line is in neither tree. So a tester building main plus this PR gets frame-time deltas only, which fold in the raster and fragment change of the stale draws, as your own wording says. For the compute-only number I built a second renderer with 46973fff6 on top (it applies clean and touches only vk_draw.cpp, so it shares this PR's caches); its numbers will be labelled as that, not as this PR's. It may be worth carrying that commit here, or landing it first, so the instrument and the spans that read it travel together.

  3. Cost to testers and players, for the description: every RX_VK_MESH* entry is hashed into the translator stamp, so default and =1 are two stamps and each arm needs its own shader preparation on a Deck (tens of minutes cold); and the PR changes stamped files, so every player's caches retranslate once after it lands even with the switch unset. Neither is a defect; both are worth a line.

Nothing in the diff looks able to harm a Deck beyond wrong pictures while the switch is on: reads stay clamped inside the records, no buffer changes size, and it is never a default.

Read for a Steam Deck OLED run of this (head `1ec4bac6f`, built as main @ 9af4808f plus exactly this PR; only `longshot_vk.so` differs from that main; the PR's `test_mesh_fallback_layout.py` gives 62 cases, 48 modules `spirv-val` clean here too, and the 8 failures of the changed set all fail on that main). The arms are queued behind tonight's runs; three things from reading it that may be useful before then. 1. **A possible over-count in what the stub measures.** With `RX_VK_MESH_FB_NO_EXPORT=1` the export's loads of the workgroup attributes are gone, so the guest's stores into that workgroup memory become write-only. If ACO then drops those stores, and with them the guest arithmetic that only fed them, the stub removes part of the game's *decode* as well, and the "export" share (about 1.5 of 6.8 ms) would be too large and the decode share (about 5.3) too small. The layout test pins that the loads are gone in the SPIR-V; nothing pins what the driver keeps after that. One way to settle it without a GPU timer: compare the two arms' compiled sizes for the hot programs (`RADV_DEBUG=shaderstats`, or the instruction counts from the driver's shader dump) for `739acd678ae08655` and `d905f52b7517c681`. If the stub arm's code shrinks by much more than the export's own loads and stores, decode went with it. A stub that keeps the loads and drops only the record stores (or writes the loaded values to one dummy word) would bound it from the other side. I will run the shaderstats comparison on the OLED with the arms. 2. **The keyed `fb mesh prog <key>` rows are not in this PR.** They come from https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1460's measurement commit (`46973fff6`), which neither this branch nor main carries, and the "`fb span rows:`" canary line is in neither tree. So a tester building main plus this PR gets frame-time deltas only, which fold in the raster and fragment change of the stale draws, as your own wording says. For the compute-only number I built a second renderer with `46973fff6` on top (it applies clean and touches only `vk_draw.cpp`, so it shares this PR's caches); its numbers will be labelled as that, not as this PR's. It may be worth carrying that commit here, or landing it first, so the instrument and the spans that read it travel together. 3. **Cost to testers and players, for the description:** every `RX_VK_MESH*` entry is hashed into the translator stamp, so default and `=1` are two stamps and each arm needs its own shader preparation on a Deck (tens of minutes cold); and the PR changes stamped files, so every player's caches retranslate once after it lands even with the switch unset. Neither is a defect; both are worth a line. Nothing in the diff looks able to harm a Deck beyond wrong pictures while the switch is on: reads stay clamped inside the records, no buffer changes size, and it is never a default.
Contributor

The check from point 1 above, run on a Steam Deck OLED (RADV, Mesa 26.2.0-devel): no sign that the driver drops the guest decode in the stub arm. The stub removes memory traffic, not computation, so the export share is not inflated that way.

Method: main @ 9af4808f plus exactly this PR, both arms prepared cold with RADV_DEBUG=shaderstats (default first; the stub arm seeded from the default arm's driver cache, so it compiled only the 1,039 compute pipelines the switch changes, and its statistics are exactly the stubbed fallback programs). The statistics carry no program key, so the two largest twins were paired by shape (8 KB of LDS, 256 VGPRs, about 2,040 branches each, far above every other compute shader): most likely 739acd678ae08655 and d905f52b7517c681, but that pairing is inferred, not keyed.

Stub against default, for those two programs:

ACO statistic change
instructions, code size −0.6% / −0.8% (−672 / −952 instructions)
VALU −0.4% / −0.7%
SALU −0.1%
branches unchanged
LDS, VGPRs unchanged (256 VGPRs kept); spilled VGPRs −115 of about 7,140; scratch −4 KB
VMEM −59% (−4,370); VMEM clauses −65%

Had the decode gone with the loads, VALU, SALU and branches would have fallen by thousands; they did not. What goes is memory instructions, more than the export's own loads and stores account for, which reads as spill and clause traffic around the export relieved when its live values are gone. So the stub's number includes that register-pressure relief as well as the record traffic itself: still "what the export costs the program", but a restructured export (as in #1561) keeps those values live and may recover less than the stub suggests, which fits packed4's roughly 1 ms against the stub's 1.5.

Limits: these are static counts from the compiler, which cannot say how often any instruction runs; the keyed fb mesh prog spans (default against stub, on the renderer with the span commit) remain the number to quote, and are queued here behind the packed-layout arms. Both preparations completed and both arms start; no timed arm has run yet.

The check from point 1 above, run on a Steam Deck OLED (RADV, Mesa 26.2.0-devel): **no sign that the driver drops the guest decode in the stub arm. The stub removes memory traffic, not computation, so the export share is not inflated that way.** Method: main @ 9af4808f plus exactly this PR, both arms prepared cold with `RADV_DEBUG=shaderstats` (default first; the stub arm seeded from the default arm's driver cache, so it compiled only the 1,039 compute pipelines the switch changes, and its statistics are exactly the stubbed fallback programs). The statistics carry no program key, so the two largest twins were paired by shape (8 KB of LDS, 256 VGPRs, about 2,040 branches each, far above every other compute shader): most likely `739acd678ae08655` and `d905f52b7517c681`, but that pairing is **inferred, not keyed**. Stub against default, for those two programs: | ACO statistic | change | |---|---| | instructions, code size | −0.6% / −0.8% (−672 / −952 instructions) | | VALU | −0.4% / −0.7% | | SALU | −0.1% | | branches | unchanged | | LDS, VGPRs | unchanged (256 VGPRs kept); spilled VGPRs −115 of about 7,140; scratch −4 KB | | VMEM | **−59%** (−4,370); VMEM clauses −65% | Had the decode gone with the loads, VALU, SALU and branches would have fallen by thousands; they did not. What goes is memory instructions, more than the export's own loads and stores account for, which reads as spill and clause traffic around the export relieved when its live values are gone. So the stub's number includes that register-pressure relief as well as the record traffic itself: still "what the export costs the program", but a restructured export (as in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1561) keeps those values live and may recover less than the stub suggests, which fits packed4's roughly 1 ms against the stub's 1.5. Limits: these are static counts from the compiler, which cannot say how often any instruction runs; the keyed `fb mesh prog` spans (default against stub, on the renderer with the span commit) remain the number to quote, and are queued here behind the packed-layout arms. Both preparations completed and both arms start; no timed arm has run yet.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
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 'perf/1477-bc0-fb-export-split:omgitsgela-perf/1477-bc0-fb-export-split'
git switch 'omgitsgela-perf/1477-bc0-fb-export-split'
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!1531
No description provided.