rdna2spirv: zero the tfe/lwe status VGPR on image_load and image_load_mip #291

Closed
Andretuta wants to merge 1 commit from upstream-pr/291 into main
Andretuta commented 2026-11-24 03:01:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T03:01:25Z.


Carried over from old PR 10022 by n-romanovich in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10022, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
n-romanovich: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

#8968 added cs_imgload_tfe and cs_imgload_d16_tfe on main, and both fail on an NVIDIA GeForce RTX 5060 Ti (r32 sint (sint view): 64 bad, texel(5,3) = 2071 instead of 71) because image_read_typed never wrote 0 into the trailing tfe/lwe status VGPR (vdata[data_vgprs]), leaving the seeded 0x3e8 (1000) value untouched.

Claimed in #9677.

Changes

  • tools/rdna2spirv.py: pass status=("tfe" in mods or "lwe" in mods) from image_load (typed and glc coherent) and image_load_mip (2D and 3D) into image_read_typed, and write 0 to vdata[data_vgprs] ((popcount(dmask) + 1) // 2 under d16, else popcount(dmask)) via self.dst(...) so inactive lanes stay preserved.
  • tests/semantic/test_image_load_tfe.py: unit tests covering tfe, lwe, d16 packing (dmask:0x3, 0x7), glc, and 2D/3D image_load_mip.
  • docs/design.md: document the tfe/lwe status VGPR rule under Typed image loads.

Tested

  • GPU / driver / OS: NVIDIA GeForce RTX 5060 Ti, NVIDIA 610.88, Windows 11 (Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, Python 3.14.4)
  • python -I scripts/run_gpu_tests.py --build runtime/build --filter imgload: 4/4 passed (cs_imgload, cs_imgload_d16, cs_imgload_tfe, cs_imgload_d16_tfe; 4/4 spirv-val) — previously 2/4 (cs_imgload_tfe and cs_imgload_d16_tfe failed with 2071)
  • python -m unittest discover -s tests/semantic -p test_image_load_tfe.py: 3/3 passed
  • python -m unittest discover -s tests/semantic -p test_mem_crash_forms.py: 1/1 passed
  • python -m unittest discover -s tests/semantic -p test_image_coherent.py: 10/10 passed (1 skipped)
  • python -I tests/test_image_load_typed.py: 23/23 passed (2 skipped)
  • python -m compileall -q make_game.py tools tests and python -I scripts/check_no_game_data.py ...: passed
  • Synthetic inputs only, no game files.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465268298 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/291). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T03:01:25Z. --- > Carried over from **old PR 10022** by `n-romanovich` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10022`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `n-romanovich`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): `#8968` added `cs_imgload_tfe` and `cs_imgload_d16_tfe` on `main`, and both fail on an NVIDIA GeForce RTX 5060 Ti (`r32 sint (sint view): 64 bad, texel(5,3) = 2071` instead of `71`) because `image_read_typed` never wrote `0` into the trailing `tfe`/`lwe` status VGPR (`vdata[data_vgprs]`), leaving the seeded `0x3e8` (`1000`) value untouched. Claimed in `#9677`. ### Changes - `tools/rdna2spirv.py`: pass `status=("tfe" in mods or "lwe" in mods)` from `image_load` (typed and `glc` coherent) and `image_load_mip` (2D and 3D) into `image_read_typed`, and write `0` to `vdata[data_vgprs]` (`(popcount(dmask) + 1) // 2` under `d16`, else `popcount(dmask)`) via `self.dst(...)` so inactive lanes stay preserved. - `tests/semantic/test_image_load_tfe.py`: unit tests covering `tfe`, `lwe`, `d16` packing (`dmask:0x3`, `0x7`), `glc`, and 2D/3D `image_load_mip`. - `docs/design.md`: document the `tfe`/`lwe` status VGPR rule under `Typed image loads`. ### Tested - GPU / driver / OS: NVIDIA GeForce RTX 5060 Ti, NVIDIA 610.88, Windows 11 (Vulkan SDK 1.4.363.0, `llvm-mc 21.1.8`, Python 3.14.4) - `python -I scripts/run_gpu_tests.py --build runtime/build --filter imgload`: **4/4 passed** (`cs_imgload`, `cs_imgload_d16`, `cs_imgload_tfe`, `cs_imgload_d16_tfe`; 4/4 `spirv-val`) — previously 2/4 (`cs_imgload_tfe` and `cs_imgload_d16_tfe` failed with `2071`) - `python -m unittest discover -s tests/semantic -p test_image_load_tfe.py`: 3/3 passed - `python -m unittest discover -s tests/semantic -p test_mem_crash_forms.py`: 1/1 passed - `python -m unittest discover -s tests/semantic -p test_image_coherent.py`: 10/10 passed (1 skipped) - `python -I tests/test_image_load_typed.py`: 23/23 passed (2 skipped) - `python -m compileall -q make_game.py tools tests` and `python -I scripts/check_no_game_data.py ...`: passed - Synthetic inputs only, no game files. AI-assisted.
