Repository navigation
tools: spirv_metal_set0.py gives set 0 fixed Metal argument-buffer IDs (SHADER-161) - #1330
Conversation
|
Tested 93f81fd on Linux (WSL2 Ubuntu), Python 3.12, CPU only: pass. |
|
Heads-up on the red the test that made
|
…s (SHADER-161) SPIRV-Cross 1.4.363.0 puts every runtime descriptor array of an argument buffer at one ID and comments all but one out as "Overlapping binding", so a native Metal shader can't reach set 0's images or samplers. The tool sizes the runtime arrays from runtime/src/vulkan_bindless.h and moves each binding to its own ID range, for spirv-cross --msl-decoration-binding. The Vulkan module and layout are unchanged. All 17 set-0 test shaders convert with no overlap and compile; cs_imgstore writes all 3x64 texels correctly in a native Metal dispatch on an Apple A18 Pro. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93f81fd to
c4e8c34
Compare
|
Tested c4e8c34 on RTX 4090 (driver 621.14, 32-wide subgroups), Windows 11 26200: pass
No game files used. AI-assisted run (Claude Code). |
|
M2 data point for the CPU tests (no overlap with the A18 Pro results in the PR body). Apple M2 (Mac mini, Mac14,3), macOS 26.4 (25E246), MoltenVK 1.4.2, Homebrew llvm-mc 23.1.6, Python 3.13.18 in an isolated venv with pytest 9.2.0. Fetched head c4e8c34 into a separate read-only worktree; no edits and no pushes. pytest tests/test_spirv_metal_set0.py on that head: 3 passed in 0.02s. Not run: the PR's native Metal dispatch of cs_imgstore with the new set-0 layout. This CLT-only Mac has no metal/metalc/metallib utility and no spirv-cross on PATH, so I cannot compile MSL or build the Metal harness here. Tooling limitation, not a patch failure. No game files. |
What and why
@fruvs found that SPIRV-Cross gives overlapping argument-buffer slots to a set with several runtime descriptor arrays. With Leonida's real set 0 it's worse: SPIRV-Cross 1.4.363.0 (Tier 2,
--msl-argument-buffer-tier 1) puts every runtime array at[[id(0)]]and comments all but one out as// Overlapping binding. The MSL still compiles, but the shader can't reach its images or samplers (seen inps_tex,cs_imgload,cs_imgstore).tools/spirv_metal_set0.py, for a native Metal path only (the Vulkan module and layout don't change). It sizes set 0's runtime arrays from thebindingstable inruntime/src/vulkan_bindless.hand moves each binding to the first ID of its own range (binding b starts at the capacities of bindings 0..b-1 added up: 0, 4096, 5120, 5121, ...). Convert the result withspirv-cross ... --msl-decoration-binding, so the IDs are the same in every shader whichever bindings it uses.--print-layoutprints the table.tests/test_spirv_metal_set0.py: the capacities are read from the header, and the rewrite (sizes, IDs, hash table left a buffer) is checked.docs/design.md: one sentence in the "Images and samplers (core)" row.Tested
Apple A18 Pro, macOS 26.6.2, SPIRV-Cross 1.4.363.0, system Metal compiler (MSL 3.1).
Overlapping bindingleft.cs_imgstorewith the new layout: three 8x8 storage images bound at element 0 of IDs 7937, 8193 and 8449 (bindings 8 to 10), with an empty hash table so every lookup gives index 0. All 3x64 texels are correct (rgba8 unorm, r32 uint, r32 sint).pytest tests/test_spirv_metal_set0.py: 3 passed.Checklist
docs/design.md.AI-assisted (Claude Code): it reproduced the issue, wrote the tool and the tests, and ran everything above on the A18 Pro.
🤖 Generated with Claude Code