Skip to content

rdna2spirv: unify VGPR read/write operand analysis across liveness and interp passes - #2739

Open
Kosmabb8 wants to merge 2 commits into
ItsNotRexed:mainfrom
Kosmabb8:fix/vgpr-rw-analysis
Open

Kosmabb8 wants to merge 2 commits into
ItsNotRexed:mainfrom
Kosmabb8:fix/vgpr-rw-analysis

Conversation

@Kosmabb8

@Kosmabb8 Kosmabb8 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

The translator's VGPR operand analysis disagreed between liveness, interpolation and pristine-copy tracking. A shared read/write helper now handles swap operands, returning/non-returning atomics, partial d16 writes and implicit EXEC destinations consistently, so these passes retain the same input registers and invalidate the same overwritten copies.

Claim: #2716 (comment)

Merged upstream f847748 in aa9898a. The two conflicts were resolved through the shared helper while preserving upstream's accumulating dot-product reads. Added six opcode/encoding subcases to guard those reads.

Validation on Windows, portable CPython 3.12.10, synthetic CPU tests:

  • VGPR operand/liveness regressions: 11 passed.
  • Accumulating dot-product checks: 5 passed.
  • Interpolation sweep: 207 passed.
  • Full semantic discovery ran 7,333 tests in 886.561 seconds: 14 failures, 4 skips, 1 expected failure. All 14 failures were mutation-test child imports of test_ps_semantics: this embedded Python's ._pth ignores PYTHONPATH. No other failures occurred. A separate external harness supplying the child sys.path explicitly passed both unchanged mutation-test methods, including the baseline and all 13 sabotage cases (95.208 seconds). The unmodified full-suite run is therefore not claimed as green.
  • Compilation and scoped diff checks passed.

All 14 open account PR heads (including #3536 and #3565) merge together cleanly against that snapshot, using this repaired head. Fifteen focused test files in the combined tree passed: 298 unittest cases passed, 4 expected Windows skips, and 8 direct lane-mask checks passed. No cross-PR textual conflict, including with #2742.

No local GPU run, spirv-val/llvm-mc or retail shader corpus. AI-assisted.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 70523fbdf3ee0faace7d6ce811166f4954fd2d93 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent synthetic Vulkan check of 70523fbdf3ee0faace7d6ce811166f4954fd2d93 on Linux 7.0.0-43 (RTX 5090, NVIDIA 595.99.02, subgroup 32, LLVM 21.1.8, SPIRV-Tools 2026.1).

I drew stock ps_bary with vs_ids, then prepended v_swap_b32_e32 v0, v1 and drew again. I compared each swapped pixel against the stock pixel with both interpolated channels and raw weights exchanged, using an absolute tolerance of 1e-6.

  • The PR matched all 4,096 swapped pixels. Reversing only the translator diff made all 4,096 differ: the second interpolated channel and corresponding raw weight were zero in every pixel. The stock draw matched across both translator versions.
  • Both sets of modules passed Vulkan 1.2 SPIR-V validation. All ten focused semantic tests passed on the PR. The GPU comparison specifically covers the register swap and barycentric path.

AI-assisted verification.

@padhossein

Copy link
Copy Markdown
Contributor

Independent VGPR baseline comparison (70523fbd). The 10 targeted tests pass on this head. For an A/B control I ran the same test file with the base translator via LEONIDA_TOOLS_DIR: 33 assertions failed, including the end-to-end swapped barycentric cases and operand-role cases for non-returning atomics. This confirms those are production-translator regressions caught by the tests. Synthetic inputs only.

AI-assisted (Codex).

@sperm

sperm commented Nov 22, 2026

Copy link
Copy Markdown

Tested 70523fb on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

  • Full python -I scripts/run_gpu_tests.py (Linux build of this branch's runtime/, LEONIDA_VK_DEVICE per GPU): 170/185 passed, 15 skipped, 0 failed on both GPUs. Compared with the same suite at the merge base 4947579 on the same machine, every test has the same result.
  • python -m unittest discover -s tests/semantic: 2577 OK

No game files. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Linux (WSL2 Ubuntu, Python 3.12) and native Windows 11 (Python 3.13.1), CPU only: pass. Merges cleanly with main. tests/semantic/test_vgpr_rw_analysis.py: Linux 10 tests OK, Windows 10 tests OK, 0 skips. Negative control (tools/rdna2spirv.py restored to main, Linux): fails (33 failures across the 10 tests), so the tests exercise the real code. Trial merges: clean with #2780, #2742, #2722, #2710; #2711 (SHADER-492, also mergeable on its own) conflicts in tools/rdna2spirv.py, so whichever lands second needs a rebase.

@Kosmabb8

Copy link
Copy Markdown
Contributor Author

Conflict repair aa9898a is now pushed. It merges f847748 and preserves both the shared helper and upstream dot2c/dot8c accumulating reads. Added six opcode/encoding subcases; VGPR 11, dot-product 5 and interpolation 207 tests passed. Full semantic run: 7,333 tests; all 14 failures were embedded-Python mutation-child import failures. An external explicit-child-path rerun passed both unchanged mutation methods, baseline and all 13 sabotage cases; no other full-suite failures. Four skips and one expected failure. Updated PR body with the exact limitation rather than claiming a green full run. All account PR heads merge together cleanly in local integration. No GPU or SPIR-V tool run. 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.

5 participants