tahffo68hk-hash commented 2026-11-24 03:38:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tahffo68hk-hash on 2026-11-24T03:38:38Z.


The resident image_load TFE path at de87b1a9 still writes zero to the appended status VGPR. The #98 review found that this changes observable results: GFX1036 preserved the seeded status, and the RTX 5060 Ti negative control returned 0 instead of 0x5a5a03f5 while still fetching 0x64. #98 was closed after that review. Could we keep the resident TFE status write out of this PR until the fixture and translator agree? The experiment covers resident image_load TFE only. Sparse NACK, LWE and other instruction variants remain unverified.

AI-assisted.

中文翻译

de87b1a9 仍会在常驻 image_load TFE 路径将追加状态 VGPR 写成零。#98 审查中,GFX1036 保留了预置状态字;RTX 5060 Ti 负对照仍读到数据 0x64,但状态从 0x5a5a03f5 变成了零。#98 随后关闭。建议暂缓此 PR 中常驻 TFE 状态字的写入,等测试与翻译规则一致再处理。实验仅覆盖常驻 image_load TFE,稀疏 NACK、LWE 和其他指令变体尚未验证。

AI-assisted(AI 辅助)。

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7121287498 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/291#issuecomment-7121287498). Originally posted by [tahffo68hk-hash](https://github.com/tahffo68hk-hash) on 2026-11-24T03:38:38Z. --- The resident image_load TFE path at de87b1a9 still writes zero to the appended status VGPR. The [#98 review](https://github.com/ubiquitarianism/leonida/pull/98#pullrequestreview-6033017384) found that this changes observable results: GFX1036 preserved the seeded status, and the RTX 5060 Ti negative control returned 0 instead of 0x5a5a03f5 while still fetching 0x64. #98 was closed after that review. Could we keep the resident TFE status write out of this PR until the fixture and translator agree? The experiment covers resident image_load TFE only. Sparse NACK, LWE and other instruction variants remain unverified. AI-assisted. <details> <summary>中文翻译</summary> de87b1a9 仍会在常驻 image_load TFE 路径将追加状态 VGPR 写成零。#98 审查中,GFX1036 保留了预置状态字;RTX 5060 Ti 负对照仍读到数据 0x64,但状态从 0x5a5a03f5 变成了零。#98 随后关闭。建议暂缓此 PR 中常驻 TFE 状态字的写入,等测试与翻译规则一致再处理。实验仅覆盖常驻 image_load TFE,稀疏 NACK、LWE 和其他指令变体尚未验证。 AI-assisted(AI 辅助)。 </details>
GeorgiyDemo commented 2026-11-24 07:32:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-24T07:32:26Z.


Tested de87b1a9 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main d42773d07:

  • main: cs_imgload_tfe and cs_imgload_d16_tfe FAIL on both drivers with r32 sint (sint view): 64 bad, texel(5,3) = 2071; cs_imgload and cs_imgload_d16 pass (2/4 on MoltenVK 1.4.2 and on KosmicKrisp Mesa 26.3.1).
  • This head: 4/4 pass on both drivers, same words.
  • tests/semantic/test_image_load_tfe.py: 3 tests OK.

