rdna2spirv: use OpAtomicStore for MSG_GS_ALLOC_REQ %ms_counts (SHADER-766) #94

Closed
github-bot wants to merge 1 commit from github-bot/gh-94 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:16 UTC · original
ubiquitarianism:old-pr/9826 → main · +13 −38 · 2 files · 1 commits · closed without merging

Carried over from old PR 9826 by lordon1a in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9826, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
This branch conflicts with the current main and needs a rebase.
lordon1a: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116641828

What and why

On main@2d53a8055, s_sendmsg(MSG_GS_ALLOC_REQ) in tools/rdna2spirv.py gates OpStore %ms_counts on local_index == 0. When a non-zero wave sends the allocation — as in runtime/test/shaders/ms_wave_info_s3.asm, where wave 0 skips MSG_GS_ALLOC_REQ and wave 1 (local_index 64..127) executes it — %ms_counts is never written, causing ms_wave_info_s3 to render nothing ((-1, -1, -1, -1) clear color) on both native VK_EXT_mesh_shader and LEONIDA_MESH_COMPUTE=1.

Replaces the local_index == 0 guard + plain OpStore with OpAtomicStore %ms_counts %c2 %c0 %m (Workgroup scope, Relaxed semantics), followed by the shader's existing workgroup barrier, and updates tests/test_mesh_alloc_single_writer.py. (Re-opening cleanly on main@2d53a8055 after earlier SHADER-766 PRs #5741 / #5855 were closed in the reset; credit to their authors for the root-cause analysis.)

Verification (Windows 11 Home 26H2, MSYS2 clang64 LLVM 23.1.5 / SPIRV-Tools v2026.4, no game files)

  • Unit test: python -I tests/test_mesh_alloc_single_writer.py -v -> OK.
  • NVIDIA GeForce RTX 3070 Ti Laptop GPU (10de:24e0, driver 616.64, Vulkan 1.4.351):
    • Before fix (main): ms_wave_info_s3 FAIL (got (-1,-1,-1,-1)).
    • After fix (native VK_EXT_mesh_shader, --filter ms_): 5/6 passed, 1 skipped (ms_wave_info_s3: 4096/4096 pixels exact).
    • After fix (LEONIDA_W64_EMULATE=1, --filter ms_): 6/6 passed (ms_wave_info_s3: 4096/4096 pixels exact).
  • Intel(R) Iris(R) Xe Graphics (8086:46a6, driver 32.0.101.7088, Vulkan 1.4.323):
    • Before fix (main, LEONIDA_MESH_COMPUTE=1 + LEONIDA_W64_EMULATE=1): ms_wave_info_s3 FAIL (got (-1,-1,-1,-1)).
    • After fix (LEONIDA_MESH_COMPUTE=1 + LEONIDA_W64_EMULATE=1, --filter ms_): 6/6 passed (ms_wave_info_s3: 4096/4096 pixels exact).
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_mesh_alloc_single_writer.py: clean (rc=0).
  • git diff --check: clean (rc=0).

AI-assisted.

**@⁠Andretuta** on GitHub · 2026-11-24 02:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/94) `ubiquitarianism:old-pr/9826` → `main` · +13 −38 · 2 files · 1 commits · closed without merging > Carried over from **old PR 9826** by `lordon1a` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9826`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > This branch conflicts with the current `main` and needs a rebase. > `lordon1a`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116641828 ### What and why On `main@2d53a8055`, `s_sendmsg(MSG_GS_ALLOC_REQ)` in `tools/rdna2spirv.py` gates `OpStore %ms_counts` on `local_index == 0`. When a non-zero wave sends the allocation — as in `runtime/test/shaders/ms_wave_info_s3.asm`, where wave 0 skips `MSG_GS_ALLOC_REQ` and wave 1 (`local_index` 64..127) executes it — `%ms_counts` is never written, causing `ms_wave_info_s3` to render nothing (`(-1, -1, -1, -1)` clear color) on both native `VK_EXT_mesh_shader` and `LEONIDA_MESH_COMPUTE=1`. Replaces the `local_index == 0` guard + plain `OpStore` with `OpAtomicStore %ms_counts %c2 %c0 %m` (Workgroup scope, Relaxed semantics), followed by the shader's existing workgroup barrier, and updates `tests/test_mesh_alloc_single_writer.py`. (Re-opening cleanly on `main@2d53a8055` after earlier SHADER-766 PRs `#5741` / `#5855` were closed in the reset; credit to their authors for the root-cause analysis.) ### Verification (Windows 11 Home 26H2, MSYS2 clang64 LLVM 23.1.5 / SPIRV-Tools v2026.4, no game files) - Unit test: `python -I tests/test_mesh_alloc_single_writer.py -v` -> **OK**. - **NVIDIA GeForce RTX 3070 Ti Laptop GPU** (`10de:24e0`, driver `616.64`, Vulkan `1.4.351`): - Before fix (`main`): `ms_wave_info_s3` **FAIL** (`got (-1,-1,-1,-1)`). - After fix (native `VK_EXT_mesh_shader`, `--filter ms_`): **5/6 passed, 1 skipped** (`ms_wave_info_s3`: `4096/4096 pixels exact`). - After fix (`LEONIDA_W64_EMULATE=1`, `--filter ms_`): **6/6 passed** (`ms_wave_info_s3`: `4096/4096 pixels exact`). - **Intel(R) Iris(R) Xe Graphics** (`8086:46a6`, driver `32.0.101.7088`, Vulkan `1.4.323`): - Before fix (`main`, `LEONIDA_MESH_COMPUTE=1 + LEONIDA_W64_EMULATE=1`): `ms_wave_info_s3` **FAIL** (`got (-1,-1,-1,-1)`). - After fix (`LEONIDA_MESH_COMPUTE=1 + LEONIDA_W64_EMULATE=1`, `--filter ms_`): **6/6 passed** (`ms_wave_info_s3`: `4096/4096 pixels exact`). - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_mesh_alloc_single_writer.py`: clean (`rc=0`). - `git diff --check`: clean (`rc=0`). AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:44:11 +00:00
Author
Owner

