Repository navigation
Conversation
…SHADER-302) Since SHADER-231 every access through a run-time V# adds ADD_TID_ENABLE times the wave lane, and outside compute and mesh shaders that lane is SubgroupLocalInvocationId. MoltenVK has no subgroups in the vertex stage (a Metal vertex function has no SIMD-group lane), so SPIRV-Cross stops with "Subgroup builtins are not available in this type of function" and any VS that fetches through a run-time V# (vs_m15) fails pipeline creation on a Mac. With --no-vertex-subgroups a VS leaves the lane out of a run-time V#'s index (exact while the bit is clear; lane 0 when set) and refuses a literal V# with the bit. vk_subgroup_info.py reports vertex_in_supported_stages, and make_game.py and run_gpu_tests.py turn the flag on where it is false (LEONIDA_NO_VERTEX_SUBGROUPS overrides the runner; build.py takes =1), like --f16-interp-fallback. Checked on an Apple M5 (MoltenVK 1.4.2): vk_pipeline_check creates 9 of 9 VS pipelines (8 of 9 on main), with the same validation messages; only vs_m15.spv changes and run_gpu_tests.py gives the same result per test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested I translated all 2,236 VS of the corpus with
Failure classes. Each failed pipeline was re-run alone with
The PR gains 993 pipelines, and they are exactly the 993 VS whose index
The 572 VS that still fail all keep What changes in the modules:
GPU-test modules: 175 build here; I left out The flag turns on by itself on this Mac:
Rebasing onto main:
Tests:
No game data. AI-assisted. |
|
Tested under Wine on a Mac: this PR makes the Windows Setup: Apple M3 Max, macOS 27.3, CrossOver 26.3 (wine-11.0) with MoltenVK 1.4.3 (main 5189f8de, SPIRV-Cross 57e4efcc). Windows build cross-compiled with clang-cl 23.1.6 + xwin ( On main 4947579 the test fails at the PSO, the same error as in the description: With this PR merged into 4947579 locally (conflicts resolved:
One gap for the Windows/Wine path: the D3D12 tests' shaders are translated by CMake's custom command ( No game data. AI-assisted (Claude Code). |
…LSB (SHADER-413) A native readfirstlane is a ballot of the EXEC lanes, its lowest set bit and a shuffle from that lane. MoltenVK lowers OpGroupNonUniformBallotFindLSB, like the SubgroupSize built-in, to Metal's threads_per_simdgroup input, which a vertex function can't declare, so every VS with a readfirstlane failed to compile on Apple GPUs. In a vertex shader the lowest bit is now taken with FindILsb over the ballot's four words, the form the --wave64-emulate path already uses on its mask words. It gives the same lane, since a ballot has no bit at or above the subgroup size. Other stages keep BallotFindLSB. On an Apple M4 (MoltenVK 1.4.2), with the 1.0.2.1 corpus translated from 4eb6155: exactly the 572 VS that contain v_readfirstlane_b32 change, and all 2,236 stay spirv-val-valid. VS pipelines go from 667 to 672 on main, and from 1,662 to 2,233 of 2,236 with #1784's --no-vertex-subgroups. tests/semantic/test_vs_readfirstlane.py runs it on the wave interpreter, with the first EXEC lane in word 0 and word 1 of the ballot. AI-assisted.
…ds use their own tool's flags
The any-flag check covers only the user-facing pages (README, CONTRIBUTING, AGENTS, i18n, docs/testing.md, the
runtime and semantic READMEs). Design and research notes such as docs/design.md cite flags of open pull requests
("ProjectLeonida#1784's --no-vertex-subgroups"), which no source has yet, so including them made the test fail on main. The
fenced-command check still runs on every page: a command block must use real flags of its script.
|
Independent MoltenVK check (claimed on #4571). Hardware correction: this machine reports Apple M2 / Mac14,3, not M1 — macOS 26.4 (25E246), MoltenVK 1.4.2 (device Vulkan 1.4.357), subgroup range 4..32, llvm-mc 23.1.6, Python 3.13.18. Head
Negative control on current upstream/main No code changes, no push, no game files; synthetic shaders and counts only. AI-assisted. |
|
Scope on current code, for the rebase. Apple M2 Max, Homebrew MoltenVK 1.4.2, own 1.0.2.1 dump translated with
So on current AI-assisted. No game files. |
|
Superseded by #6160, which is rebuilt on current |
…HADER-302) A VS reads its lane for the ADD_TID_ENABLE term of a run-time V# access (SHADER-231), for a lane mask in an SGPR it can't prove is one (Gen.mask_src, ProjectLeonida#1792) and for its own wave operations, and outside compute and mesh shaders that lane is SubgroupLocalInvocationId. A Metal vertex function has no SIMD-group lane id, so on MoltenVK SPIRV-Cross stops with "Subgroup builtins are not available in this type of function" and those VS fail pipeline creation. With --no-vertex-subgroups a VS that reads its lane computes it at entry into a Private %sg_lane: rank = exclusive add of 1, lane = position of set bit `rank` of ballot(true). The ballot and the scan see the same active invocations, so this is the invocation's own bit, equal to SubgroupLocalInvocationId on any active set (subgroups up to 128). Metal compiles ballots and scans in vertex functions. Other stages, and everything without the flag, are unchanged. vk_subgroup_info.py reports vertex_in_supported_stages; make_game.py and run_gpu_tests.py turn the flag on where it is false (LEONIDA_NO_VERTEX_SUBGROUPS overrides the runner, build.py takes =1). The subgroup interpreter gains Inclusive/ExclusiveScan for the integer group ops and loads through PhysicalStorageBuffer pointers (that branch was dead code inside OpAccessChain). New GPU fixture vs_lane_mask (a v_cndmask mask in user SGPR s2, drawn with ps_flat): on an Apple M5 it passes with the flag and fails without it with MoltenVK's subgroup-builtin error. Supersedes ProjectLeonida#1784. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HADER-302) A VS reads its lane for the ADD_TID_ENABLE term of a run-time V# access (SHADER-231), for a lane mask in an SGPR it can't prove is one (Gen.mask_src, ProjectLeonida#1792) and for its own wave operations, and outside compute and mesh shaders that lane is SubgroupLocalInvocationId. A Metal vertex function has no SIMD-group lane id, so on MoltenVK SPIRV-Cross stops with "Subgroup builtins are not available in this type of function" and those VS fail pipeline creation. With --no-vertex-subgroups a VS that reads its lane computes it at entry into a Private %sg_lane: rank = exclusive add of 1, lane = position of set bit `rank` of ballot(true). The ballot and the scan see the same active invocations, so this is the invocation's own bit, equal to SubgroupLocalInvocationId on any active set (subgroups up to 128). Metal compiles ballots and scans in vertex functions. Other stages, and everything without the flag, are unchanged. vk_subgroup_info.py reports vertex_in_supported_stages; make_game.py and run_gpu_tests.py turn the flag on where it is false (LEONIDA_NO_VERTEX_SUBGROUPS overrides the runner, build.py takes =1). The subgroup interpreter gains Inclusive/ExclusiveScan for the integer group ops and loads through PhysicalStorageBuffer pointers (that branch was dead code inside OpAccessChain). New GPU fixture vs_lane_mask (a v_cndmask mask in user SGPR s2, drawn with ps_flat): on an Apple M5 it passes with the flag and fails without it with MoltenVK's subgroup-builtin error. Supersedes ProjectLeonida#1784. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HADER-302) A VS reads its lane for the ADD_TID_ENABLE term of a run-time V# access (SHADER-231), for a lane mask in an SGPR it can't prove is one (Gen.mask_src, ItsNotRexed#1792) and for its own wave operations, and outside compute and mesh shaders that lane is SubgroupLocalInvocationId. A Metal vertex function has no SIMD-group lane id, so on MoltenVK SPIRV-Cross stops with "Subgroup builtins are not available in this type of function" and those VS fail pipeline creation. With --no-vertex-subgroups a VS that reads its lane computes it at entry into a Private %sg_lane: rank = exclusive add of 1, lane = position of set bit `rank` of ballot(true). The ballot and the scan see the same active invocations, so this is the invocation's own bit, equal to SubgroupLocalInvocationId on any active set (subgroups up to 128). Metal compiles ballots and scans in vertex functions. Other stages, and everything without the flag, are unchanged. vk_subgroup_info.py reports vertex_in_supported_stages; make_game.py and run_gpu_tests.py turn the flag on where it is false (LEONIDA_NO_VERTEX_SUBGROUPS overrides the runner, build.py takes =1). The subgroup interpreter gains Inclusive/ExclusiveScan for the integer group ops and loads through PhysicalStorageBuffer pointers (that branch was dead code inside OpAccessChain). New GPU fixture vs_lane_mask (a v_cndmask mask in user SGPR s2, drawn with ps_flat): on an Apple M5 it passes with the flag and fails without it with MoltenVK's subgroup-builtin error. Supersedes ItsNotRexed#1784. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing as promised above: #6160 replaces this PR (same SHADER-302, exact lane instead of lane 0) and has been reviewed and approved there. AI-assisted (Claude Code). |
SHADER-302. Claim: #1745 comment 7080201472. Follows up SHADER-231 (#1565).
Problem
Since #1565, every MUBUF/MTBUF access through a run-time V# adds
ADD_TID_ENABLE(word3 bit 23) × the wave lane to the index.Gen.wave_lanereturnsSubgroupLocalInvocationIdfor that lane outside compute and mesh shaders. MoltenVK'ssubgroupSupportedStageshas no vertex bit: it lists compute, fragment and tessellation control, because a Metal vertex function has no SIMD-group lane. So on a Mac the pipeline of any VS that fetches through a run-time V# fails:vs_m15is the GPU-test version of the game's fetch-without-fetch-program VS (runtime/test/shaders/vs_m15.asm). The same pattern in the corpus therefore fails at pipeline creation on every Mac.Change
The fix follows the existing
--f16-interp-fallbackpattern: the device decides and a translator flag carries it.tools/rdna2spirv.py: new--no-vertex-subgroups. With it,Gen.buffer_addressin a VS leaves the lane out of a run-time V#'s index, just as for a literal V# without the bit, so the VS declares neither the builtin norGroupNonUniformfor it.ADD_TID_ENABLEin a VS isUnsupportedunder the flag.tools/vk_subgroup_info.py: reportsvertex_in_supported_stages, the vertex bit ofsubgroupSupportedStages.make_game.py: turns the flag on by itself where that is false, like--f16-interp-fallback. The flag is also inFALLBACK_FLAGS, so it is recorded and forwarded.scripts/run_gpu_tests.py: turns the flag on where the device answer is false.LEONIDA_NO_VERTEX_SUBGROUPS=1/0overrides it. The device answer is read from the last JSON line of the output, so driver log lines after it don't hide it (the same fix run_gpu_tests: skip ps_ij_computed under the PerVertexKHR fallbacks, and find the device JSON past driver logs #1681 makes forper_vertex_inputs).runtime/test/shaders/build.pytakesLEONIDA_NO_VERTEX_SUBGROUPS=1.docs/design.md, a pointer to it from the swizzled-addressing row, and a "Macs: vertex shaders without subgroups" section indocs/testing.md.Tested
Apple M5, macOS 27.2.1, MoltenVK 1.4.2, Khronos validation layer 1.4.363, LLVM 23.1.6, Python 3.14.
main89b047cvk_pipeline_checkover the 170 GPU-test modules, VS pipelinesvs_m15)vs_m15.spv, the one VS that declared the builtin. The other 169 are byte-identical.run_gpu_tests.pyvs_m15is drawn only by the Windowsd3d12_translated_draw_test, so on the Mac the check is pipeline creation, not pixels. The onerun_gpu_tests.pyfailure isps_ij_computed, the same onmain; #1680 / #1681 fix it.Unit tests:
tests/semantic/test_no_vertex_subgroups.py(new) runs the VS in the one-lane interpreter:GroupNonUniform;main's translator, 3 of these fail (the builtin is still declared, and the literal is not refused).tests/test_vk_subgroup_info.py: the vertex bit for all-graphics, MoltenVK-like and vertex-only stage masks.tests/test_make_game_translator_flags.py: the flag follows the device, can be asked for explicitly, and composes with the f16 fallback.tests/test_run_gpu_tests.py: the device answer, including a driver log line after the JSON, and the env override.tests/test_make_game_argparse.py:test_custom_jobs_forwarded_to_shadersnow patches the new device probe as it already didruntime_gpu_per_vertex. Without that patch it queried the real GPU, and on a Mac it got the flag.python -m unittest discover -s tests/semantic: 1456 OK. I ran all 176 stdlibtests/test_*.pyfiles andcompileallis clean. The one failure,test_navmesh_index(test_differently_cased_report_path_cannot_be_scanned_input), fails the same way onmainon this Mac's case-insensitive APFS, and is unrelated.Unverified: how many of the game's VS fetch through a run-time V#, which needs a corpus count with game files, and whether any VS sets
ADD_TID_ENABLE.Validation-layer setup on the Mac: the test tools load MoltenVK directly. For the validation runs only, I used Homebrew's loader with a local copy of the MoltenVK ICD manifest marked
is_portability_driver: false, since the tools don't opt in to portability enumeration. That adds an unrelatedVUID-VkDeviceCreateInfo-pProperties-04451to both runs.Overlap
Some open PRs touch the same files:
tools/vk_subgroup_info.py: vk_subgroup_info: filter physical devices by LEONIDA_VK_DEVICE (TEST-258) #1755 (TEST-258).make_game.py: make_game: keep the default build folder out of iCloud-synced Documents on a Mac #1758, make_game.py: a layered driver's nested deviceName is not another GPU #1708, make_game: --wave64-emulate auto leaves emulation off on RDNA2 under the AMD Windows driver (#857) #1697.scripts/run_gpu_tests.py: GPU runners: ps_ij_computed SKIPs, not FAILs, without PerVertexKHR inputs (SHADER-177 follow-up) #1680, run_gpu_tests: skip ps_ij_computed under the PerVertexKHR fallbacks, and find the device JSON past driver logs #1681.None of them changes the same lines as far as I can see. Whichever lands second may need a trivial rebase.
No game data. AI-assisted (Claude Code).
🤖 Generated with Claude Code