shader: lower packed 16-bit integer VOP3P instructions in pixel_aot #391
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/397"
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 KomaGuy on 2026-11-22T00:18:31Z.
Change
Lower all fourteen packed 16-bit integer
VOP3Parithmetic and shift forms intools/pixel_aot.py, covering the remaining 14VOP3Pforms on bothgfx1013andgfx1030:v_pk_add_i16,v_pk_add_u16,v_pk_sub_i16,v_pk_sub_u16,v_pk_min_i16,v_pk_min_u16,v_pk_max_i16,v_pk_max_u16,v_pk_mul_lo_u16,v_pk_mad_i16,v_pk_mad_u16,v_pk_lshlrev_b16,v_pk_lshrrev_b16, andv_pk_ashrrev_i16.op_sel(default[0, ...]) andop_sel_hi(default[1, ...]) select the low or high 16-bit half of each source operand for destination lanes 0 and 1. Shift instructions masksrc0shift counts to 4 bits (& 15) and apply logical or arithmetic 16-bit shifts tosrc1. Optionalclampsaturatesadd/sub/madto[-32768, 32767](i16) or[0, 65535](u16), whileclamponmin/max/mul_lo/shifts andneg_lo/neg_hi/float inline constants are rejected.int/uintSM 6.0 HLSL (sincemad_i16fits withinint32andmad_u16fits withinuint32without overflow).PK_INT16_BODYandcheck_pk_int16_drawintests/pixel_aot_check.pyacross 3 constant sets (exercising all 14 forms, shift counts>= 16, inline-1, signed/unsigned saturation boundaries, and cross-lane swaps, exporting all 4 bytes of the packed accumulator as exact[0, 255]integers), 5 negative mutations, and negative controls covering disallowedclamp/neg_*/float immediates, WQM, andvmcnt/lgkmcnthazards.Verification
Tested on Linux x86_64 (Python 3.13.5, LLVM 19.1.7, Clang 19.1.7) on top of
4f6c39d:python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so— passed (controls, negative controls, andllvm-mc -mcpu=gfx1013assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity forPK_INT16_BODYand all existing fixtures).python3 -B tests/ffx_dispatch_aot_check.py llvm-mc-19 llvm-objcopy-19 libLLVM-19.so— passed.python3 -B tests/script_state_check.py,tests/bcpack_check.py,tests/resource_ranges_check.py,tests/layout_chunks_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py— all passed.tools/form_coverage.pyrecords all 14 packed 16-bit integerVOP3Pforms against bothdocs/coverage/gfx1013.tsvanddocs/coverage/rdna2.tsv.PK_INT16_BODYand all 5 negative mutations (ashrrevsign fill, signed vs unsigned min,sub_u16clamp,op_selcross-lane swap,mad_i16clamp) as C++20 withclang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address— bit-exact match on all 3 constant sets and all 5 mutations caught; 0 sanitizer errors.dxc -Gis -T ps_6_0), WARP (pixel_aot_warp), and hardware (pixel_aot_hardware) checks were not run locally on Linux; relying on thebuild-and-testWindows CI job to verify DXC compilation and D3D12 WARP readback.Evidence and follow-up
tests/pixel_aot_check.pyare original MIT-licensedgfx1013assembly sequences built from source at test time.v_pk_*_f16, 5 forms), #389 (v_fma_mix*, 3 forms), and #391 (v_dot*, 7 forms) with zero opcode overlap; together the four PRs cover all 29/29VOP3Pforms on bothgfx1013andgfx1030.Checklist