Skip to content

Translator: constant and ordered/unordered VOPC compares (v_cmp_f/t/tru/o/u) - #620

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
LouisRiverstone:vopc-const-ordered
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
LouisRiverstone:vopc-const-ordered

Conversation

@LouisRiverstone

Copy link
Copy Markdown
Contributor

tools/rdna2spirv.py's compare() raises Unsupported on the VOPC conditions that aren't relations:

  • v_cmp_f_* / v_cmp_t_* on integers
  • v_cmp_f_*, v_cmp_tru_*, v_cmp_o_* and v_cmp_u_* on f32 and f16
  • the same for their v_cmpx forms

They aren't in the translated corpus, so this is future-proofing. Claimed in #374.

Change

  • tools/rdna2spirv.py, in compare():
    • f is always false, and t / tru are always true.
    • o (ordered) is true when neither source is NaN, and u (unordered) is true when either one is, using OpIsNan.
    • The result then goes through the existing path unchanged: VCC for VOPC, the named SGPR mask for VOP3, and EXEC for v_cmpx. Off lanes give 0.
    • Other conditions are unaffected. An unknown condition still raises Unsupported.
  • tests/semantic/test_vopc_const_ordered.py (new, stdlib unittest) checks lane 0's bit against a plain-Python reference:
    • all four float conditions on f32 and f16, over ±0, ±1, ±inf, quiet and signalling NaNs and denormals, with the mask preset to the opposite value
    • f / t on u32 and i32
    • the VOP3 form writing s10 and leaving VCC alone
    • v_cmpx keeping or switching off the lane

Tested

  • python -I -m unittest discover -s tests/semantic: all pass. Without the translator change, the new file has errors (Unsupported).
  • python -m compileall -q tools tests passes. Not run on a GPU, and no game files used.

AI-assisted (Claude Code): it wrote the change and the tests, and ran the checks listed above.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 68b7993a39cecbccbeb86817a98d31fbc16ec9af on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

I tested the f16 and f32 VOPC comparisons through the PR translator and Vulkan harness. Each fragment shader wrote the four predicate results (always false, always true, ordered, unordered) to separate framebuffer channels via VCC. I supplied eight operand pairs per width at draw time, including zero, one, infinity, the smallest positive subnormal bit pattern, and quiet and signaling NaN bit patterns in either operand.

All 16 draws matched the expected four-channel words in all 4,096 pixels each. Ordered was true for every non-NaN pair and unordered was true for every pair containing a NaN input. The two fragment modules and shared vertex module passed Vulkan 1.2 SPIR-V validation. This probe covers the float VCC path; integer comparisons, explicit scalar mask destinations, and EXEC-writing cmpx forms were outside the run.

AI-assisted verification.

@esteban-dcp

Copy link
Copy Markdown

Tested 68b7993 on two GPUs, Linux 7.3.5 (CachyOS): pass.

  • NVIDIA RTX 4050 Laptop (Ada), driver 620.73.04, subgroup 32: 86 shaders: 86 translated, 86 pass spirv-val; 57/83 passed, 26 wave64 skipped; with LEONIDA_W64_EMULATE=1: 83/83 passed
  • AMD Radeon 740M (RDNA3, RADV, Mesa 26.3.1), subgroup 32..64: 83/83 passed
  • This PR adds no GPU test of its own, so this checks that it breaks nothing in the existing suite on either vendor.
  • CPU: unittest discover -s tests/semantic 788 OK; tests/test_run_gpu_tests.py and tests/test_shader_checks.py OK

python -I scripts/run_gpu_tests.py --build runtime/build/linux on the PR head as-is (test programs built from this branch), VK_LOADER_DRIVERS_SELECT pinning each GPU (device line checked), VK_LOADER_LAYERS_DISABLE=~implicit~. 0 failures.

@IAmNotSiob IAmNotSiob 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.

nice, f/t/tru/o/u done right and t only exists for int and tru for float. tests pass with main (810) :) AI-assisted review (Claude Code).

@matheuskshn

Copy link
Copy Markdown
Contributor

Tested 68b7993 on Windows 11 / Python 3.12.14. All five tests in test_vopc_const_ordered.py passed, including the NaN cases, the VOP3 named-mask destination, and CMPX writing EXEC. Running the float tests with the c432cdc translator reproduced errors on the constant-false forms. AI-assisted CPU validation.

v_cmp(x)_f_* / v_cmp(x)_t_* on integers and v_cmp(x)_f / _tru / _o / _u on
f32 and f16 raised Unsupported. f is always false, t and tru always true; o
is true when neither source is NaN (OpIsNan), u when either is. The result
goes through the existing compare path (VCC, an SGPR mask, or EXEC for
v_cmpx; off lanes give 0).

tests/semantic/test_vopc_const_ordered.py checks them against a plain-Python
reference, including NaN, infinity and signalling-NaN inputs.
main pins 48557ea again since the ItsNotRexed#666-ItsNotRexed#698 merge round, while
tools/rpf9dump/Program.cs (3816356) already uses ArchiveEntry.ResourceDrawableOffset
from 917e9b9, so the Windows 'check' job fails to compile rpf9dump on every
PR. Same one-line change as ItsNotRexed#713 / ItsNotRexed#732; whichever lands first, this merges
cleanly.
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

CI note: the Windows check job failed here because main pins third_party/rpf9-explorer at 48557ea again since the #666–#698 merge round, while tools/rpf9dump/Program.cs (3816356) already uses ArchiveEntry.ResourceDrawableOffset from 917e9b9, so rpf9dump does not compile on any PR. I added the same one-line re-pin to 917e9b9 that #713 / #732 make (a separate commit, nothing else in it), so this PR gets a clean run; whichever lands first, the other merges cleanly.

@ItsNotRexed
ItsNotRexed merged commit a7c7b8c into ItsNotRexed:main Nov 22, 2026
9 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.

6 participants