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

Open
opened 2026-11-26 20:19:42 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/946
Author: @hamdog0203
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/shader-metal-set0


📝 Commits (1)

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

📊 Changes

2 files changed (+447 additions, -24 deletions)

View changed files

📝 tests/test_spirv_metal_set0.py (+281 -0)
📝 tools/spirv_metal_set0.py (+166 -24)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/946 **Author:** [@hamdog0203](https://github.com/hamdog0203) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader-metal-set0` --- ### 📝 Commits (1) - [`9c09a67`](https://github.com/ubiquitarianism/leonida/commit/9c09a6749b246c3f86e9eba6dc4b6129444585cb) spirv_metal_set0: synthesize uint, retype helper calls, expand decoration groups, and capture spirv-as stderr (SHADER-METAL-SET0-FIX) ### 📊 Changes **2 files changed** (+447 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_spirv_metal_set0.py` (+281 -0) 📝 `tools/spirv_metal_set0.py` (+166 -24) </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#984
No description provided.