Skip to content

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

Draft
BubsMcgee wants to merge 1 commit into
ProjectLeonida:mainfrom
BubsMcgee:rt-image-get-lod-cube
Draft

BubsMcgee wants to merge 1 commit into
ProjectLeonida:mainfrom
BubsMcgee:rt-image-get-lod-cube

Conversation

@BubsMcgee

@BubsMcgee BubsMcgee commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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 (#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.

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.
@Tauwni

Tauwni commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants