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

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2099
Author: @BubsMcgee
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: rt-image-get-lod-cube


📝 Commits (1)

  • 1b2720b rdna2spirv: translate image_get_lod on a cube (IMAGE-GET-LOD-CUBE)

📊 Changes

3 files changed (+112 additions, -5 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_image_get_lod_cube.py (+91 -0)
📝 tools/rdna2spirv.py (+20 -4)

📄 Description

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.

🔄 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/2099 **Author:** [@BubsMcgee](https://github.com/BubsMcgee) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `rt-image-get-lod-cube` --- ### 📝 Commits (1) - [`1b2720b`](https://github.com/ubiquitarianism/leonida/commit/1b2720ba47531ac70cdeac93486b2cac8b63ff01) rdna2spirv: translate image_get_lod on a cube (IMAGE-GET-LOD-CUBE) ### 📊 Changes **3 files changed** (+112 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_image_get_lod_cube.py` (+91 -0) 📝 `tools/rdna2spirv.py` (+20 -4) </details> ### 📄 Description 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. --- <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#2104
No description provided.