vk_harness: a vertex shader with subgroup operations is unsupported where the vertex stage has none (TEST-W64G-VS-SUBGROUP-STAGE) #900

Closed
hugo0024 wants to merge 1 commit from upstream-pr/900 into main
hugo0024 commented 2026-11-24 15:06:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by hugo0024 on 2026-11-24T15:06:10Z.


Claimed in the coordination issue as: TEST-W64G-VS-SUBGROUP-STAGE (claim)

What and why

runtime/test/shaders/w64_graphics.py fails all seven vs_w64_* fixtures on a Mac. They read SubgroupLocalInvocationId, and MoltenVK cannot build the pipeline:

vs_w64_c_lane_id  C  64: exit 1: ... [mvk-error] SPIR-V to MSL conversion error: Subgroup builtins are not available in this type of function. | FAILED vkCreateGraphicsPipelines

The device says so itself: its subgroup supportedStages are compute, fragment and tessellation control ("supported_subgroup_stages": 50 from tools/vk_subgroup_info.py). A Metal vertex function has no SIMD-group built-ins. Using subgroup operations in a stage outside supportedStages is not valid Vulkan, so this is a device that cannot run the fixture, not a failure of it.

  • vk_harness.cpp reads VkPhysicalDeviceSubgroupProperties and exits 77 with unsupported: no subgroup operations in the vertex stage when the vertex module declares a GroupNonUniform capability and the vertex stage is not in supportedStages. Only for a plain draw: under VKH_MESH and VKH_MESH_COMPUTE the first module is a mesh shader.
  • spirv_capability.h gets uses_subgroup_operations() (any of the eight GroupNonUniform capabilities), with cases in spirv_capability_test.cpp.
  • w64_graphics.py is unchanged: it already turns a 77 into a SKIP, as it does for the geometry fixtures.
  • docs/testing.md: a paragraph in the w64_graphics.py section on what a Mac gives.

Of the 18 vertex fixtures build.py makes, only the seven vs_w64_* declare a GroupNonUniform capability, so nothing that runs today is skipped by this.

Tested

Apple M5, MoltenVK 1.4.2. w64_graphics.py on all 29 fixtures, before at main 3d3770c16 and after on this branch (vk_harness.cpp and w64_graphics.py did not change in between):

