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

Closed
Andretuta wants to merge 1 commit from upstream-pr/94 into main
Andretuta commented 2026-11-24 02:16:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:16:42Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464812422 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/94). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:16:42Z. --- > 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.
sodove commented 2026-11-24 06:20:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-24T06:20:42Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7123836259 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7123836259). Originally posted by [sodove](https://github.com/sodove) on 2026-11-24T06:20:42Z. --- 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.
Len1k commented 2026-11-24 09:05:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Len1k on 2026-11-24T09:05:18Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7126941792 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7126941792). Originally posted by [Len1k](https://github.com/Len1k) on 2026-11-24T09:05:18Z. --- 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.
thesubtleties commented 2026-11-24 16:18:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by thesubtleties on 2026-11-24T16:18:08Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137440878 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7137440878). Originally posted by [thesubtleties](https://github.com/thesubtleties) on 2026-11-24T16:18:08Z. --- 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).
Andretuta commented 2026-11-27 04:02:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-27T04:02:12Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7209466983 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/94#issuecomment-7209466983). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-27T04:02:12Z. --- Closing carried-over draft: `OpAtomicStore` fix for `MSG_GS_ALLOC_REQ` already landed on `main` (`0b589ea` / `1504c1af6`).

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!94
No description provided.