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

Open
github-bot wants to merge 1 commit from github-bot/gh-2099 into main AGit
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 20:35 UTC · original
BubsMcgee:rt-image-get-lod-cube → main · +112 −5 · 3 files · 1 commits · draft

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.
**@⁠BubsMcgee** on GitHub · 2026-11-25 20:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2099) `BubsMcgee:rt-image-get-lod-cube` → `main` · +112 −5 · 3 files · 1 commits · draft 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.
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).

Tests: tests/semantic/test_image_get_lod_cube.py 5/5 (shape, source VGPRs, face
word unread, refusals, spirv-val); full tests/semantic 6,317 tests pass.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:17:52 +00:00
Author
Owner

@⁠Tauwni on GitHub · 2026-11-26 13:55 UTC · original

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.

**@⁠Tauwni** on GitHub · 2026-11-26 13:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2099#issuecomment-7194026504) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2099/head:github-bot/gh-2099'
git switch 'github-bot/gh-2099'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2099'
git switch 'github-bot/gh-2099'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2099'
git switch 'github-bot/gh-2099'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2099'
git switch 'main'
git merge --squash 'github-bot/gh-2099'
git switch 'main'
git merge --ff-only 'github-bot/gh-2099'
git switch 'main'
git merge 'github-bot/gh-2099'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.