@⁠sodove on GitHub · 2026-11-24 06:20 UTC · original

The shader fix proposed here is already on current main at 0b589ea. At main 8f481cf, MSG_GS_ALLOC_REQ emits the same Workgroup-scope relaxed OpAtomicStore to ms_counts without a local-invocation-zero gate. I ran tests/test_mesh_alloc_single_writer.py on Windows 11 with Python 3.12. It passed for both native mesh and compute lowering.

The implementation and regression coverage are already present, so this archived draft can be closed. AI-assisted source verification.

**@⁠sodove** on GitHub · 2026-11-24 06:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7123836259) The shader fix proposed here is already on current main at [0b589ea](https://github.com/ubiquitarianism/leonida/commit/0b589ea999bde037c6c9a6f8aaa272a906216334). At main 8f481cf, MSG_GS_ALLOC_REQ emits the same Workgroup-scope relaxed OpAtomicStore to ms_counts without a local-invocation-zero gate. I ran tests/test_mesh_alloc_single_writer.py on Windows 11 with Python 3.12. It passed for both native mesh and compute lowering. The implementation and regression coverage are already present, so this archived draft can be closed. AI-assisted source verification.
Author
Owner

@⁠Len1k on GitHub · 2026-11-24 09:05 UTC · original

Ran this pull request's own test, then put tools/rdna2spirv.py back to the branch's base version (9ec34cdff) and ran it again — green both times, so the test does not pin the change.

baseline (head sources, head tests)   tests/test_mesh_alloc_single_writer.py  rc=0  OK   (1 test)
swapped tools/rdna2spirv.py to its base version
mutation (base sources, head tests)   tests/test_mesh_alloc_single_writer.py  rc=0  OK   (1 test)

This is not "already merged": head is 1,122,971 B, base is 1,132,746 B, current main is 1,134,932 B — three different files. The OpAtomicStore change is real and present; the test passes whichever atomic the translator emits for MSG_GS_ALLOC_REQ %ms_counts.

A test that would guard it: take the translated SPIR-V for a mesh shader that allocates through %ms_counts and assert the atomic opcode and its memory scope, so the base tool's output fails the assertion. As it stands the single case asserts something both versions satisfy.

The change itself may be perfectly correct — I only measure whether the test would notice if it were gone.

AI-assisted. Standard library only, no game files, no GPU.

**@⁠Len1k** on GitHub · 2026-11-24 09:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7126941792) Ran this pull request's own test, then put `tools/rdna2spirv.py` back to the branch's base version (`9ec34cdff`) and ran it again — **green both times**, so the test does not pin the change. ``` baseline (head sources, head tests) tests/test_mesh_alloc_single_writer.py rc=0 OK (1 test) swapped tools/rdna2spirv.py to its base version mutation (base sources, head tests) tests/test_mesh_alloc_single_writer.py rc=0 OK (1 test) ``` This is not "already merged": head is 1,122,971 B, base is 1,132,746 B, current `main` is 1,134,932 B — three different files. The `OpAtomicStore` change is real and present; the test passes whichever atomic the translator emits for `MSG_GS_ALLOC_REQ %ms_counts`. A test that would guard it: take the translated SPIR-V for a mesh shader that allocates through `%ms_counts` and assert the atomic opcode and its memory scope, so the base tool's output fails the assertion. As it stands the single case asserts something both versions satisfy. The change itself may be perfectly correct — I only measure whether the test would notice if it were gone. *AI-assisted.* Standard library only, no game files, no GPU.
Author
Owner

@⁠thesubtleties on GitHub · 2026-11-24 16:18 UTC · original

The change is already on main (1504c1af6). ms_wave_info_s3 there: 20/20 on RTX 3080 native, 3080 emulated, and gfx1036 RADV. With the old local_index == 0 guard restored: 0/20, 0/20, 20/20. I think this can be closed. No game files. AI-assisted (Claude Code).

**@⁠thesubtleties** on GitHub · 2026-11-24 16:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7137440878) The change is already on `main` (`1504c1af6`). `ms_wave_info_s3` there: 20/20 on RTX 3080 native, 3080 emulated, and gfx1036 RADV. With the old `local_index == 0` guard restored: 0/20, 0/20, 20/20. I think this can be closed. No game files. AI-assisted (Claude Code).
github-bot closed this pull request 2026-11-27 04:04:21 +00:00
Author
Owner

@⁠Andretuta on GitHub · 2026-11-27 04:02 UTC · original

Closing carried-over draft: OpAtomicStore fix for MSG_GS_ALLOC_REQ already landed on main (0b589ea / 1504c1af6).

**@⁠Andretuta** on GitHub · 2026-11-27 04:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7209466983) Closing carried-over draft: `OpAtomicStore` fix for `MSG_GS_ALLOC_REQ` already landed on `main` (`0b589ea` / `1504c1af6`).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.