shader: lower gfx1013 32-bit integer comparisons in pixel_aot #301
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/306"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-21T21:38:26Z.
Change
Lower all 32 gfx1013 32-bit integer comparison forms (
v_cmp_{f,lt,eq,le,gt,ne,ge,t}_{i32,u32}in both_e32and_e64encodings) intools/pixel_aot.py.Operands are decoded via a new
int_operand()helper that reinterprets registers and constants asint(asint(...)) fori32oruint(asuint(...)/ unsigned literals) foru32, treats integer and float inline constants as their 32-bit patterns, and rejects float source modifiers (-,|x|,abs(...)),clamp, andv_cmpx_*exec-writing forms. Results feedv_cndmask_b32through the existing tracked lane-mask path in both wave32 (vcc_lo,s52) and wave64 (vcc,s[52:53]) spellings.Add control, binary assembly/disassembly, and D3D12 draw fixtures in
tests/pixel_aot_check.pyplus documentation indocs/experiments.md.Verification
Commit
9b4c89fon Linux x86_64 (Python 3.14, LLVM 23.1, g++):python3 -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy libLLVM.so: passed (assembles all 8 four-channel fixtures covering all 32v_cmp_*_{i32,u32}forms forgfx1013, extracts, disassembles, lowers, and matches source lowering).g++ -std=c++17 -O2 -Wall -Wextra -Werror) of all 8 generated shader bodies against the Python reference across all 4 input bit-pattern pairs (0x80000000vs0x00000000,0xbf800000vs0xbf800000,0x3f800000vs0xbf800000,0xc0000000vs0xbf800000): all 32 forms matched.main:tools/pixel_aot.py: rejectedv_cmp_f_i32_e32withValueError: Unsupported instruction 22: v_cmp_f_i32_e32 vcc_lo, s44, v18.python3 -B tests/docs_links_check.py,tests/bidi_controls_check.py,tests/rdna2_tools_check.py(26 ran, 1 skipped withoutLLVM_LIB), and the 5 non-iced_x86checks intests/form_coverage_check.py: all passed.offscreen_check.exeD3D12 draws locally because this environment is Linux without MSVC/DXC/Windows;check_int_predicate_draws()will execute under the Windows CI job.Evidence and follow-up
All fixtures are synthetic AMDGPU assembly programs authored inline in
tests/pixel_aot_check.pyunder the repository's MIT license. Input pairs use normal and signed-zero IEEE-754 bit patterns so denormal flushing or NaN canonicalization cannot alter the bit patterns while separating signed, unsigned, and floating-point orderings. Semantics follow the AMD RDNA Shader ISA reference.Checklist
AI-assisted: yes.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-21T21:55:38Z.
@R0Y00 I ran the Windows pixel suite with this PR’s
9b4c89fas the base and prepared a small follow-up fixture forv_cmp_lt_u32in both e32 and e64. The fixture and its documentation are available in commit425870c.The fixture reads raw DWORDs, compares both operand orders and exports the four results through
v_cndmask_b32. The CPU reference expects RGBA(0, 1, 0, 1)for0x80000000and0x7fffffff, and(0, 0, 0, 0)for equal words. It also compares0x7f800002with0x7fc00001. Quieting the first NaN while retaining its payload would reverse the unsigned order.python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM>passed with LLVM 23.1.5.ctest --preset dev --no-tests=error -R '^pixel_aot_' -Vpassed both pixel tests on Windows 11 build26300.10075. WARP (10.0.26100.10068) and Radeon RX 9060 XT (32.0.32029.2010) matched all four channels of 4,096 pixels per draw for all three inputs. The D3D12 debug layer was unavailable.v_cmp_lt_i32produced the expected mismatch at pixel(0, 0)on both adapters. All four channels flipped.b53bfb0to 99/1,968 with this PR and the follow-up fixture.The fixture is ready to cherry-pick onto this PR if you’d like to include the sign-boundary and NaN cases. AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:58:43Z.
At
9b4c89fthe merge conflicts are intests/pixel_aot_check.py. Preserve the comparison draws and existing scalar and half controls. Coordinate the identicalint_operandhelper with #308 and #310.Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-21T22:19:33Z.
Rebased onto
main(6ee2406) inde229bb, keeping all landed scalar64,v_cvt_f32_f16, andfmaak/fmamkcontrols alongside the integer comparison fixtures. Simplifiedint_operand()to delegate scalar and literal decoding to the existingscalar_u32()helper, matching the identical helper used in #308 and #310.Thanks @lambirou for testing this on Windows 11 with RX 9060 XT and WARP. Happy to keep this PR scoped to the 32 comparison forms first and take your raw-DWORD sign-boundary fixture (
425870c) as a quick follow-up once this lands.