Skip to content

translator: preserve 64-bit data in Gen.mov64 to/from VCC (SHADER-1263) - #8330

Open
HDFreitas wants to merge 2 commits into
ItsNotRexed:mainfrom
HDFreitas:fix/shader-1263-mov64-vcc
Open

HDFreitas wants to merge 2 commits into
ItsNotRexed:mainfrom
HDFreitas:fix/shader-1263-mov64-vcc

Conversation

@HDFreitas

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: SHADER-1263 (#8186 (comment))

What and why

Fixes SHADER-1263: Gen.mov64 in tools/rdna2spirv.py treated VCC as a lane mask even when it held 64-bit scalar data:

  • Writing s_mov_b64 vcc, s[r:r+1] when s is not a lane mask (or immediate) now stores the low and high dwords into %vcc and %vcc_hi instead of calling mask_src(s) (which turned a data pair into per-lane bits and dropped vcc_hi).
  • Reading s_mov_b64 s[r:r+1], vcc when "vcc" not in self.cur_masks now loads %vcc and %vcc_hi instead of duplicating %vcc into both halves.
  • Lane-mask moves to/from VCC keep their existing mask_src / duplicated-bit behavior.

Added regression tests in tests/semantic/test_mov64_vcc_data.py.

Tested

  • OS / Python: Arch Linux, Python 3.14 (CPU-only; no GPU or game files used)
  • Host GPU / Driver: NVIDIA GeForce RTX 3060 12 GB, nvidia-open 615.71.09
  • python3 -m compileall -q make_game.py tools tests: exit 0
  • python3 -m unittest discover -s tests/semantic -p test_mov64_vcc_data.py -v: 2/2 passed
  • python3 -m unittest discover -s tests/semantic -p "*vcc*.py" -v and "*lane_mask*.py" -v: 58/58 lane_mask tests passed + all vcc tests passed
  • python3 -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_mov64_vcc_data.py: exit 0

AI-assisted: yes

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.

@thehollowedone

Copy link
Copy Markdown

Independent Windows GPU check of e333418a on an RTX 3080 Ti (driver 621.35, MSVC 19.44, Vulkan SDK 1.4.363.0). The GPU ran 32-lane subgroups with wave64 emulation.

A synthetic compute shader moved two distinct scalar words through VCC and read back 0x11223344 and 0x55667788 in order. A separate comparison-mask control moved the mask through a scalar register pair and back into VCC. It selected the expected 19 and 7 for the true and false lanes. Both shaders passed spirv-val, and Vulkan core and synchronization validation reported zero diagnostics. Both stock tests in test_mov64_vcc_data.py also passed.

Synthetic inputs only. AI-assisted.

@al3xar al3xar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested e333418a1 on Windows 11 x64, Python 3.14, Vulkan SDK 1.4.363.0 (spirv-as / spirv-val, CPU-only, no game files): pass.

  • Merges cleanly onto upstream/main (67d877390).
  • python -I -m unittest discover -s tests/semantic -p test_mov64_vcc_data.py -v: 2/2 passed.
  • python -I -m unittest discover -s tests/semantic -p "*vcc*.py" and "*lane_mask*.py": all passed (58/58 lane-mask tests + all vcc tests).
  • Extra edge-case + SPIR-V validation check: translated both the straight data pair round-trip and a v_cmp_lt_f32 vcc, v0, v1 -> s_mov_b64 vcc, s[2:3] -> s_mov_b64 s[4:5], vcc transition; both emit OpStore %vcc_hi / OpLoad %uint %vcc_hi cleanly and pass spirv-as --target-env spv1.5 + spirv-val --target-env vulkan1.2 (exit 0).
  • Negative control (tools/rdna2spirv.py reverted to upstream/main, PR test kept): test_s_mov_b64_data_pair_through_vcc_preserves_both_halves fails as expected ('OpStore %vcc_hi' not found, exit 1).
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_mov64_vcc_data.py: clean (exit 0).

AI-assisted.

@GonZiin

GonZiin commented Nov 23, 2026

Copy link
Copy Markdown

AI-assisted review of e333418a. The focused VCC and lane-mask suites had 93 passes and one skip on Linux, with synthetic inputs only. I reproduced two regressions against merge base dde82f27e:

  • When s[2:3] holds {2, 0}, moving the pair into VCC and using it in v_cndmask_b32 makes lane 0 select the true value. The merge base selects false, as expected when only bit 1 is set. The VCC mask read needs to extract the lane’s bit from the scalar words. The same probe with s_mov_b64 exec, vcc incorrectly enables lane 0 on this head. Scalar VCC write
  • s_mov_b64 vcc, null translates as zero on the merge base and raises Unsupported: s_mov_b64 source on this head. Please cover the zero source in the new path. Move handling

@Atomic258

Copy link
Copy Markdown
Contributor

Tested e333418a on Windows Server 2022, CPython 3.13.12 / Node 24: pass

  • python -I -m unittest discover -s tests/semantic -p "test_mov64_vcc_data.py" -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@HDFreitas

Copy link
Copy Markdown
Contributor Author

Addressed @GonZiin's two findings:

  • mask_src now extracts bit lane from %vcc / %vcc_hi when "vcc" not in self.cur_masks.
  • Gen.mov64 now handles null sources (zero) for both vcc/vcc_lo and SGPR pairs.
  • Added both regression cases to tests/semantic/test_mov64_vcc_data.py (4/4 passed; test_salu_b32_lane_masks.py 8/8 passed).

@sanchaton

sanchaton commented Nov 23, 2026 •

Copy link
Copy Markdown

Tested 66e7d002f merged cleanly onto main 867d922f0 on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell, Vulkan subgroup size 32, driver 617.14, Windows 11, Python 3.14; AI-assisted): pass.

Setup: cached CI runtime-windows binaries (vk_compute_test.exe / vk_harness.exe), no llvm-mc or spirv-val installed locally (--assembler python --no-validate --disasm-dir tests/semantic/fixtures/disasm).

  • python -m unittest discover -s tests/semantic -p test_mov64_vcc_data.py -v: 4/4 passed
  • Full GPU suite with LEONIDA_W64_EMULATE=1: 96/96 translated & assembled, 96/96 passed, 0 failed (including ps_vcc_x2, cs_w64_mask_imm, cs_w64x_*, cs_wave64_ballot, cs_wm_*)

@fortkolbast1

Copy link
Copy Markdown

Tested 66e7d002f on Windows 11 26200, CPython 3.14.8, CPU only (no GPU, no game files).

  • python -m unittest discover -s tests/semantic -p test_mov64_vcc_data.py → 4 tests OK.
  • Neighbours, same tree: -p "test_*vcc*.py" → 38 tests OK; -p "test_*mov64*.py" → 4 tests OK.
  • Full translator suite, python -I scripts/run_semantic_tests.py tests/semantic: 448 files, 5960 tests, 2 files failed in 324 s with 12 jobs: test_image_atomics_guard, test_image_store_d16 — the two files that are red on main itself (867d922f0: 447 files, 5956 tests, the same two). So this PR adds 4 tests and no new failure.

No checked: on this head before this run.

Approved by @fortkolbast1. AI-assisted.

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