Skip to content

vk_harness: a stage without subgroup support is unsupported (77), not a failed pipeline - #8885

Closed
BlazeXYZ wants to merge 1 commit into
ProjectLeonida:mainfrom
BlazeXYZ:vk-harness-subgroup-stages
Closed

BlazeXYZ wants to merge 1 commit into
ProjectLeonida:mainfrom
BlazeXYZ:vk-harness-subgroup-stages

Conversation

@BlazeXYZ

Copy link
Copy Markdown

Claim: #8683 (comment) (new item, from @alvaroaguileraweb's finding #8683 (comment))

On MoltenVK, runtime/test/shaders/w64_graphics.py's seven vs_w64_* fixtures fail at vkCreateGraphicsPipelines ("Subgroup builtins are not available in this type of function") instead of skipping, so a Mac run can't tell the driver limit from a translator regression.

A stage that uses subgroup operations needs the device to list it in VkPhysicalDeviceSubgroupProperties::supportedStages, and MoltenVK lists no vertex stage (as #6160 also notes). vk_harness now checks every stage it builds:

  • the first shader as vertex, mesh (VKH_MESH) or compute (--mesh-compute)
  • VKH_MESH_COMPUTE's vertex shader
  • VKH_GS
  • the fragment shader

A stage that declares a GroupNonUniform* (61..68) or SubgroupBallotKHR/SubgroupVoteKHR capability where the device has no subgroup operations is now unsupported: <module> uses subgroup operations and the device has none in the <stage> stage with exit 77. w64_graphics.py and the other runners already report 77 as SKIP. vk_ps_sweep.cpp:305 already makes the same check for the fragment stage. rdna2spirv.py declares these capabilities only for a shader that uses them, so other draws and devices are unaffected: RADV, AMD, NVIDIA and Intel list every graphics stage.

  • runtime/test/spirv_capability.h: uses_subgroup_operations(), next to needs_shader_int64().
  • runtime/test/spirv_capability_test.cpp: 9 CPU-only checks (each capability, a non-subgroup neighbour, a capability after OpMemoryModel, an empty module).
  • runtime/test/shaders/w64_graphics.py: the docstring says these fixtures skip where the vertex stage has no subgroup operations.

Tested (Windows 10, no GPU run, no game files):

  • spirv_capability_test built with clang 20 (zig c++, -std=c++20 -Wall -Wextra): all checks pass.
  • vk_harness.cpp compiled for x86_64-windows-gnu with -Wall against the Khronos Vulkan-Headers: no errors or warnings, same as main. Not built with MSVC here (no Visual Studio on this machine).
  • tests/test_w64_graphics_args.py, _probe.py, _reference.py: OK.
  • Not run on MoltenVK. @alvaroaguileraweb, could you re-run w64_graphics.py on your M2 with this branch? The vs_w64_* rows should read SKIP (unsupported: ...).

AI-assisted (Claude Code).

🤖 Generated with Claude Code

… a failed pipeline

A stage that uses subgroup operations needs the device to list it in
VkPhysicalDeviceSubgroupProperties::supportedStages. MoltenVK lists no vertex
stage, so w64_graphics.py's seven vs_w64_* fixtures failed at
vkCreateGraphicsPipelines ("Subgroup builtins are not available in this type of
function") instead of skipping, and a Mac run could not tell the driver limit
from a translator regression.

vk_harness now checks each stage it builds (vertex, or the mesh / --mesh-compute
shader, VKH_MESH_COMPUTE's vertex shader, VKH_GS and the fragment shader): one
that declares a GroupNonUniform* or SubgroupBallot/VoteKHR capability where the
device has no subgroup operations is "unsupported:" with exit 77, which
w64_graphics.py and the other runners already report as SKIP. vk_ps_sweep makes
the same check for the fragment stage. rdna2spirv.py declares these
capabilities only for a shader that uses them, so other draws are unaffected.

The capability test lives in spirv_capability.h (uses_subgroup_operations) with
CPU-only checks in spirv_capability_test.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@catminou4

Copy link
Copy Markdown
Contributor

Tested on Apple M1 Max, macOS 27.2.1 arm64: built spirv_capability_test from this head → "spirv_capability: all checks passed", exit 0. No game files. AI-assisted (Devin).

@catminou4

Copy link
Copy Markdown
Contributor

Follow-up GPU check on the same head, Apple M1 Max, macOS 27.2.1 arm64, MoltenVK 1.4.2 — the w64_graphics.py suite itself (this is the MoltenVK vs_w64_* case from the coordination finding):

Built vk_harness from this head, translated all 270 fixtures with runtime/test/shaders/build.py, ran w64_graphics.py — 32/32 SKIP, 0 FAIL:

  • vs_w64_* ×7 → SKIP (unsupported: ... uses subgroup operations and the device has none in the vertex stage) — the new stage-support check turns the previous pipeline-creation failure into a clean skip, as intended.
  • gs_w64_* ×2 → SKIP (unsupported: no geometryShader) — expected, Metal has no GS stage.
  • ps_w64_a/b ×14 → SKIP (the fragment stage may run fewer live lanes than 32 here (4..) and 32 or 64 could not be required) — MoltenVK's subgroup range is 4–32 with no required-size stages for fragment, so tiers A/B correctly decline.
  • ps_w64_c ×9 → SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF).

On Apple Silicon the whole wave64-graphics suite is unreachable — every path skips for a documented hardware reason rather than failing. No game files. AI-assisted (Devin).

@lohant27-netizen

Copy link
Copy Markdown

Tested 63c80b329 on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8871, #8869, #8825, #8863 and #8885 (no conflicts): pass.

@alvaroaguileraweb

Copy link
Copy Markdown

Apple M2 re-run of w64_graphics.py on 63c80b3: 29/29 SKIP, 0 FAIL.

  • Device: Apple M2 (Mac14,2), macOS 26.6.2 (25G83), MoltenVK 1.4.2, subgroup 4..32.
  • Build: vk_harness and spirv_capability_test; spirv_capability: all checks passed.
  • w64_graphics.py (SPIR-V from the current main 867d922 build):
    • 7 vs_w64_* -> SKIP (unsupported: ... uses subgroup operations and the device has none in the vertex stage).
    • 2 gs_w64_* -> SKIP (unsupported: no geometryShader).
    • 20 ps_w64_* -> SKIP (fragment stage may run fewer live lanes; tier C needs 64+32).
    • 0 FAIL.
  • The previous vkCreateGraphicsPipelines failure is gone; the VS rows now read SKIP as requested.
  • No game files; synthetic fixtures only.

AI-assisted.

@alvaroaguileraweb

Copy link
Copy Markdown

Addendum: a normal non-subgroup pixel draw still passes with this vk_harness. python3 -I scripts/run_gpu_tests.py --build runtime/build/linux --filter ps_flat --require-pass -> 1/1 passed (4096 pixels, flat IDs exact, uv within 6e-08). AI-assisted.

@wavehs

wavehs commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

macOS arm64 verification (Apple M3 Pro, MoltenVK + KosmicKrisp) — the skip fires, and the fixtures really do fail without it

Tested PR head 63c80b32, merged onto main 867d922f0 (merge 63c80b329), no conflicts.

Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2, Apple clang 21.0.0, CMake 4.5.0, SPIRV-Tools v2026.4. Drivers: MoltenVK 1.4.0 and Mesa 26.3.0 KosmicKrisp, both through libvulkan.1.dylib with VK_DRIVER_FILES.

Check Result
ctest -R spirv_capability 1/1 pass
Full build + ctest -j 8 exit 0, 46.85 s, only the pre-existing shader_library_corpus and vk_sync_validation skips
vs_w64_* fixtures through w64_graphics.check, MoltenVK 7/7 SKIP with the new message
same, KosmicKrisp 7/7 SKIP
ps_w64_a_skip (fragment, subgroups fine there) runs, no false skip

The 7 are vs_w64_a_skip, vs_w64_b_waterfall, vs_w64_b_readlane_uniform, vs_w64_b_ballot_atomic, vs_w64_c_bcnt_export, vs_w64_c_readlane, vs_w64_c_lane_id, built with runtime/test/shaders/build.py (all 9 translated, 9 pass spirv-val).

Negative control — the premise is real, not assumed. vk_harness built from origin/main in a separate tree, same fixtures, MoltenVK:

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

The same line for all 7 fixtures, and -13 on KosmicKrisp. With the PR they return 77 and w64_graphics.py turns that into Skip, so a driver that cannot run the stage now skips instead of failing the run.

I also checked the two ways this could over-skip:

  • Plain vertex shader with no subgroup capability → exit 0 on both drivers, so the check does not fire on a normal VS.
  • Subgroups moved to the fragment stage → exit 0 on both drivers, so a supported stage is not refused.
  • A vertex shader whose OpGroupNonUniformAny result feeds gl_Position → exit 0 on main, i.e. MoltenVK does compile subgroup operations in a vertex function; what it refuses is subgroup builtins (gl_SubgroupSize, gl_SubgroupInvocationID, …). The capability scan is therefore strictly broader than the observed failure.

That last point is not a defect — Vulkan requires the stage to be listed in supportedStages for any subgroup capability, so skipping is the correct side of an unspecified case — but the code comment attributes the skip to the MSL error alone. Since the two conditions differ (operations compile, builtins do not), a sentence saying why the capability is the right test rather than "the MSL conversion stops it" would save the next reader from re-deriving it, and it is the reason this stays correct when a driver is more permissive than MoltenVK.

Found: the SKIP line now reads unsupported: unsupported: …

SKIP (unsupported: unsupported: /tmp/shaders8885/spirv/vs_w64_a_skip.spv uses subgroup operations and the device has none in the vertex stage)

runtime/test/shaders/w64_graphics.py:268 prepends its own "unsupported: " to the harness's last line, and the harness's line (runtime/test/vk_harness.cpp:547) already starts with unsupported: ; :393-394 then wraps the result in SKIP (…). The duplication is pre-existing, but this PR is the first path that reaches it from vk_harness for a graphics stage, so these are the first SKIP lines that show it. The smallest fix is to stop adding the prefix at :268 (the last line already names the stage) or to route it through scripts/run_gpu_tests.py's unsupported_skip(), which extracts the unsupported: line instead of concatenating. Two-line change, and it makes the skip self-describing in CI logs.

Smaller notes. stages[] re-reads argv[1] and the GS module with read_spv() although vs_code/gs_code are already in hand (argv[2] correctly reuses fs_code) — cheap to make consistent, and it keeps the "one read per file" property if a fixture is ever replaced mid-run. The props.apiVersion >= VK_API_VERSION_1_1 guard is right: pre-1.1 devices have no VkPhysicalDeviceSubgroupProperties to query. stages[] has no tessellation entry, which matches the harness (it never creates a tessellation stage), so VERTEX is the only non-mesh graphics stage that can be checked here — worth keeping in mind if tessellation fixtures are added later, since VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT is in MoltenVK's 0x32 and would be wrongly refused under the VERTEX label.

Measured supportedStages for the record: MoltenVK 0x32 (compute, fragment, tessellation-control), KosmicKrisp 0x30 (compute, fragment). Neither lists vertex, which is exactly the case this PR handles.

The new unit tests are the right shape: every capability in the range, both KHR aliases, the boundary just past it (69), a capability placed after OpMemoryModel (ignored), and the empty module.

No game files. AI-assisted.

@OlaiFG7

OlaiFG7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Reviewed 63c80b3, code read only (not built, no MSVC or GPU here), AI-assisted: LGTM. runtime/test/vk_harness.cpp:529-552 reads VkPhysicalDeviceSubgroupProperties::supportedStages (apiVersion >= 1.1), tests every active stage bit and exits 77; the SPIR-V capability IDs (61..68, 4423, 4431 in spirv_capability.h:53-63) match tools/spirv_asm_tables.py, and the nine unit checks are not vacuous. I second the non-blocking notes already made: the pre-existing doubled unsupported: prefix at runtime/test/shaders/w64_graphics.py:268 and the redundant read_spv. Overlaps: #9079 (spirv_capability.h) and #9155 (vk_harness.cpp).

@Michele0303

Copy link
Copy Markdown

checked: #8885 at 63c80b32 | base: main@5d74c27 | on: macOS 27.0.1 arm64 (Apple M5), MoltenVK 1.4.2, Python 3.13 | result: pass; w64_graphics.py exit 1 on main (7 vs_w64_* fail at vkCreateGraphicsPipelines), exit 0 here (those 7 SKIP, every ps_w64_*/gs_w64_* row unchanged)
Full run_gpu_tests.py with this vk_harness: 180/241 passed, 60 skipped, all 241 rows identical to main (the one FAIL is cs_fma_fused, #8183).
AI-assisted (Claude Code). No game data.

@cooooooto

Copy link
Copy Markdown

Independent Apple M4 / MoltenVK validation of closed head 63c80b329 against base 867d922f0: pass for the scoped fix.

Host: Mac mini (Apple M4), macOS 27.0.1 (26A434), MoltenVK 1.4.2, Vulkan loader/headers/tools 1.4.363.0, Python 3.12.16, AppleClang 21.0.0, CMake 4.5.1, LLVM/llvm-mc 23.1.6, SPIRV-Tools v2026.4. The device reports subgroup 32 (range 4..32), supportedStages=0x32 (tessellation-control | fragment | compute), and requiredSubgroupSizeStages=0; vertex and geometry are not subgroup-capable stages. No game files.

Base and head were built in separate directories. Both pass the Python w64 tests, compileall, check_no_game_data, spirv_capability, and the complete portable CTest (64/64, with the same two expected skips). The same 32 hand-written shaders translated and passed spirv-val on both; their output trees are byte-identical.

Real GPU result from w64_graphics.py:

tree PS (20) GS (2) VS (7) exit
base 867d922f0 20 SKIP 2 SKIP 7 FAIL (pipeline -3) 1
#8885 63c80b329 20 SKIP 2 SKIP 7 SKIP (vertex absent from supportedStages) 0

Controls against over-skipping passed: ps_flat is 1/1 PASS on both; a subgroup shader in the supported fragment stage executes on both and produces byte-identical raw output; the Wave64 vertex module changes directly from exit 1 on base to exit 77 with the intended capability reason on head. A deliberately invalid module in the supported fragment slot is not converted to exit 77 (MoltenVK aborts with its own Entry point does not exist error), so unrelated pipeline failures are not hidden by this check.

The complete GPU suite is also classification-identical: 179 PASS, 60 SKIP, 2 FAIL on both base and head. The two failures are the same cs_fma_fused and ps_ssharp results on this MoltenVK host, unrelated to this PR.

Conclusion: this capability-based approach fixes the actual M4/MoltenVK failure without the skip-before-compare coverage loss observed in #9275. The only visible issue I found in scope is the already-reported doubled unsupported: unsupported: prefix. Since #8885 is now closed without merge, this result may be useful if the change is reopened or carried into a replacement PR.

AI-assisted validation; all GPU commands were actually executed on the Apple M4.

@cooooooto

Copy link
Copy Markdown

Follow-up against current remote main 2d53a8055: the MoltenVK failure is still present and I found no equivalent stage-capability check in vk_harness/spirv_capability.

Fresh native build on the same Apple M4 / MoltenVK 1.4.2 host, with 31 freshly built hand-written Wave64/auxiliary shaders: 31/31 translated and 31/31 passed spirv-val.

w64_graphics.py on current main:

  • 20 PS fixtures: SKIP for the documented subgroup-size reasons;
  • 2 GS fixtures: SKIP (no geometryShader);
  • all 7 vs_w64_* fixtures: FAIL at pipeline creation with Subgroup builtins are not available in this type of function, vkCreateGraphicsPipelines -> -3;
  • exit 1.

So #8885 has not been superseded on current main; its capability-based exit-77 change remains applicable. No game files. AI-assisted validation; the GPU run was executed on the Apple M4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants