Skip to content

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

Draft
Andretuta wants to merge 1 commit into
mainfrom
old-pr/10022
Draft

Andretuta wants to merge 1 commit into
mainfrom
old-pr/10022

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

The resident image_load TFE path at de87b1a 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.

中文翻译

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

AI-assisted(AI 辅助)。

@GeorgiyDemo

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Tested de87b1a 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

demoz53 pushed a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
… 11) on main 8f481cf (GPU-RTX3050-LAPTOP)

run_gpu_tests.py 197/248 native and 229/248 with LEONIDA_W64_EMULATE=1; the
two tfe fixtures fail as on the other NVIDIA and Intel records and pass with
ProjectLeonida#291. Indexed in docs/gpu_test_results.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LewisCodesWebsites

Copy link
Copy Markdown

Tested de87b1a (cherry-picked onto main 21625bc) 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

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants