docs, tests: mesh shaders read the heaps from the root window; GPU fixture ms_root_heap (RT-MESH-HEAP-DOCS) #2809

Closed
ubiquitarianism wants to merge 3 commits from upstream-pr/2809 into main
ubiquitarianism commented 2026-12-01 00:31:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ubiquitarianism on 2026-12-01T00:31:55Z.


Claimed in the coordination issue as: RT-MESH-HEAP-DOCS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296419849)

What and why

docs/linux_proton.md lists mesh shaders reading the resource and sampler heaps as missing. Mesh draws already get both heap dwords through the mesh root window (s16 onward).

  • docs/linux_proton.md now says so.
  • tests/semantic/test_ms_root_window.py checks that a translated mesh program dereferences both heap pointers read from the window, in mesh and --mesh-compute modes.
  • runtime/test/shaders/ms_root_heap.asm: a hand-written mesh fixture that reads both heap dwords from the root window and writes them into a vertex attribute, registered in scripts/run_gpu_tests.py (push dwords 12 and 13 are mesh s20 and s21).

Draft until the GPU fixture has run. It was translated on the CPU with rdna2spirv.py --assembler python (mesh and --mesh-compute), so its llvm-mc encoding is unchecked, and it has not been run on a GPU: this machine has no Vulkan SDK, so vk_harness is not built. A run of python -I scripts/run_gpu_tests.py --filter ms_root_heap on any Vulkan GPU would settle it.

Not run in game.

Tested

