rdna2spirv: refuse 3D Dref c_lz samples (OLD-9845 / SHADER-1402) #1187

Open
github-bot wants to merge 2 commits from github-bot/gh-1187 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 19:50 UTC · original
ambroseautomation:carry/old-9845-dref-3d-refusal → main · +66 −8 · 5 files · 2 commits · open

Claimed in the coordination issue as: OLD-9845 (#14)

What and why

Carries forward old-pr/9845 (draft #112, original commit author ThomasSAMP preserved; indexed in #17; SHADER-1402), rebased cleanly onto current main.

Refuses 3D depth-compare c_lz texture samples in tools/rdna2spirv.py:

  • Raises Unsupported ("3D depth comparison") for image_sample_c_lz and image_sample_c_lz_o with dim:SQ_RSRC_IMG_3D, because Vulkan forbids Dref image sampling instructions on 3D images (VUID-StandaloneSpirv-OpImage-04777).
  • Adds the contract row in docs/design.md (with the 1.0.2.1 corpus count: all 15,155 image_sample_c_lz sites are 2D or 2D-array, none 3D).
  • Adds hand-written fixtures tests/semantic/fixtures/dref_3d_c_lz.asm and dref_3d_c_lz_o.asm, and updates tests/semantic/test_sample_c.py to test both the 3D refusals and continued acceptance of 2D / 2D-array forms.

Tested

  • python -m unittest discover -s tests/semantic -p test_sample_c.py -v: 10 tests, OK (1 skipped: spirv-val not on PATH).
  • python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6,170 tests, 0 files failed.
  • python -I tests/test_docs_links.py: 16 tests, OK.
  • python -I scripts/check_no_game_data.py docs/design.md tools/rdna2spirv.py tests/semantic/test_sample_c.py tests/semantic/fixtures/dref_3d_c_lz.asm tests/semantic/fixtures/dref_3d_c_lz_o.asm: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10)

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.
**@⁠ambroseautomation** on GitHub · 2026-11-24 19:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1187) `ambroseautomation:carry/old-9845-dref-3d-refusal` → `main` · +66 −8 · 5 files · 2 commits · open Claimed in the coordination issue as: OLD-9845 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Carries forward `old-pr/9845` (draft #112, original commit author `ThomasSAMP` preserved; indexed in #17; SHADER-1402), rebased cleanly onto current `main`. Refuses 3D depth-compare `c_lz` texture samples in `tools/rdna2spirv.py`: - Raises `Unsupported` (`"3D depth comparison"`) for `image_sample_c_lz` and `image_sample_c_lz_o` with `dim:SQ_RSRC_IMG_3D`, because Vulkan forbids Dref image sampling instructions on 3D images (`VUID-StandaloneSpirv-OpImage-04777`). - Adds the contract row in `docs/design.md` (with the 1.0.2.1 corpus count: all 15,155 `image_sample_c_lz` sites are 2D or 2D-array, none 3D). - Adds hand-written fixtures `tests/semantic/fixtures/dref_3d_c_lz.asm` and `dref_3d_c_lz_o.asm`, and updates `tests/semantic/test_sample_c.py` to test both the 3D refusals and continued acceptance of 2D / 2D-array forms. ### Tested - `python -m unittest discover -s tests/semantic -p test_sample_c.py -v`: 10 tests, OK (1 skipped: `spirv-val` not on PATH). - `python -I scripts/run_semantic_tests.py tests/semantic`: 470 files, 6,170 tests, 0 files failed. - `python -I tests/test_docs_links.py`: 16 tests, OK. - `python -I scripts/check_no_game_data.py docs/design.md tools/rdna2spirv.py tests/semantic/test_sample_c.py tests/semantic/fixtures/dref_3d_c_lz.asm tests/semantic/fixtures/dref_3d_c_lz_o.asm`: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:02 +00:00
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:09 UTC · original

Recommendation: [MERGE]

Reasoning: Carries #112: refuses 3D depth-compare image_sample_c_lz(_o) with Unsupported, since Vulkan forbids Dref sampling on 3D images (VUID-StandaloneSpirv-OpImage-04777); adds a contract row and fixtures. Turns invalid SPIR-V into an explicit refusal. Small and well grounded. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 3/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1187#issuecomment-7143110508) **Recommendation:** [MERGE] **Reasoning:** Carries #112: refuses 3D depth-compare `image_sample_c_lz(_o)` with `Unsupported`, since Vulkan forbids Dref sampling on 3D images (VUID-StandaloneSpirv-OpImage-04777); adds a contract row and fixtures. Turns invalid SPIR-V into an explicit refusal. Small and well grounded. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 3/10
Author
Owner

@⁠qhukz13 on GitHub · 2026-11-24 20:55 UTC · original

The refusal itself is right, but VUID-StandaloneSpirv-OpImage-04777 covers every OpImage*Dref* instruction, and on this branch (ecda3ce3c) three more 3D forms still emit one:

op, dim:SQ_RSRC_IMG_3D on this branch
image_sample_c v9, v[4:7], ... OpImageSampleDrefImplicitLod on %simg3d
image_sample_c_o v9, v[4:8], ... OpImageSampleDrefImplicitLod on %simg3d
image_sample_c_b v9, v[4:8], ... OpImageSampleDrefImplicitLod on %simg3d
image_sample_c_lz(_o) refused (this PR)
image_sample_c_l, image_sample_c_d, image_gather4_c(_lz) already refused on main

The image_sample_c module, assembled with spirv-as --target-env vulkan1.2, fails spirv-val --target-env vulkan1.2 (Vulkan SDK 1.4.363) with the same VUID the PR cites:

error: [VUID-StandaloneSpirv-OpImage-04777] In Vulkan, OpImage*Dref* instructions must not use images with a 3D Dim
  %369 = OpImageSampleDrefImplicitLod %float %363 %368 %364

So the check could key on the Dref instruction rather than on the two c_lz names, e.g. refuse any image_sample_c* with is3d, with a 3D case for _c, _c_o and _c_b next to the two new fixtures. The census in the design.md row only counts image_sample_c_lz; if the other three forms are also never 3D in the corpus, the row could say so for them too.

Checked by translating each form with support.translate_lines on the PR head and validating the image_sample_c module; no game files, no GPU. AI-assisted (Claude Code).

**@⁠qhukz13** on GitHub · 2026-11-24 20:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1187#issuecomment-7144230314) The refusal itself is right, but VUID-StandaloneSpirv-OpImage-04777 covers every `OpImage*Dref*` instruction, and on this branch (`ecda3ce3c`) three more 3D forms still emit one: | op, `dim:SQ_RSRC_IMG_3D` | on this branch | |---|---| | `image_sample_c` `v9, v[4:7], ...` | `OpImageSampleDrefImplicitLod` on `%simg3d` | | `image_sample_c_o` `v9, v[4:8], ...` | `OpImageSampleDrefImplicitLod` on `%simg3d` | | `image_sample_c_b` `v9, v[4:8], ...` | `OpImageSampleDrefImplicitLod` on `%simg3d` | | `image_sample_c_lz(_o)` | refused (this PR) | | `image_sample_c_l`, `image_sample_c_d`, `image_gather4_c(_lz)` | already refused on main | The `image_sample_c` module, assembled with `spirv-as --target-env vulkan1.2`, fails `spirv-val --target-env vulkan1.2` (Vulkan SDK 1.4.363) with the same VUID the PR cites: ``` error: [VUID-StandaloneSpirv-OpImage-04777] In Vulkan, OpImage*Dref* instructions must not use images with a 3D Dim %369 = OpImageSampleDrefImplicitLod %float %363 %368 %364 ``` So the check could key on the Dref instruction rather than on the two `c_lz` names, e.g. refuse any `image_sample_c*` with `is3d`, with a 3D case for `_c`, `_c_o` and `_c_b` next to the two new fixtures. The census in the design.md row only counts `image_sample_c_lz`; if the other three forms are also never 3D in the corpus, the row could say so for them too. Checked by translating each form with `support.translate_lines` on the PR head and validating the `image_sample_c` module; no game files, no GPU. AI-assisted (Claude Code).
Author
Owner

@⁠ambroseautomation on GitHub · 2026-11-25 12:49 UTC · original

Good catch, @⁠qhukz13 — updated on top of current main (98c2f7777): the 3D Dref refusal now checks is3d and (op == 'image_sample_c' or op.startswith('image_sample_c_')), covering image_sample_c, _c_o, _c_b, _c_b_o, _c_cl, _c_cl_o, _c_b_cl, _c_b_cl_o, _c_lz, and _c_lz_o (while leaving non-Dref 3D image_sample_cl / _cl_o accepted, and keeping image_sample_c_l's existing 2D-only refusal). Added regression cases for all 8 additional 3D Dref forms and 3D _cl/_cl_o controls in tests/semantic/test_sample_c.py and updated the docs/design.md contract row (keeping the 15,155 corpus count scoped specifically to image_sample_c_lz). Verified with test_sample_c.py, test_sample_cl.py, and test_texel_offsets.py (no game files, CPU-only). AI-assisted.

**@⁠ambroseautomation** on GitHub · 2026-11-25 12:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1187#issuecomment-7162906977) Good catch, @⁠qhukz13 — updated on top of current main (98c2f7777): the 3D Dref refusal now checks `is3d and (op == 'image_sample_c' or op.startswith('image_sample_c_'))`, covering `image_sample_c`, `_c_o`, `_c_b`, `_c_b_o`, `_c_cl`, `_c_cl_o`, `_c_b_cl`, `_c_b_cl_o`, `_c_lz`, and `_c_lz_o` (while leaving non-Dref 3D `image_sample_cl` / `_cl_o` accepted, and keeping `image_sample_c_l`'s existing 2D-only refusal). Added regression cases for all 8 additional 3D Dref forms and 3D `_cl`/`_cl_o` controls in `tests/semantic/test_sample_c.py` and updated the `docs/design.md` contract row (keeping the 15,155 corpus count scoped specifically to `image_sample_c_lz`). Verified with `test_sample_c.py`, `test_sample_cl.py`, and `test_texel_offsets.py` (no game files, CPU-only). AI-assisted.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 18:15 UTC · original · approved these changes

Approving 72e01c4. Merged into current main (b9320a1) with no conflicts. The full translator suite, including the extended test_sample_c.py, gives 490 files / 6,295 tests with only test_int32_to_f64 failing, the same baseline failure as main here (Linux, Python 3.13).

Widening the refusal to every image_sample_c* form on a 3D view is right, because VUID-StandaloneSpirv-OpImage-04777 forbids Dref on 3D whatever the LOD source. The 2D and 2D-array controls show the corpus forms still translate.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 18:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1187#pullrequestreview-6062719367) · **approved these changes** Approving 72e01c4. Merged into current main (b9320a1) with no conflicts. The full translator suite, including the extended `test_sample_c.py`, gives 490 files / 6,295 tests with only `test_int32_to_f64` failing, the same baseline failure as main here (Linux, Python 3.13). Widening the refusal to every `image_sample_c*` form on a 3D view is right, because VUID-StandaloneSpirv-OpImage-04777 forbids Dref on 3D whatever the LOD source. The 2D and 2D-array controls show the corpus forms still translate. AI-assisted (Claude).
This pull request has changes conflicting with the target branch.
  • tools/rdna2spirv.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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