spirv_metal_set0: synthesize uint, retype helper calls, expand decoration groups, and capture spirv-as stderr (SHADER-METAL-SET0-FIX) #946

Merged
hamdog0203 merged 1 commit from upstream-pr/946 into main 2026-11-28 11:41:34 +00:00
hamdog0203 commented 2026-11-24 15:33:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by hamdog0203 on 2026-11-24T15:33:24Z.


Summary

Fixes four SPIR-V / CLI edge cases in tools/spirv_metal_set0.py:

  • Synthesize a 32-bit unsigned integer type (OpTypeInt 32 0) before the first resized pointer type when a module with resized set-0 descriptor arrays does not already declare one (instead of exiting with SystemExit).
  • Propagate retyped set-0 descriptor-array pointer types transitively across OpCopyObject and OpFunctionCall into OpFunctionParameter and cloned OpTypeFunction declarations (without mutating function types shared with unresized foreign-set helpers), and fail closed on conflicting call sites or OpPhi/OpSelect pointer merges.
  • Expand OpDecorationGroup / OpGroupDecorate for both DescriptorSet 0 and Binding decorations, splitting shared Binding groups when they mix set-0 and non-set-0 targets.
  • Capture spirv-as stderr and pass explicit encoding="utf-8", errors="replace" for spirv-dis/spirv-as so cli() surfaces assembler errors and preserves UTF-8 OpNames on Windows code pages.

Verification

  • pytest tests/test_spirv_metal_set0.py -v (with Khronos SPIRV-Tools spirv-as, spirv-dis, spirv-val 1.4.363.1): 15/15 passed, 0 skipped.
  • Negative control against unpatched main (a289278): 6/7 new tests failed on main.
  • unittest tests/test_text_write_line_endings.py: 3/3 passed.
  • scripts/check_no_game_data.py: exit 0; LF-only, no BOM.

Claimed in the coordination issue as: SHADER-METAL-SET0-FIX (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136062894)
AI-assisted: yes
No game files

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475249110 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/946). Originally posted by [hamdog0203](https://github.com/hamdog0203) on 2026-11-24T15:33:24Z. --- ## Summary Fixes four SPIR-V / CLI edge cases in `tools/spirv_metal_set0.py`: - Synthesize a 32-bit unsigned integer type (`OpTypeInt 32 0`) before the first resized pointer type when a module with resized set-0 descriptor arrays does not already declare one (instead of exiting with `SystemExit`). - Propagate retyped set-0 descriptor-array pointer types transitively across `OpCopyObject` and `OpFunctionCall` into `OpFunctionParameter` and cloned `OpTypeFunction` declarations (without mutating function types shared with unresized foreign-set helpers), and fail closed on conflicting call sites or `OpPhi`/`OpSelect` pointer merges. - Expand `OpDecorationGroup` / `OpGroupDecorate` for both `DescriptorSet 0` and `Binding` decorations, splitting shared `Binding` groups when they mix set-0 and non-set-0 targets. - Capture `spirv-as` stderr and pass explicit `encoding="utf-8", errors="replace"` for `spirv-dis`/`spirv-as` so `cli()` surfaces assembler errors and preserves UTF-8 `OpName`s on Windows code pages. ## Verification - `pytest tests/test_spirv_metal_set0.py -v` (with Khronos SPIRV-Tools `spirv-as`, `spirv-dis`, `spirv-val` 1.4.363.1): **15/15 passed, 0 skipped**. - Negative control against unpatched `main` (`a289278`): 6/7 new tests failed on `main`. - `unittest tests/test_text_write_line_endings.py`: **3/3 passed**. - `scripts/check_no_game_data.py`: exit 0; LF-only, no BOM. Claimed in the coordination issue as: SHADER-METAL-SET0-FIX (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136062894) AI-assisted: yes No game files
KernelSmoker commented 2026-11-24 15:37:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T15:37:04Z.

Review: APPROVED


Verified on exact head 9c09a6749b246c3f86e9eba6dc4b6129444585cb. In a disposable Fedora 45 container with SPIRV-Tools installed, tests/test_spirv_metal_set0.py passed 15/15, including assembled and spirv-val-validated modules for synthetic uint insertion, nested helper parameter/call retyping, mixed decoration groups, and rejection of unsupported/conflicting pointer flows. tests/test_text_write_line_endings.py passed 3/3. Python compile, check_no_game_data.py, and git diff --check passed. The tests use synthetic SPIR-V only; no game data or GPU result is claimed.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6042375420 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/946#pullrequestreview-6042375420). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T15:37:04Z. **Review:** APPROVED --- Verified on exact head `9c09a6749b246c3f86e9eba6dc4b6129444585cb`. In a disposable Fedora 45 container with SPIRV-Tools installed, `tests/test_spirv_metal_set0.py` passed 15/15, including assembled and `spirv-val`-validated modules for synthetic uint insertion, nested helper parameter/call retyping, mixed decoration groups, and rejection of unsupported/conflicting pointer flows. `tests/test_text_write_line_endings.py` passed 3/3. Python compile, `check_no_game_data.py`, and `git diff --check` passed. The tests use synthetic SPIR-V only; no game data or GPU result is claimed.
sodove commented 2026-11-28 11:28:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T11:28:24Z.


#946 | head 9c09a6749b246c3f86e9eba6dc4b6129444585cb | python3 -m pytest -q -rA tests/test_spirv_metal_set0.py | red: 7 failed, 8 passed | green: 15 passed | Red → green

SPIRV-Tools were on PATH. The suite exercised the CLI and real assembly/disassembly/validation, including retyped helper calls and grouped decorations.

Copied the PR tests onto clean main 4a54aedcb6b66525e0c9f72a6ea10263337c9141 for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238574109 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/946#issuecomment-7238574109). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T11:28:24Z. --- #946 | head `9c09a6749b246c3f86e9eba6dc4b6129444585cb` | `python3 -m pytest -q -rA tests/test_spirv_metal_set0.py` | red: 7 failed, 8 passed | green: 15 passed | **Red → green** SPIRV-Tools were on PATH. The suite exercised the CLI and real assembly/disassembly/validation, including retyped helper calls and grouped decorations. Copied the PR tests onto clean main `4a54aedcb6b66525e0c9f72a6ea10263337c9141` for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7238450840).
DadaCap commented 2026-11-28 11:41:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:41:36Z.


Merged, thank you @hamdog0203! This PR (spirv_metal_set0: synthesize uint, retype helper calls, expand decoration groups, and capture spirv-as stderr (SHADER-METAL-SET0-FIX)) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238719681 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/946#issuecomment-7238719681). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T11:41:36Z. --- Merged, thank you @hamdog0203! This PR (spirv_metal_set0: synthesize uint, retype helper calls, expand decoration groups, and capture spirv-as stderr (SHADER-METAL-SET0-FIX)) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
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!946
No description provided.