Skipped Failed Exit
Before 22 7 (the vs_w64_*) 1
After 29 0 0
  • The seven now print SKIP (unsupported: unsupported: no subgroup operations in the vertex stage); the doubled word is how the runner prints every 77, the geometry ones too.
  • spirv_capability_test: all checks pass. ctest: 72/72.
  • run_gpu_tests.py: 185/249 passed, 61 skipped, 3 failed in one run and 184 with 4 failed in another. The failures are cs_fma_fused, cs_imgload_tfe, cs_imgload_d16_tfe and the intermittent ps_imgatomic (#543), as on main; every plain vertex shader still draws.
  • tests/test_w64_graphics_*.py, tests/test_docs_*.py and tests/test_i18n_index.py pass.

Not tested: a device that has the vertex stage in supportedStages, where the new check is a no-op by construction, and the geometry stage, which this does not touch (a Mac has none).

GPUs tested: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1 (26B131)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474757791 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/900). Originally posted by [hugo0024](https://github.com/hugo0024) on 2026-11-24T15:06:10Z. --- Claimed in the coordination issue as: TEST-W64G-VS-SUBGROUP-STAGE ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135325373)) ### What and why `runtime/test/shaders/w64_graphics.py` fails all seven `vs_w64_*` fixtures on a Mac. They read `SubgroupLocalInvocationId`, and MoltenVK cannot build the pipeline: ```text vs_w64_c_lane_id C 64: exit 1: ... [mvk-error] SPIR-V to MSL conversion error: Subgroup builtins are not available in this type of function. | FAILED vkCreateGraphicsPipelines ``` The device says so itself: its subgroup `supportedStages` are compute, fragment and tessellation control (`"supported_subgroup_stages": 50` from `tools/vk_subgroup_info.py`). A Metal vertex function has no SIMD-group built-ins. Using subgroup operations in a stage outside `supportedStages` is not valid Vulkan, so this is a device that cannot run the fixture, not a failure of it. - `vk_harness.cpp` reads `VkPhysicalDeviceSubgroupProperties` and exits 77 with `unsupported: no subgroup operations in the vertex stage` when the vertex module declares a GroupNonUniform capability and the vertex stage is not in `supportedStages`. Only for a plain draw: under `VKH_MESH` and `VKH_MESH_COMPUTE` the first module is a mesh shader. - `spirv_capability.h` gets `uses_subgroup_operations()` (any of the eight GroupNonUniform capabilities), with cases in `spirv_capability_test.cpp`. - `w64_graphics.py` is unchanged: it already turns a 77 into a `SKIP`, as it does for the geometry fixtures. - `docs/testing.md`: a paragraph in the `w64_graphics.py` section on what a Mac gives. Of the 18 vertex fixtures `build.py` makes, only the seven `vs_w64_*` declare a GroupNonUniform capability, so nothing that runs today is skipped by this. ### Tested Apple M5, MoltenVK 1.4.2. `w64_graphics.py` on all 29 fixtures, before at `main` `3d3770c16` and after on this branch (`vk_harness.cpp` and `w64_graphics.py` did not change in between): | | Skipped | Failed | Exit | |---|---|---|---| | Before | 22 | 7 (the `vs_w64_*`) | 1 | | After | 29 | 0 | 0 | - The seven now print `SKIP (unsupported: unsupported: no subgroup operations in the vertex stage)`; the doubled word is how the runner prints every 77, the geometry ones too. - `spirv_capability_test`: all checks pass. `ctest`: 72/72. - `run_gpu_tests.py`: 185/249 passed, 61 skipped, 3 failed in one run and 184 with 4 failed in another. The failures are `cs_fma_fused`, `cs_imgload_tfe`, `cs_imgload_d16_tfe` and the intermittent `ps_imgatomic` (#543), as on `main`; every plain vertex shader still draws. - `tests/test_w64_graphics_*.py`, `tests/test_docs_*.py` and `tests/test_i18n_index.py` pass. Not tested: a device that has the vertex stage in `supportedStages`, where the new check is a no-op by construction, and the geometry stage, which this does not touch (a Mac has none). GPUs tested: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1 (26B131) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PierreEbele commented 2026-11-25 21:09:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T21:09:45Z.


Reviewed d063e61a: vk_harness now reports 77 for a vertex module declaring GroupNonUniform(61..68) where subgroupSupportedStages has no vertex stage; w64_graphics.py turns 77 into a SKIP. I could not build or run the C++ side here (no GPU and no C++ toolchain), so spirv_capability_test and vk_harness were only read, not executed. What I did run on both trees: the related CPU tests (test_gpu_unsupported_stage, test_w64_graphics_probe, test_wave64_graphics_scan - pass) and a probe that translates all seven vs_w64_* fixtures with the repo's own translator: each declares capability 61 (and SubgroupLocalInvocationId) while vs_ids declares none, so the exit path covers exactly the seven fixtures that failed on MoltenVK. Two non-blocking questions: the commit's "22 skipped and 7 failed -> 29 skipped" does not add up to the 30 entries in FIXTURES - what did the extra fixture do?; and is capability declaration (not builtin use) the intended marker? No findings; CI building spirv_capability_test is the remaining check. AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174694696 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/900#issuecomment-7174694696). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T21:09:45Z. --- Reviewed d063e61a: `vk_harness` now reports 77 for a vertex module declaring GroupNonUniform(61..68) where `subgroupSupportedStages` has no vertex stage; `w64_graphics.py` turns 77 into a SKIP. I could not build or run the C++ side here (no GPU and no C++ toolchain), so `spirv_capability_test` and `vk_harness` were only read, not executed. What I did run on both trees: the related CPU tests (`test_gpu_unsupported_stage`, `test_w64_graphics_probe`, `test_wave64_graphics_scan` - pass) and a probe that translates all seven vs_w64_* fixtures with the repo's own translator: each declares capability 61 (and SubgroupLocalInvocationId) while vs_ids declares none, so the exit path covers exactly the seven fixtures that failed on MoltenVK. Two non-blocking questions: the commit's "22 skipped and 7 failed -> 29 skipped" does not add up to the 30 entries in FIXTURES - what did the extra fixture do?; and is capability declaration (not builtin use) the intended marker? No findings; CI building spirv_capability_test is the remaining check. AI-assisted review. **Recommendation:** Merge
hugo0024 commented 2026-11-26 07:37:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by hugo0024 on 2026-11-26T07:37:23Z.


@PierreEbele thanks for the review. Both answers:

  1. The numbers in the commit message were measured on main 3d3770c16, where FIXTURES had 29 entries. ps_w64_a_wqm_uniform_vote came in after that, with f03418595 (SHADER-W64-WQM-UVOTE). On the branch as it is now, rebased onto 6fe83805a, the M5 run is 30 skipped of 30, exit 0; the commit message and the description still carry the first measurement.
  2. Yes, the declaration is the intended marker. A module cannot use a subgroup built-in or a subgroup instruction without declaring a GroupNonUniform capability, so the declaration covers both and sits in the module header, where declares_capability already reads. What it costs is a module that declared one without using it, which would be skipped for nothing: of the 18 vertex fixtures build.py makes, only the seven vs_w64_* declare one.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7185655013 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/900#issuecomment-7185655013). Originally posted by [hugo0024](https://github.com/hugo0024) on 2026-11-26T07:37:23Z. --- @PierreEbele thanks for the review. Both answers: 1. The numbers in the commit message were measured on `main` `3d3770c16`, where `FIXTURES` had 29 entries. `ps_w64_a_wqm_uniform_vote` came in after that, with `f03418595` (SHADER-W64-WQM-UVOTE). On the branch as it is now, rebased onto `6fe83805a`, the M5 run is 30 skipped of 30, exit 0; the commit message and the description still carry the first measurement. 2. Yes, the declaration is the intended marker. A module cannot use a subgroup built-in or a subgroup instruction without declaring a GroupNonUniform capability, so the declaration covers both and sits in the module header, where `declares_capability` already reads. What it costs is a module that declared one without using it, which would be skipped for nothing: of the 18 vertex fixtures `build.py` makes, only the seven `vs_w64_*` declare one. AI-assisted.
ecox982745 commented 2026-11-26 07:50:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-26T07:50:07Z.


Tested the vertex-supported case on an RTX 4090, driver 616.64, Windows build 26300. I built vk_harness and spirv_capability_test separately from PR head d063e61ab and its parent 6fe83805a. The device reports supported_subgroup_stages=0x3fff (vertex included) and a subgroup size range of 32–32.

  • GPU: All seven vs_w64_* shaders drew on both revisions. An extra default-size draw of 960 vertices per fixture gave identical four-word records for all 6,720 vertices across the two builds. The fixture checks for defined values, including the atomic counter and slot membership, passed on both.
  • Stock runner: All 30 w64_graphics.py results matched the parent. Each build had 18 passes, 12 tier-C comparisons skipped because they need a 64-lane reference, and zero failures. The geometry ring and all four tier-A/B vertex cases passed. No draw hit the new vertex-stage skip on this GPU.
  • CPU/tooling: spirv_capability_test passed on both revisions. I translated and validated the 30 synthetic fixtures and two helper shaders once, then used those same SPIR-V binaries with both harnesses.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7185886373 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/900#issuecomment-7185886373). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-26T07:50:07Z. --- Tested the vertex-supported case on an RTX 4090, driver 616.64, Windows build 26300. I built `vk_harness` and `spirv_capability_test` separately from PR head `d063e61ab` and its parent `6fe83805a`. The device reports `supported_subgroup_stages=0x3fff` (vertex included) and a subgroup size range of 32–32. - **GPU:** All seven `vs_w64_*` shaders drew on both revisions. An extra default-size draw of 960 vertices per fixture gave identical four-word records for all **6,720 vertices** across the two builds. The fixture checks for defined values, including the atomic counter and slot membership, passed on both. - **Stock runner:** All 30 `w64_graphics.py` results matched the parent. Each build had 18 passes, 12 tier-C comparisons skipped because they need a 64-lane reference, and zero failures. The geometry ring and all four tier-A/B vertex cases passed. No draw hit the new vertex-stage skip on this GPU. - **CPU/tooling:** `spirv_capability_test` passed on both revisions. I translated and validated the 30 synthetic fixtures and two helper shaders once, then used those same SPIR-V binaries with both harnesses.
zmasi commented 2026-11-29 00:36:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:36:36Z.


Windows 11 + MSVC 19.44 + RTX 3090 Verification — PASS (9fb314f5ce)

Verified 9fb314f5ce (TEST-W64G-VS-SUBGROUP-STAGE) merged onto origin/main (829530dbd0 and 48bae6cade, 0 conflicts, plus a 5-way combined merge alongside #1918, #1579, #1628, and #2198) on native Windows 11 (10.0.26200.9974) with MSVC 19.44.35228, NVIDIA GeForce RTX 3090, and VK_LAYER_KHRONOS_validation 1.4.363.1.

Checks Run

  • Red -> Green spirv_capability_test (/std:c++20 /O2 /MD /EHsc /W4 /permissive- /utf-8):
    • Red: compiling #900's runtime/test/spirv_capability_test.cpp against origin/main's spirv_capability.h failed (rc=2, missing uses_subgroup_operations).
    • Green: spirv_capability_test.exe compiled with 0 warnings and passed (rc=0: spirv_capability: all checks passed), covering capabilities 61..68 (GroupNonUniform..GroupNonUniformQuad), boundary neighbours 60 and 69, empty modules, and post-preamble operand words.
  • vk_harness.exe hardware & simulated ~VK_SHADER_STAGE_VERTEX_BIT verification (on NVIDIA GeForce RTX 3090, LEONIDA_VK_VALIDATION=1):
    • Native RTX 3090 (supportedStages includes VK_SHADER_STAGE_VERTEX_BIT): assembled a synthetic SPIR-V vertex shader declaring OpCapability GroupNonUniform + BuiltIn SubgroupLocalInvocationId paired with fs_solid.spv -> exited 0 (ok 64x64), 0 VUID- / validation errors.
    • Simulated vertex-subgroup-less adapter (sgStages.supportedStages &= ~VK_SHADER_STAGE_VERTEX_BIT):
      • Plain draw mode with the GroupNonUniform vertex shader exited 77 (SKIP) with "unsupported: no subgroup operations in the vertex stage".
      • VKH_MESH=1 mode confirmed !mesh && !mesh_compute prevents mesh shaders (argv[1]) from being misclassified as vertex-stage subgroup shaders.
  • Documentation & registration suites: tests/test_docs_encoding.py, tests/test_ctest_registration.py, and tests/test_ci_registration.py all passed (rc=0).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248231086 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/900#issuecomment-7248231086). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T00:36:36Z. --- ## Windows 11 + MSVC `19.44` + RTX 3090 Verification — PASS (`9fb314f5ce`) Verified `9fb314f5ce` (`TEST-W64G-VS-SUBGROUP-STAGE`) merged onto `origin/main` (`829530dbd0` and `48bae6cade`, `0` conflicts, plus a 5-way combined merge alongside `#1918`, `#1579`, `#1628`, and `#2198`) on native Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228`, **NVIDIA GeForce RTX 3090**, and `VK_LAYER_KHRONOS_validation` `1.4.363.1`. ### Checks Run - **Red -> Green `spirv_capability_test`** (`/std:c++20 /O2 /MD /EHsc /W4 /permissive- /utf-8`): - **Red**: compiling `#900`'s `runtime/test/spirv_capability_test.cpp` against `origin/main`'s `spirv_capability.h` failed (`rc=2`, missing `uses_subgroup_operations`). - **Green**: `spirv_capability_test.exe` compiled with `0` warnings and passed (`rc=0`: `spirv_capability: all checks passed`), covering capabilities `61..68` (`GroupNonUniform`..`GroupNonUniformQuad`), boundary neighbours `60` and `69`, empty modules, and post-preamble operand words. - **`vk_harness.exe` hardware & simulated `~VK_SHADER_STAGE_VERTEX_BIT` verification** (on **NVIDIA GeForce RTX 3090**, `LEONIDA_VK_VALIDATION=1`): - **Native RTX 3090 (`supportedStages` includes `VK_SHADER_STAGE_VERTEX_BIT`)**: assembled a synthetic SPIR-V vertex shader declaring `OpCapability GroupNonUniform` + `BuiltIn SubgroupLocalInvocationId` paired with `fs_solid.spv` -> exited **`0`** (`ok 64x64`), `0` `VUID-` / validation errors. - **Simulated vertex-subgroup-less adapter (`sgStages.supportedStages &= ~VK_SHADER_STAGE_VERTEX_BIT`)**: - Plain draw mode with the `GroupNonUniform` vertex shader exited **`77`** (`SKIP`) with `"unsupported: no subgroup operations in the vertex stage"`. - `VKH_MESH=1` mode confirmed `!mesh && !mesh_compute` prevents mesh shaders (`argv[1]`) from being misclassified as vertex-stage subgroup shaders. - **Documentation & registration suites**: `tests/test_docs_encoding.py`, `tests/test_ctest_registration.py`, and `tests/test_ci_registration.py` all passed (`rc=0`). AI-assisted.
aslan2142 commented 2026-12-01 17:21:29 +00:00 (Migrated from github.com)

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


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:7319170305 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/900#issuecomment-7319170305). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:21:29Z. --- 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!900
No description provided.