Skip to content

rdna2spirv: validate buffer_atomic* vdata and reject lds/tfe modifiers - #7713

Open
DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:fix/rdna2-buffer-atomic-validation
Open

DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:fix/rdna2-buffer-atomic-validation

Conversation

@DenRakEiw

Copy link
Copy Markdown
Contributor

Claim: #7496 (comment)

Summary

  • Validate vdata register kind (vgpr) and register width (2 for cmpswap/fcmpswap, 1 for other 32-bit ops) in Gen.buffer_atomic (tools/rdna2spirv.py), raising Unsupported(op + " data") instead of hitting KeyError on non-VGPR operands or silently reading an out-of-range VGPR.
  • Reject unsupported lds and tfe modifiers with Unsupported(op + " form") across buffer_atomic, buffer_atomic_float, and buffer_atomic_x2, matching buffer_sub and global_atomic.
  • Add synthetic regression tests in tests/semantic/test_buffer_atomic_validation.py covering non-VGPR vdata, wrong VGPR widths, lds/tfe rejection across all three handlers, and valid forms validated with spirv-val --target-env vulkan1.2.

Verification

  • python -I -m unittest discover -s tests/semantic -p test_buffer_atomic_validation.py -v (with spirv-as / spirv-val from Vulkan SDK 1.4.363.0): 4/4 tests OK
  • python -I -m unittest discover -s tests/semantic -p "test_buffer_*.py" -v: 208/208 tests OK
  • python -I -m unittest discover -s tests/semantic -p "test_atomic_*.py" -v: 17/17 tests OK
  • python -I -m compileall -q tools tests and git diff --check origin/main..HEAD: clean

AI-assisted (Gemini 4 Neon).

@slint6614-dev

slint6614-dev commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Checked on Linux: merged onto main dde82f2 (merges cleanly).

  • python3 -B tests/semantic/test_buffer_atomic_validation.py → OK
  • Negative control: with tools/rdna2spirv.py reverted to main and the new test kept, 99 tests fail, so the test catches the bug.
  • 1 test is skipped here (spirv-as / spirv-val not on PATH here), so the valid-forms SPIR-V validation was not run.
    Read the diff as well; it looks right to me.

@hcampbell98

Copy link
Copy Markdown

Tested 13330f616 merged with main dde82f27e on Linux (WSL2, CPython 3.14.4 and 3.12.13, CPU only, no game files, no spirv-as/spirv-val on PATH): Pass.

Checks

  • Merge, git diff --check dde82f27e...HEAD, python3 -I scripts/check_no_game_data.py ..., and python3 -m compileall -q tools tests: clean / exit 0.
  • tests/semantic/test_buffer_atomic_validation.py:
    • CPython 3.14.4 (-I): 4 tests OK (1 skipped: spirv-as / spirv-val not on PATH).
    • CPython 3.12.13 (-I): 4 tests OK (1 skipped).
    • Venv pytest -q: 3 passed, 1 skipped, 186 subtests passed (translate() ran and asserted OpEntryPoint GLCompute for all valid ops; only spirv-as/spirv-val binary validation was skipped).
  • Related semantic & CI gates (python3 -I):
    • test_buffer_*.py: 208 tests OK (1 skipped).
    • test_atomic_*.py: 17 tests OK.
    • tests/test_semantic_translator_use.py: 3 tests OK.
    • tests/test_ci_registration.py: 14 tests OK.
    • tests/test_runner_calls_all_tests.py: 3 tests OK.
  • Negative control (tools/rdna2spirv.py restored from dde82f27e): test_buffer_atomic_validation.py fails with 85 failures and 13 errors (1 skipped) across non-VGPR vdata, wrong VGPR widths, and lds/tfe modifiers.

AI-assisted.

@morodirule

Copy link
Copy Markdown

Tested 13330f6 on Arch Linux, Python 3.14.10, CPU only: pass — first Linux check. test_buffer_atomic_validation 4/4 (186 subtests) + x2/fminmax_align 15/15 (207 subtests) OK. Negative control: pre-fix file → 98 failures; restored, green again. No game files, no GPU. AI-assisted.

@MonkeyPython

Copy link
Copy Markdown

Tested 13330f61 on NVIDIA RTX 3080 Ti (Ampere, subgroup 32..32), driver 621.24, Vulkan 1.4.357, Windows 11 (10.0.26300): pass — no regressions vs parent commit (branch base) bf85ff70. First GPU check on this PR (earlier checks were CPU-only).

Tools: llvm-mc 23.1.6 (conda-forge llvm-tools, native Windows), Vulkan SDK 1.4.363.0 (SPIRV-Tools v2026.4), MSVC 14.51 (VS 2026), Python 3.14.6.

AI-assisted (Hermes agent); all runs on the hardware above. No game files used. Cross-posted to #166.

@memorypressure

Copy link
Copy Markdown

Tested head 13330f6 vs main dde82f2 (merged tree ed62268df, clean): new test_buffer_atomic_validation Ran 4 OK; all six existing atomic suites unchanged (4-11 tests each, OK), so the stricter n==2 vdata check breaks no shipped cmpswap form. Red on clean main (checks absent); disabling all four lds/tfe guards makes it fail 56 ways — coverage confirmed — restored md5-clean. LEONIDA_TOOLS_DIR empty-dir control errors loudly, and spirv-as/spirv-val are present so the valid-forms test really assembles. Pairwise heads-up: #2956 conflicts in rdna2spirv.py/design.md/lane_masks.py if it lands second onto its stale base — clean into current main either way. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

6 participants