Skip to content

rdna2spirv: read null as 0 in 64-bit integer VALU compares - #3367

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
s0las16:devin/1795378315-vcmp64-null-src
Nov 23, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
s0las16:devin/1795378315-vcmp64-null-src

Conversation

@s0las16

@s0las16 s0las16 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

claiming: new SHADER item — 64-bit integer v_cmp/v_cmpx (eq, ne, lt, le, gt, ge; u64/i64) reject a null source with Unsupported: <op> operand; RDNA2 reads null as 0. Fixed in tools/rdna2spirv.py with CPU semantic tests; no game files or GPU needed.

Summary

On RDNA2 the null special operand (0x7d) reads 0 as a source, also as a 64-bit operand. The 64-bit integer VALU compares in tools/rdna2spirv.py had their own operand readers that accepted VGPR/SGPR pairs and immediates only, so a legal form like v_cmp_lt_u64_e64 vcc_lo, null, v[2:3] (LLVM -mcpu=gfx1013 accepts it: [0x6a,0x00,0xe1,0xd4,0x7d,0x04,0x02,0x00]) failed translation. This is the VALU-compare counterpart of #3229 (64-bit SALU) and #3230 (f64 arithmetic).

Changes

  • tools/rdna2spirv.py: the ordered and equality 64-bit compare readers keep their VGPR-pair path and delegate SGPR pairs, immediates and null to the existing Gen.src64_data().
  • tests/semantic/test_vcmp64_null_src.py: hand-written listings, run through spirv_mini_interp, checked against independent Python expectations: null in either source, both null, signed/unsigned boundaries, e32/e64, v_cmpx EXEC narrowing with VCC preserved, inactive lanes.
  • docs/design.md: contract row for the rule.

f64 compares and v_cmp_class_f64 are untouched (still unsupported as a whole on main; separate work).

Verification (CPU only, Linux)

  • Negative control: the new test against main's translator fails (408 subtest errors, Unsupported: v_cmp*_64 operand).
  • New test: 5/5 OK. tests/semantic/test_vcmp*.py: 21/21 OK. test_vopc*.py: 5/5 OK.
  • tests/test_docs_design_rows.py: same 3 pre-existing failures as main, none new.
  • Not GPU-verified; no corpus count (no game files used).

AI-assisted (Devin).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 143d5eb 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 tests/semantic/test_vcmp64_null_src.py (from tests/semantic) — 5/5 OK
  • python3 -I scripts/run_gpu_tests.py --build /home/deck/opencode/Leonida/runtime/build — 170/185 passed, 15 skipped, 0 failed (run from PR worktree vs main runtime build; total/skip differs from current-main 175/189/14, no failures)

AI-assisted (OpenCode).

@slint6614-dev

Copy link
Copy Markdown
Contributor

Non-blocking test-coverage note: test_vcmpx_sources_and_vcc_preservation does not currently observe whether VCC is preserved. run_compare initializes VCC to all ones and every comparison is uniform across lanes; a true case therefore also passes with a stale all-ones VCC, while a false case narrows EXEC to zero and exports nothing. A mixed true/false lane case that saves VCC, restores EXEC, and checks the saved mask would verify the preservation claim. The source-reader change itself appears consistent with the existing src64_data helper.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@evilclanker9000

Copy link
Copy Markdown
Contributor

Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE; integer compare): null as a source of the 64-bit VALU compares, through raw hw_oracle kernels, one lane. v_cmp_{eq,ne,lt,le,gt,ge}_{u64,i64}_e64 s20, null, v[2:3] and ..., v[2:3], null (result read through v_cndmask_b32_e64), and the same six as v_cmpx_*_e64 (result read through the lane they leave active), with v[2:3] over the PR's five values (0, 1, 1<<32, 1<<63, all ones): 240 cases, all equal to the comparison against 0 that this PR's reference computes (signed order for i64). So null reads as zero in either operand position, cmp and cmpx, as the PR says. This PR's translation was not part of this run; the script is local, not pushed.
AI-assisted.

@chpeu

chpeu commented Nov 22, 2026

Copy link
Copy Markdown

Tested 14b9a66a on two NVIDIA cards, Linux, no game files. main f847748c is not in this branch's
history, so I ran it twice: as it stands, and re-applied on top of current main.

As it stands (14b9a66a)

  • LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux --llvm-mc /usr/lib/llvm-20/bin/llvm-mc
    → RTX 3080 170/185 passed, 15 skipped, 0 failed; RTX 5080 (LEONIDA_VK_DEVICE="RTX 5080") the same.
    The total is 185 here because the branch predates the newest fixtures; on current main this machine counts 199.
  • Your new tests/semantic/test_vcmp64_null_src.py: 6 tests OK under python -m unittest discover -s tests/semantic, the way CI runs that folder.

Re-applied on current main (git merge --no-ff --no-commit of your head into f847748c: clean, no
conflicts, your docs/design.md line and the new test both land):

  • GPU suite → 184/199 passed, 15 skipped, 0 failed on the RTX 3080 and on the RTX 5080 with the wave64
    emulation, 153/199 passed, 46 skipped without it. Those are exactly the numbers main alone gives on this
    machine, so the new fixture changes nothing on NVIDIA hardware here.
  • Build clean (cmake --build runtime/build/linux --parallel), python -m compileall -q make_game.py tools tests
    clean.

Machine: Linux Mint 22 (Ubuntu 24.04 base), NVIDIA driver 615.71.09, Vulkan 1.4.351, llvm-mc 20.1.2,
SPIRV-Tools 2025.1~rc1 (Ubuntu packages), GCC 13.3, Python 3.12.3, built with
cmake -S runtime -B runtime/build/linux -DLEONIDA_VULKAN_HEADERS_FETCH=ON. Skips are the wave64 ones (NVIDIA
subgroup is 32..32) plus the fixtures the d3d12_* tests already run. AI-assisted testing, counts read through
by hand.

@oVolkra

oVolkra commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 14b9a66 (merged onto main aa2988c) on RTX 3060 (Ampere), driver 617.14, Windows 11, MSVC 14.44, RelWithDebInfo: pass

  • ctest: 153/153 pass, also with LEONIDA_VK_VALIDATION=1 (153/153).
  • scripts/run_gpu_tests.py: native 164/210 (46 skipped), with LEONIDA_W64_EMULATE=1 195/210 (15 skipped). Same as main at aa2988c.
  • Eight *_test.exe programs that ctest does not register (d3d12_clear, tiny_game_exit_code, vk_bindless, vk_compute, vk_sampler, vk_store, vk_texture, vk_xdxr_build) were run by hand, with and without validation: same results as on main.
  • No game files used.

AI-assisted: this check was run and written with Claude Code (Anthropic) on my machine; the numbers above are its unedited output.

@ItsNotRexed
ItsNotRexed merged commit 8444bf6 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.

7 participants