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

Closed
Tortoche wants to merge 2 commits from upstream-pr/1572 into main
Tortoche commented 2026-11-25 04:47:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tortoche on 2026-11-25T04:47:50Z.


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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485358609 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1572). Originally posted by [Tortoche](https://github.com/Tortoche) on 2026-11-25T04:47:50Z. --- 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)
GeorgiyDemo commented 2026-11-25 04:50:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T04:50:14Z.


Tested 0c5605585 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main c7e82e26e (translator-only PR; binaries from the build at 66d4f5aa3):

  • python3 -m unittest test_image_coherent (from tests/semantic): OK at this head. The same file on main errors 14 times — the 2D image_load_mip + glc coherent-view path is refused there.
  • GPU regression on MoltenVK 1.4.2: --filter ps_texture 8/8 PASS, --filter ps_tex 12/12 PASS (ps_texoff/ps_texoff_implicit note the device's ±8 texel-offset limit, unchanged).
  • Not run: GPU execution of the new 2D image_load_mip glc path — there is no .asm fixture for it; the semantic suite is the evidence here.

AI-assisted; synthetic fixtures only, no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7153208639 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1572#issuecomment-7153208639). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-25T04:50:14Z. --- Tested `0c5605585` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `c7e82e26e` (translator-only PR; binaries from the build at `66d4f5aa3`): - `python3 -m unittest test_image_coherent` (from `tests/semantic`): **OK** at this head. The same file on `main` errors **14 times** — the 2D `image_load_mip` + `glc` coherent-view path is refused there. - GPU regression on **MoltenVK 1.4.2**: `--filter ps_texture` **8/8 PASS**, `--filter ps_tex` **12/12 PASS** (`ps_texoff`/`ps_texoff_implicit` note the device's ±8 texel-offset limit, unchanged). - Not run: GPU execution of the new 2D `image_load_mip` `glc` path — there is no `.asm` fixture for it; the semantic suite is the evidence here. AI-assisted; synthetic fixtures only, no game data.
MoonEyes commented 2026-11-28 02:59:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:59:53Z.


Hi @Tortoche, thanks for this pull request. It currently conflicts with main (conflicting file(s): tools/rdna2spirv.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232726757 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1572#issuecomment-7232726757). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:59:53Z. --- Hi @Tortoche, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tools/rdna2spirv.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 11:33:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:33:17Z.

Review: CHANGES_REQUESTED


Reviewed the diff against main:

  • Merge conflicts & CI: This branch conflicts with main in tools/rdna2spirv.py and has failing CI.
  • Dead leftover code: In tools/rdna2spirv.py:14616-14628 (the post-image_load_mip section of image_misc), coherent_mip = op == "image_load_mip" and "glc" in mods and its branches are dead/unreachable because if op == "image_load_mip": ... return already returned earlier at line 14535.
  • Coordination: Please rebase onto main, drop the dead hunk in image_misc, and coordinate with the carried draft #143.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130382266 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1572#pullrequestreview-6130382266). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:33:17Z. **Review:** CHANGES_REQUESTED --- Reviewed the diff against `main`: - **Merge conflicts & CI:** This branch conflicts with `main` in `tools/rdna2spirv.py` and has failing CI. - **Dead leftover code:** In `tools/rdna2spirv.py:14616-14628` (the post-`image_load_mip` section of `image_misc`), `coherent_mip = op == "image_load_mip" and "glc" in mods` and its branches are dead/unreachable because `if op == "image_load_mip": ... return` already returned earlier at line 14535. - **Coordination:** Please rebase onto `main`, drop the dead hunk in `image_misc`, and coordinate with the carried draft `#143`. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 11:52:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:52:19Z.

Review: CHANGES_REQUESTED


Keeping #1572 over closed carried-over draft #143 (OLD-9875), since this PR preserves @tedin7's authorship while adding a16 support, fixing the a[2] descriptor argument and d16 odd-component write_lo16 handling, updating docs/design.md, and expanding tests/semantic/test_image_coherent.py.

Still holding from merge pending the rebase onto main and removal of the dead leftover coherent_mip hunk in tools/rdna2spirv.py already noted in the review above.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130700634 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1572#pullrequestreview-6130700634). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:52:19Z. **Review:** CHANGES_REQUESTED --- Keeping **#1572** over closed carried-over draft **#143** (`OLD-9875`), since this PR preserves `@tedin7`'s authorship while adding `a16` support, fixing the `a[2]` descriptor argument and `d16` odd-component `write_lo16` handling, updating `docs/design.md`, and expanding `tests/semantic/test_image_coherent.py`. Still holding from merge pending the rebase onto `main` and removal of the dead leftover `coherent_mip` hunk in `tools/rdna2spirv.py` already noted in the review above. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:36:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:36:44Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317893557 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1572#issuecomment-7317893557). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:36:44Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1572
No description provided.