rdna2spirv: translate image_get_lod on a cube (IMAGE-GET-LOD-CUBE) #2099

Merged
BubsMcgee merged 1 commit from upstream-pr/2099 into main 2026-12-01 15:16:57 +00:00
BubsMcgee commented 2026-11-25 20:35:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by BubsMcgee on 2026-11-25T20:35:52Z.


A cube binds as the 6-layer 2D-array view cube_coords already builds for image_sample: the query takes the projected s - 1 and t - 1 (the 2D-array u and v) and does not read the third word (8 * slice + face). a16 packs the three coordinates differently, so a16 cube stays Unsupported.

No corpus shader uses cube image_get_lod (705 in the 26,503-shader set: 702 2D, 3 2D array), so no title output changes; a 2,651-shader shard translates to byte-identical .spv before and after. Confirmed by the RDNA2 ISA MIMG GET_LOD form and the existing cube sample mapping (docs/design.md).

Claimed in the coordination issue as: IMAGE-GET-LOD-CUBE (ubiquitarianism/leonida#1608).

What and why

tools/rdna2spirv.py refused image_get_lod on every dimension but 2D and 2D array. A cube is the same 6-layer 2D-array view cube_coords uses: the hardware s and t are the projected coordinates in [1, 2] and the third word is 8 * slice + face; the LOD comes from the s/t derivatives, so the translator queries OpImageQueryLod on %simg2da at (s - 1, t - 1) and does not read the face word. This translation is byte-identical for the existing 2D and 2D-array uses. a16 cube remains refused because a16 packs the three coordinates differently.

Tested

  • tests/semantic/test_image_get_lod_cube.py: 5/5 (SPIR-V shape, source VGPRs, face word unread, refusals, spirv-as/spirv-val).
  • Full tests/semantic: 6,317 tests pass.
  • Corpus: 705 image_get_lod in the 26,503-shader set (702 2D, 3 2D array); a 2,651-shader shard translated to byte-identical .spv before and after.

GPUs tested: n/a (translator-only; CPU and spirv-as/spirv-val, no GPU needed).

AI-assisted: yes.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5498748818 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2099). Originally posted by [BubsMcgee](https://github.com/BubsMcgee) on 2026-11-25T20:35:52Z. --- A cube binds as the 6-layer 2D-array view `cube_coords` already builds for `image_sample`: the query takes the projected `s - 1` and `t - 1` (the 2D-array u and v) and does not read the third word (8 * slice + face). `a16` packs the three coordinates differently, so a16 cube stays `Unsupported`. No corpus shader uses cube `image_get_lod` (705 in the 26,503-shader set: 702 2D, 3 2D array), so no title output changes; a 2,651-shader shard translates to byte-identical `.spv` before and after. Confirmed by the RDNA2 ISA MIMG GET_LOD form and the existing cube sample mapping (`docs/design.md`). Claimed in the coordination issue as: `IMAGE-GET-LOD-CUBE` (ubiquitarianism/leonida#1608). ### What and why `tools/rdna2spirv.py` refused `image_get_lod` on every dimension but 2D and 2D array. A cube is the same 6-layer 2D-array view `cube_coords` uses: the hardware `s` and `t` are the projected coordinates in [1, 2] and the third word is 8 * slice + face; the LOD comes from the s/t derivatives, so the translator queries `OpImageQueryLod` on `%simg2da` at `(s - 1, t - 1)` and does not read the face word. This translation is byte-identical for the existing 2D and 2D-array uses. `a16` cube remains refused because a16 packs the three coordinates differently. ### Tested - `tests/semantic/test_image_get_lod_cube.py`: 5/5 (SPIR-V shape, source VGPRs, face word unread, refusals, `spirv-as`/`spirv-val`). - Full `tests/semantic`: 6,317 tests pass. - Corpus: 705 `image_get_lod` in the 26,503-shader set (702 2D, 3 2D array); a 2,651-shader shard translated to byte-identical `.spv` before and after. GPUs tested: n/a (translator-only; CPU and `spirv-as`/`spirv-val`, no GPU needed). AI-assisted: yes. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
Tauwni commented 2026-11-26 13:55:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-11-26T13:55:28Z.


Tested 1b2720ba4 merged onto main a73a57e13 (it merges cleanly), on an Apple M3 (macOS 26.5.1). I ran the full scripts/run_gpu_tests.py in auto mode, with test programs built from main. I tested the merge rather than the branch alone because a branch from before 9f98dcc61 fails ps_tex against main's vk_bindless_test (the tagged descriptor table), which says nothing about this change.

Driver main main + this PR
MoltenVK 1.4.2 195 pass, 70 skip 195 pass, 70 skip
MoltenVK, LEONIDA_W64_EMULATE=1 229 pass, 36 skip 229 pass, 36 skip
KosmicKrisp (Mesa 26.3.1) 190 pass, 73 skip 190 pass, 73 skip

The counts are identical to main on all three. No new failure. The ones left are the same on both sides: cs_fma_fused (#1724), ps_ssharp (#1774) and cs_imgatomic_ext (#1518) on MoltenVK; KosmicKrisp's (NAN)-constant fixtures (#2229) and cs_imgatomic_ext there.

AI-assisted (Claude Code). No game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7194026504 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2099#issuecomment-7194026504). Originally posted by [Tauwni](https://github.com/Tauwni) on 2026-11-26T13:55:28Z. --- Tested `1b2720ba4` merged onto `main` `a73a57e13` (it merges cleanly), on an Apple M3 (macOS 26.5.1). I ran the full `scripts/run_gpu_tests.py` in auto mode, with test programs built from `main`. I tested the merge rather than the branch alone because a branch from before `9f98dcc61` fails `ps_tex` against `main`'s `vk_bindless_test` (the tagged descriptor table), which says nothing about this change. | Driver | `main` | `main` + this PR | |---|---|---| | MoltenVK 1.4.2 | 195 pass, 70 skip | 195 pass, 70 skip | | MoltenVK, `LEONIDA_W64_EMULATE=1` | 229 pass, 36 skip | 229 pass, 36 skip | | KosmicKrisp (Mesa 26.3.1) | 190 pass, 73 skip | 190 pass, 73 skip | The counts are identical to `main` on all three. No new failure. The ones left are the same on both sides: `cs_fma_fused` (#1724), `ps_ssharp` (#1774) and `cs_imgatomic_ext` (#1518) on MoltenVK; KosmicKrisp's `(NAN)`-constant fixtures (#2229) and `cs_imgatomic_ext` there. AI-assisted (Claude Code). No game data.
aslan2142 commented 2026-12-01 11:50:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:50:19Z.

Review: COMMENTED


Draft review note: cube image_get_lod lowering (IMAGE-GET-LOD-CUBE) is cleanly scoped and currently mergeable on main, but remains a draft with no CI run. Please run CI to green and mark ready for review when you want this merged.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130664264 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2099#pullrequestreview-6130664264). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:50:19Z. **Review:** COMMENTED --- Draft review note: cube `image_get_lod` lowering (`IMAGE-GET-LOD-CUBE`) is cleanly scoped and currently mergeable on `main`, but remains a draft with no CI run. Please run CI to green and mark ready for review when you want this merged. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:19:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:19:21Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310965605 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2099#issuecomment-7310965605). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:19:21Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 13:03:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T13:03:18Z.

Review: APPROVED


Now ready for review and MERGEABLE. Clean-room verified: cube image_get_lod lowering in tools/rdna2spirv.py, docs/design.md contract update, and tests/semantic/test_image_get_lod_cube.py are clean and GPU-verified on Apple M3 (@Tauwni).

Approving — ready to merge once CI runs green on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131784620 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2099#pullrequestreview-6131784620). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T13:03:18Z. **Review:** APPROVED --- Now ready for review and `MERGEABLE`. Clean-room verified: cube `image_get_lod` lowering in `tools/rdna2spirv.py`, `docs/design.md` contract update, and `tests/semantic/test_image_get_lod_cube.py` are clean and GPU-verified on Apple M3 (`@Tauwni`). Approving — ready to merge once CI runs green on current `main`. *(AI-assisted review.)*
merzleckeier commented 2026-12-01 13:17:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:17:29Z.


Verified all three result masks for cube LOD with 1b2720ba4 + ed867d7b2. I assembled and validated six synthetic modules with spirv-as and spirv-val targeting Vulkan 1.2: masks 0x1, 0x2 and 0x3 for both 2D array and cube. Main validated the three 2D-array controls and refused the cube form. The PR validated all six and left the three array modules byte-identical to main. Each cube module read the projected coordinates and omitted the face word. All five checked-in tests also passed. This checks emitted SPIR-V, with no GPU readback in this comparison.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7312391579 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2099#issuecomment-7312391579). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T13:17:29Z. --- Verified all three result masks for cube LOD with `1b2720ba4` + `ed867d7b2`. I assembled and validated six synthetic modules with `spirv-as` and `spirv-val` targeting Vulkan 1.2: masks `0x1`, `0x2` and `0x3` for both 2D array and cube. Main validated the three 2D-array controls and refused the cube form. The PR validated all six and left the three array modules byte-identical to main. Each cube module read the projected coordinates and omitted the face word. All five checked-in tests also passed. This checks emitted SPIR-V, with no GPU readback in this comparison. AI-assisted with OpenAI Codex.
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!2099
No description provided.