Note: the PR currently shows CONFLICTING against main; this check is on the head as-is, with binaries from main (only the translator changed). llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125102316 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/291#issuecomment-7125102316). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-24T07:32:26Z. --- Tested `de87b1a9` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `d42773d07`: - **`main`:** `cs_imgload_tfe` and `cs_imgload_d16_tfe` FAIL on both drivers with `r32 sint (sint view): 64 bad, texel(5,3) = 2071`; `cs_imgload` and `cs_imgload_d16` pass (2/4 on MoltenVK 1.4.2 and on KosmicKrisp Mesa 26.3.1). - **This head:** 4/4 pass on both drivers, same words. - `tests/semantic/test_image_load_tfe.py`: 3 tests OK. Note: the PR currently shows CONFLICTING against `main`; this check is on the head as-is, with binaries from `main` (only the translator changed). llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.
trigger337 commented 2026-11-24 08:19:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T08:19:16Z.


Tested de87b1a9ea on AMD Radeon RX 6900 XT (RADV Navi 21, Mesa 26.2.5, Linux 7.3.1 CachyOS): pass

  • scripts/run_gpu_tests.py --build runtime/build/linux --filter imgload: 4/4 passed
    • cs_imgload: pass
    • cs_imgload_d16: pass
    • cs_imgload_d16_tfe: pass (clears the 64 bad texels / 2071 vs 71 failure on main)
    • cs_imgload_tfe: pass (clears the 64 bad texels / 2071 vs 71 failure on main)
  • python -m unittest discover -s tests/semantic -p test_image_load_tfe.py: 3/3 passed
  • python -m unittest discover -s tests/semantic -p test_image_coherent.py: 10/10 passed
  • python -m unittest tests/test_image_load_typed.py: 23/23 passed
  • Full GPU test suite (run_gpu_tests.py): 229/248 passed, 16 skipped

Confirms fix for issue #31 on discrete RDNA2 desktop hardware under Linux Mesa RADV.

AI-assisted: yes
agent: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125991312 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/291#issuecomment-7125991312). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T08:19:16Z. --- Tested de87b1a9ea on AMD Radeon RX 6900 XT (RADV Navi 21, Mesa 26.2.5, Linux 7.3.1 CachyOS): pass - `scripts/run_gpu_tests.py --build runtime/build/linux --filter imgload`: **4/4 passed** - `cs_imgload`: pass - `cs_imgload_d16`: pass - `cs_imgload_d16_tfe`: pass (clears the 64 bad texels / 2071 vs 71 failure on main) - `cs_imgload_tfe`: pass (clears the 64 bad texels / 2071 vs 71 failure on main) - `python -m unittest discover -s tests/semantic -p test_image_load_tfe.py`: 3/3 passed - `python -m unittest discover -s tests/semantic -p test_image_coherent.py`: 10/10 passed - `python -m unittest tests/test_image_load_typed.py`: 23/23 passed - Full GPU test suite (`run_gpu_tests.py`): 229/248 passed, 16 skipped Confirms fix for issue #31 on discrete RDNA2 desktop hardware under Linux Mesa RADV. AI-assisted: yes agent: yes
LewisCodesWebsites commented 2026-11-24 11:53:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LewisCodesWebsites on 2026-11-24T11:53:46Z.


Tested de87b1a9e (cherry-picked onto main 21625bca8) on AMD Radeon 660M (RDNA2 iGPU, gfx1035), Adrenalin 32.0.21045.1000, Windows 11 26200: cs_imgload_tfe and cs_imgload_d16_tfe pass 2/2 on the GPU (texel(5,3) = 71, 0 bad; on main both fail with 64 bad, texel(5,3) = 2071), and test_image_load_tfe.py passes 3/3. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7130689728 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/291#issuecomment-7130689728). Originally posted by [LewisCodesWebsites](https://github.com/LewisCodesWebsites) on 2026-11-24T11:53:46Z. --- Tested de87b1a9e (cherry-picked onto main 21625bca8) on AMD Radeon 660M (RDNA2 iGPU, gfx1035), Adrenalin 32.0.21045.1000, Windows 11 26200: `cs_imgload_tfe` and `cs_imgload_d16_tfe` pass 2/2 on the GPU (texel(5,3) = 71, 0 bad; on main both fail with 64 bad, texel(5,3) = 2071), and `test_image_load_tfe.py` passes 3/3. AI-assisted.
LewisStephens99 commented 2026-11-24 14:23:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LewisStephens99 on 2026-11-24T14:23:31Z.


