Skip to content

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

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
BubsMcgee:rt-image-get-lod-cube
Dec 1, 2026
Merged

aslan2142 merged 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.

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
aslan2142 marked this pull request as ready for review December 1, 2026 12:19
@aslan2142

Copy link
Copy Markdown
Collaborator

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 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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

4 participants