Skip to content

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

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

BlazeXYZ wants to merge 1 commit into
ItsNotRexed: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

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

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.

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.

5 participants