Additional independent validation on NVIDIA RTX A2000 12GB, Windows 11, Vulkan 1.4.363, NVIDIA driver 32.0.16.2114, LLVM 21.1.8:nn- python -I scripts/run_gpu_tests.py --build runtime/build/vulkan --work <work> --filter imgload: 4/4 passed (cs_imgload, cs_imgload_d16, cs_imgload_tfe, cs_imgload_d16_tfe), all 4 translated and spirv-val clean.n- tests/semantic/test_image_load_tfe.py: 3/3 passed.n- tests/test_image_load_typed.py: 23/23 passed.n- compileallandcheck_no_game_data.py: passed.n`nNo game files or retail assets used. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7134297562 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/291#issuecomment-7134297562). Originally posted by [LewisStephens99](https://github.com/LewisStephens99) on 2026-11-24T14:23:31Z. --- Additional independent validation on NVIDIA RTX A2000 12GB, Windows 11, Vulkan 1.4.363, NVIDIA driver 32.0.16.2114, LLVM 21.1.8:`n`n- `python -I scripts/run_gpu_tests.py --build runtime/build/vulkan --work <work> --filter imgload`: 4/4 passed (`cs_imgload`, `cs_imgload_d16`, `cs_imgload_tfe`, `cs_imgload_d16_tfe`), all 4 translated and spirv-val clean.`n- `tests/semantic/test_image_load_tfe.py`: 3/3 passed.`n- `tests/test_image_load_typed.py`: 23/23 passed.`n- `compileall` and `check_no_game_data.py`: passed.`n`nNo game files or retail assets used. AI-assisted.
aslan2142 commented 2026-12-01 12:00:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:00:29Z.

Review: COMMENTED


Draft review against current main: zeroing the tfe/lwe status VGPR on image_load/image_load_mip in tools/rdna2spirv.py:13238 is clean-room verified, but this branch conflicts with main and has cancelled CI. Please rebase onto current main and mark Ready for Review so CI runs green.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130847623 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/291#pullrequestreview-6130847623). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:00:29Z. **Review:** COMMENTED --- Draft review against current `main`: zeroing the `tfe`/`lwe` status VGPR on `image_load`/`image_load_mip` in `tools/rdna2spirv.py:13238` is clean-room verified, but this branch conflicts with `main` and has cancelled CI. Please rebase onto current `main` and mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:17:40 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310926838 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/291#issuecomment-7310926838). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:17:40Z. --- 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 commented 2026-12-01 12:59:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:59:09Z.

Review: CHANGES_REQUESTED


Now ready for review, requesting changes before merge:

  • Merge conflicts (CONFLICTING/DIRTY): conflicts with main in docs/design.md, tests/semantic/test_image_load_tfe.py, and tools/rdna2spirv.py.
  • CI: all checks from 2026-11-24 were cancelled. Please rebase onto current main and run fresh green CI.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131720623 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/291#pullrequestreview-6131720623). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:59:09Z. **Review:** CHANGES_REQUESTED --- Now ready for review, requesting changes before merge: - **Merge conflicts (`CONFLICTING`/`DIRTY`)**: conflicts with `main` in `docs/design.md`, `tests/semantic/test_image_load_tfe.py`, and `tools/rdna2spirv.py`. - **CI**: all checks from 2026-11-24 were cancelled. Please rebase onto current `main` and run fresh green CI. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:29:25 +00:00 (Migrated from github.com)

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


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:7317692213 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/291#issuecomment-7317692213). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:29:25Z. --- 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!291
No description provided.