Skip to content

rdna2spirv: Unsupported, not KeyError, for an image instruction without a VGPR data operand - #3239

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:fix/mem-crash-unsupported
Nov 23, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:fix/mem-crash-unsupported

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-MEM-CRASH, #2891 (comment)

What and why

The same crash probe as for the ALU forms (#2978), over memory ops: every DS, MUBUF, MTBUF, MIMG, SMEM and FLAT/GLOBAL/SCRATCH mnemonic family with operand-width grids and single or double mutations of valid seeds (glc, slc, dlc, lds, tfe, d16, a16, unorm, lwe, r128, gds, dmask, dim, offset, offset0/1, idxen, offen, addr64, format, SGPR/VGPR/pair/off/null/m0/vcc/exec/ttmp/out-of-range operands). Only forms llvm-mc -mcpu=gfx1013 accepts were kept (about 60,000 distinct), each translated as a pixel and as a compute shader, in the source spelling and as llvm-mc -show-encoding prints it. Every exception that is not Unsupported was counted.

One class crashed: an image_* instruction whose first operand is not a VGPR range. llvm-mc accepts off, an SGPR or a constant there (image_sample off, v[1:2], s[16:23], s[24:27] dmask:0xf dim:SQ_RSRC_IMG_2D), and the translator raised KeyError: 'r' when it wrote the result: 10 of the 11 image forms in the new test did (image_sample*, image_sample_c_lz, image_sample_o, image_gather4*, image_load, image_load_mip, image_get_lod; the 11th, image_sample_l with lwe, did not crash on main). No compiler emits this form (the texels would have nowhere to go), so it now raises Unsupported (" destination" in image_op and image_get_lod, " data" in image_misc, which also covers image_store, image_get_resinfo and the atomics). Nothing else crashed: no other IndexError, KeyError or TypeError in any other op or modifier combination, printed or hand-written.

tests/semantic/test_mem_crash_forms.py translates the 11 forms and accepts only Unsupported; 10 raise KeyError on main, none after. A design.md row names the form and the probe. No new op family is touched (the MIMG _cl/compare and scratch work in flight is not affected).

Tested

  • Red/green: test_mem_crash_forms.py, 10 KeyError failures on main, OK with the change.
  • Probe, before and after: 13 crashing forms (all the image destination class) before, none after, in about 25,800 + 16,500 mutated forms and about 6,000 grid forms, pixel and compute, raw and printed.
  • python -m unittest discover -s tests/semantic, regen_fixtures.py --check, tests/test_shader_checks.py: OK.
  • No GPU run: only a form that already failed (with a crash) changes, no translated shader changes.

Checklist

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

AI-assisted.

…ut a VGPR data operand

llvm-mc accepts `off`, an SGPR or a constant where an image_* instruction names
the VGPR range of its result (image_sample off, v[1:2], ...); the translator
raised KeyError('r') when it wrote the result. image_op, image_get_lod and
image_misc now raise Unsupported. A probe of about 60,000 DS, MUBUF, MTBUF,
MIMG, SMEM and FLAT/GLOBAL/SCRATCH operand and modifier variations finds no
other crash.

AI-assisted.
docs/design.md
tools/rdna2spirv.py

AI-assisted.
@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 4c6b641 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass

  • python3 -m pytest tests/semantic/test_mem_crash_forms.py -q -> 1 passed, 11 subtests passed
  • python3 -I scripts/run_gpu_tests.py --build <build> -> 184/199 passed, 14 skipped, 0 failed (expected D3D12-owned skips)

No runtime C++ changes; GPU suite run from the PR worktree against the existing main runtime build.

AI-assisted (OpenCode).

@TreXito

TreXito commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 4c6b641f (base f847748c) on NVIDIA GeForce RTX 3060 Ti (Ampere), driver 580.173.02 (Vulkan 1.4.312), Linux (Ubuntu 26.04 container, Python 3.14.4, GCC): pass.

AI-assisted (Claude Code). Synthetic test shaders only, no game files.

@Impre-visible

Copy link
Copy Markdown

Tested 4c6b641 on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18): pass, no regression.

Native build of runtime/ from this head (Ninja, RelWithDebInfo, clang 23.1.5), llvm-mc 23.1.5, SPIRV-Tools v2026.4.

  • tests/semantic: 7323 OK
  • build.py: 224 shaders, 224 translated, 224 pass spirv-val; check.py: 139 of 174 pass, 35 skipped (wave64 without emulation, mesh fixtures)
  • run_gpu_tests.py: 204 shaders: 204 translated, 204 pass spirv-val; 153/199 passed, 46 skipped, 0 failed
  • LEONIDA_W64_EMULATE=1 run_gpu_tests.py: 184/199 passed, 15 skipped, 0 failed

AI-assisted run (Claude). Synthetic programs only, no game files involved.

@ItsNotRexed
ItsNotRexed merged commit 7663f24 into ItsNotRexed:main Nov 23, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants