[PR #1572] OLD-9875: rdna2spirv: translate 2D image_load_mip glc via coherent storage view #1593

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

📋 Pull Request Information

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

Base: main ← Head: old-9875


📝 Commits (2)

  • 4e23a19 fix: translate image_load_mip glc on 2D through the coherent storage view
  • 9b1dcc1 rdna2spirv: refine coherent 2D image_load_mip typing, odd d16 high-half keep, and docs

📊 Changes

3 files changed (+150 additions, -15 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_image_coherent.py (+103 -2)
📝 tools/rdna2spirv.py (+46 -12)

📄 Description

Item ID: OLD-9875
Carries forward Draft #143 (old-pr/9875), preserving original author tedin7 (e6b7cb689), rebased onto main (364ab4eab), plus follow-up refinement 0c5605585 (image_load_mip glc on 2D via coherent storage view).
Claimed in #14: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147714743

AI-assisted: yes

Summary

  • tools/rdna2spirv.py (image_misc, image_load_mip_coherent):
    • Translate image_load_mip with glc on plain 2D images (including a16 and d16) through the coherent storage view %stv*_0 instead of rejecting it or emitting sampled OpImageFetch.
    • Keep OpImageRead on the mip == 0 branch (image_load_coherent, decorated Coherent, without setting uses_query), and zero-fill destination registers on mip != 0 via OpIEqual %bool (raw_xs[2] as %uint) + structured OpSelectionMerge/OpBranchConditional, using write_lo16 on the trailing odd d16 register so the high 16 bits are preserved.
    • Refuse image_load_mip ... glc for non-2D dimensions and tfe/lwe status forms (Unsupported).
  • tests/semantic/test_image_coherent.py:
    • Add CoherentMipLoad (8 tests: f32, negative control without glc, a16, d16 even/odd 0xFFFF0000 high-half masking on both branches), expand UnmodelledCoherentReads (2D_ARRAY, 3D, tfe, lwe), and add Validation.test_spirv_val_accepts_a_coherent_mip_load.
  • docs/design.md:
    • Update the Coherent image accesses (glc) contract row for 2D image_load_mip glc (including d16/a16/odd-component handling and explicit note that mip > 0 zero-fill on a coherent view is not yet hardware-measured).

Tests Executed & Verified (Linux x86_64 CPU; no GPU / retail game-corpus run)

  • python3 -I scripts/run_semantic_tests.py -j 2 tests/semantic: 476 files, 6232 tests, 0 files failed in 5032 s (exit 0)
  • python3 -m unittest discover -s tests/semantic -p test_image_coherent.py -v: 19/19 passed (with /usr/bin/spirv-as & /usr/bin/spirv-val), plus 18/18 refusal probes and 12/12 spirv-val adversarial probes
  • python3 -I tests/test_design_contract_rows.py -v: 5/5 passed
  • python3 -I tests/test_docs_links.py -v: 16/16 passed
  • python3 -I tests/test_docs_design_rows.py -v: 5/5 passed
  • python3 -I tests/test_text_write_line_endings.py -v: 3/3 passed
  • python3 -I tests/test_ci_registration.py -v: 16/16 passed
  • python3 -m compileall -q make_game.py tools tests: OK (exit 0)
  • python3 -I scripts/check_no_game_data.py docs/design.md tests/semantic/test_image_coherent.py tools/rdna2spirv.py: OK (exit 0, zero game data)

🔄 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/1572 **Author:** [@Tortoche](https://github.com/Tortoche) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-9875` --- ### 📝 Commits (2) - [`4e23a19`](https://github.com/ubiquitarianism/leonida/commit/4e23a198474c955566f90d596c078930cacd60d7) fix: translate image_load_mip glc on 2D through the coherent storage view - [`9b1dcc1`](https://github.com/ubiquitarianism/leonida/commit/9b1dcc11aba96ee08b96bc49bda5d75b2559fc9b) rdna2spirv: refine coherent 2D image_load_mip typing, odd d16 high-half keep, and docs ### 📊 Changes **3 files changed** (+150 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_image_coherent.py` (+103 -2) 📝 `tools/rdna2spirv.py` (+46 -12) </details> ### 📄 Description Item ID: `OLD-9875` Carries forward Draft `#143` (`old-pr/9875`), preserving original author `tedin7` (`e6b7cb689`), rebased onto `main` (`364ab4eab`), plus follow-up refinement `0c5605585` (`image_load_mip glc` on 2D via coherent storage view). Claimed in `#14`: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147714743 AI-assisted: yes ### Summary - `tools/rdna2spirv.py` (`image_misc`, `image_load_mip_coherent`): - Translate `image_load_mip` with `glc` on plain 2D images (including `a16` and `d16`) through the coherent storage view `%stv*_0` instead of rejecting it or emitting sampled `OpImageFetch`. - Keep `OpImageRead` on the `mip == 0` branch (`image_load_coherent`, decorated `Coherent`, without setting `uses_query`), and zero-fill destination registers on `mip != 0` via `OpIEqual %bool` (`raw_xs[2]` as `%uint`) + structured `OpSelectionMerge`/`OpBranchConditional`, using `write_lo16` on the trailing odd `d16` register so the high 16 bits are preserved. - Refuse `image_load_mip ... glc` for non-2D dimensions and `tfe`/`lwe` status forms (`Unsupported`). - `tests/semantic/test_image_coherent.py`: - Add `CoherentMipLoad` (8 tests: `f32`, negative control without `glc`, `a16`, `d16` even/odd `0xFFFF0000` high-half masking on both branches), expand `UnmodelledCoherentReads` (`2D_ARRAY`, `3D`, `tfe`, `lwe`), and add `Validation.test_spirv_val_accepts_a_coherent_mip_load`. - `docs/design.md`: - Update the `Coherent image accesses (glc)` contract row for 2D `image_load_mip glc` (including `d16`/`a16`/odd-component handling and explicit note that `mip > 0` zero-fill on a coherent view is not yet hardware-measured). ### Tests Executed & Verified (Linux x86_64 CPU; no GPU / retail game-corpus run) - `python3 -I scripts/run_semantic_tests.py -j 2 tests/semantic`: **476 files, 6232 tests, 0 files failed in 5032 s** (exit 0) - `python3 -m unittest discover -s tests/semantic -p test_image_coherent.py -v`: **19/19 passed** (with `/usr/bin/spirv-as` & `/usr/bin/spirv-val`), plus **18/18** refusal probes and **12/12** `spirv-val` adversarial probes - `python3 -I tests/test_design_contract_rows.py -v`: **5/5 passed** - `python3 -I tests/test_docs_links.py -v`: **16/16 passed** - `python3 -I tests/test_docs_design_rows.py -v`: **5/5 passed** - `python3 -I tests/test_text_write_line_endings.py -v`: **3/3 passed** - `python3 -I tests/test_ci_registration.py -v`: **16/16 passed** - `python3 -m compileall -q make_game.py tools tests`: **OK** (exit 0) - `python3 -I scripts/check_no_game_data.py docs/design.md tests/semantic/test_image_coherent.py tools/rdna2spirv.py`: **OK** (exit 0, zero game data) --- <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#1593
No description provided.