Windows 11 (26200), rebased on main at 66b5d0433:

  • python -m unittest discover -s tests/semantic -p test_ms_root_window.py: OK
  • runtime RelWithDebInfo build; full ctest: 205 of 205 passed
  • scripts/check_no_game_data.py on the changed files: OK
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5576411309 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2809). Originally posted by [ubiquitarianism](https://github.com/ubiquitarianism) on 2026-12-01T00:31:55Z. --- Claimed in the coordination issue as: RT-MESH-HEAP-DOCS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296419849) ### What and why `docs/linux_proton.md` lists mesh shaders reading the resource and sampler heaps as missing. Mesh draws already get both heap dwords through the mesh root window (s16 onward). - `docs/linux_proton.md` now says so. - `tests/semantic/test_ms_root_window.py` checks that a translated mesh program dereferences both heap pointers read from the window, in mesh and `--mesh-compute` modes. - `runtime/test/shaders/ms_root_heap.asm`: a hand-written mesh fixture that reads both heap dwords from the root window and writes them into a vertex attribute, registered in `scripts/run_gpu_tests.py` (push dwords 12 and 13 are mesh s20 and s21). **Draft until the GPU fixture has run.** It was translated on the CPU with `rdna2spirv.py --assembler python` (mesh and `--mesh-compute`), so its llvm-mc encoding is unchecked, and it has not been run on a GPU: this machine has no Vulkan SDK, so `vk_harness` is not built. A run of `python -I scripts/run_gpu_tests.py --filter ms_root_heap` on any Vulkan GPU would settle it. Not run in game. ### Tested Windows 11 (26200), rebased on `main` at `66b5d0433`: - `python -m unittest discover -s tests/semantic -p test_ms_root_window.py`: OK - runtime RelWithDebInfo build; full `ctest`: 205 of 205 passed - `scripts/check_no_game_data.py` on the changed files: OK
fiestorra commented 2026-12-01 01:22:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T01:22:58Z.


Verified end to end on the GPU, not just statically: the new fixture translates, validates, and passes with every pixel exact.

main d920d850d plus this pull request, RTX 4090, driver 621.24:

python -I scripts/run_gpu_tests.py --build runtime/build --work <tmp> --filter ms_root_heap
  === rdna2spirv.py ===
  translate: 1/1 (100%)
  1 shaders: 1 translated, 1 pass spirv-val
  === GPU TEST RESULTS ===
    PASS  ms_root_heap          4096/4096 pixels exact
  1/1 passed

So the shader really does read its two dwords through the descriptor heaps after the root arguments, and the values come out as the fixture's comments say - 0x3f000000 (0.5) at 0x1004 and 0x3f800000 (1.0) at 0x2008, 4096 of 4096 pixels.

The semantic side, separately:

python -m pytest tests/semantic/test_ms_root_window.py -q
  5 passed, 16 subtests passed

A note on the control I tried and why it was the wrong one: I removed runtime/test/shaders/ms_root_heap.asm and the semantic tests still passed - correctly, because that file is not what they read: they build their shader inline. The fixture belongs to the GPU runner, and the right check for it is the run above, which I did instead of reporting a "control that does not bite" that was pointing at the wrong file.

And a static check that is worth having: the run line the .asm documents matches what run_gpu_tests.py sets. VKH_SGPRS="...,0,0x1000,0x2000" and VKH_HEAP="0x1004=0x3f000000,0x2008=0x3f800000" in both - the fixture's header is not stale, which is the usual way a new shader fixture rots.

AI-assisted: yes - DeepSeek v4.1 (flash), which ran the translator, spirv-val and the test on the machine above.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7297434258 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2809#issuecomment-7297434258). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-01T01:22:58Z. --- **Verified end to end on the GPU, not just statically: the new fixture translates, validates, and passes with every pixel exact.** **`main` `d920d850d` plus this pull request, RTX 4090, driver 621.24:** ``` python -I scripts/run_gpu_tests.py --build runtime/build --work <tmp> --filter ms_root_heap === rdna2spirv.py === translate: 1/1 (100%) 1 shaders: 1 translated, 1 pass spirv-val === GPU TEST RESULTS === PASS ms_root_heap 4096/4096 pixels exact 1/1 passed ``` **So the shader really does read its two dwords through the descriptor heaps after the root arguments, and the values come out as the fixture's comments say** - `0x3f000000` (0.5) at `0x1004` and `0x3f800000` (1.0) at `0x2008`, **4096 of 4096 pixels.** **The semantic side, separately:** ``` python -m pytest tests/semantic/test_ms_root_window.py -q 5 passed, 16 subtests passed ``` **A note on the control I tried and why it was the wrong one**: **I removed `runtime/test/shaders/ms_root_heap.asm` and the semantic tests still passed** - **correctly**, **because that file is not what they read**: **they build their shader inline.** **The fixture belongs to the GPU runner, and the right check for it is the run above, which I did instead of reporting a "control that does not bite" that was pointing at the wrong file.** **And a static check that is worth having**: **the run line the `.asm` documents matches what `run_gpu_tests.py` sets.** **`VKH_SGPRS="...,0,0x1000,0x2000"` and `VKH_HEAP="0x1004=0x3f000000,0x2008=0x3f800000"` in both** - **the fixture's header is not stale, which is the usual way a new shader fixture rots.** **AI-assisted:** yes - DeepSeek v4.1 (flash), which ran the translator, spirv-val and the test on the machine above. Written with an AI assistant.
KelboLive commented 2026-12-01 04:34:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T04:34:27Z.

Review: COMMENTED


The claim checks out against the code, not just the prose: graphics_user_data() appends the resource then sampler heap after graphics_arguments_end for every graphics draw, mesh included (runtime/shims/d3d12_com.cpp:2252, mesh draws at :2410 and :2591), the mesh stage reads that block through its 16-dword window (s16..s31 = push dwords 8..23, d3d12_com.h:672, mesh_root_window_ok at :2360), and runtime/test/d3d12_mesh_test.cpp:641-700 already asserts the mesh draw's dwords. Deleting "Mesh stages do not get the heap offset yet" is right.

The fixture runs here and it can fail: python -I scripts/run_gpu_tests.py --filter ms_root_heap gives PASS ms_root_heap 4096/4096 pixels exact on an RTX 4070 Ti SUPER (driver 621.01, VK_EXT_mesh_shader, native mesh path assembled by llvm-mc from the new .asm). Setting the sampler word to 0x3e800000 (0.25) instead of 1.0 makes pixel (0,0) read 0.25, which check_grad(raw, 0.5, 1.0) rejects, so both heap words are genuinely asserted — this is not a "dispatch completed" test.

Two things to change:

  1. Register the sample. tests/conftest.py:142 SAMPLE_DXBC has no "ms_root_heap": MS_TRI_DXBC, so test_gpu_samples_translate_and_validate[ms_root_heap.asm] and test_wave64_emulate_uses_no_subgroup_ops[ms_root_heap.asm] both skip; with the entry added they both pass here.
  2. Drop the stale note. The fixture header still says ; Not run yet: written without a GPU run. and the PR body repeats it; it has now been run. One line saying that VKH_SGPRS supplies push dwords 12/13 itself would also keep someone from citing this GPU test as proof of the runtime's placement — that half is the existing d3d12_mesh_test ctest.

Optional doc nuance: in the list of stops, "when they fit in s31" could add the case where only the resource heap fits (only it is written, write_direct_heaps bounds-checks slot < 32), since that is the one a reader will hit.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125155039 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2809#pullrequestreview-6125155039). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T04:34:27Z. **Review:** COMMENTED --- The claim checks out against the code, not just the prose: `graphics_user_data()` appends the resource then sampler heap after `graphics_arguments_end` for every graphics draw, mesh included (`runtime/shims/d3d12_com.cpp:2252`, mesh draws at `:2410` and `:2591`), the mesh stage reads that block through its 16-dword window (s16..s31 = push dwords 8..23, `d3d12_com.h:672`, `mesh_root_window_ok` at `:2360`), and `runtime/test/d3d12_mesh_test.cpp:641-700` already asserts the mesh draw's dwords. Deleting "Mesh stages do not get the heap offset yet" is right. The fixture runs here and it can fail: `python -I scripts/run_gpu_tests.py --filter ms_root_heap` gives `PASS ms_root_heap 4096/4096 pixels exact` on an RTX 4070 Ti SUPER (driver 621.01, `VK_EXT_mesh_shader`, native mesh path assembled by llvm-mc from the new `.asm`). Setting the sampler word to `0x3e800000` (0.25) instead of 1.0 makes pixel (0,0) read `0.25`, which `check_grad(raw, 0.5, 1.0)` rejects, so both heap words are genuinely asserted — this is not a "dispatch completed" test. Two things to change: 1. **Register the sample.** `tests/conftest.py:142` `SAMPLE_DXBC` has no `"ms_root_heap": MS_TRI_DXBC`, so `test_gpu_samples_translate_and_validate[ms_root_heap.asm]` and `test_wave64_emulate_uses_no_subgroup_ops[ms_root_heap.asm]` both **skip**; with the entry added they both pass here. 2. **Drop the stale note.** The fixture header still says `; Not run yet: written without a GPU run.` and the PR body repeats it; it has now been run. One line saying that `VKH_SGPRS` supplies push dwords 12/13 itself would also keep someone from citing this GPU test as proof of the runtime's placement — that half is the existing `d3d12_mesh_test` ctest. Optional doc nuance: in the list of stops, "when they fit in s31" could add the case where only the resource heap fits (only it is written, `write_direct_heaps` bounds-checks `slot < 32`), since that is the one a reader will hit.
merzleckeier commented 2026-12-01 12:18:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T12:18:08Z.


Independent Vulkan check of 5c34250d9 merged onto c60ce461a. The offline mesh runner assembled and validated the fixture and read back 4,096 of 4,096 expected pixels on both AMD Raphael (RADV 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.4), with wave64 emulation enabled. Changing only the test resource word to zero made NVIDIA fail at pixel (0,0), with the corresponding channel 0.0 instead of 0.5. This complements the sampler control above. The five interpreter tests also passed.

I reproduced the missing pytest registration noted above. Both parametrizations skipped on the PR head. Adding "ms_root_heap": MS_TRI_DXBC to SAMPLE_DXBC in tests/conftest.py made both pass. The GPU fixture supplies its synthetic heap arguments directly.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310937469 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2809#issuecomment-7310937469). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T12:18:08Z. --- Independent Vulkan check of `5c34250d9` merged onto `c60ce461a`. The offline mesh runner assembled and validated the fixture and read back 4,096 of 4,096 expected pixels on both AMD Raphael (RADV 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.4), with wave64 emulation enabled. Changing only the test resource word to zero made NVIDIA fail at pixel (0,0), with the corresponding channel 0.0 instead of 0.5. This complements the sampler control above. The five interpreter tests also passed. I reproduced the missing pytest registration noted above. Both parametrizations skipped on the PR head. Adding `"ms_root_heap": MS_TRI_DXBC` to `SAMPLE_DXBC` in `tests/conftest.py` made both pass. The GPU fixture supplies its synthetic heap arguments directly. AI-assisted with OpenAI Codex.
aslan2142 commented 2026-12-01 17:26:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:26:44Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319309393 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2809#issuecomment-7319309393). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:26:44Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2809
No description provided.