Repository navigation
rdna2spirv: allow packed 16-bit integer ops to read constants under op_sel and default op_sel_hi - #3368
rdna2spirv: allow packed 16-bit integer ops to read constants under op_sel and default op_sel_hi#3368sarveshgamers wants to merge 1 commit into
Conversation
…p_sel and default op_sel_hi
In VOP3P packed 16-bit integer instructions (v_pk_add/sub/mul_lo/mad/max/min), op_sel_hi defaults to [1, 1], which caused the translator to reject any instruction with a constant operand ('high half of a constant').
In RDNA2 VOP3P, an immediate constant provides a full 32-bit scalar word where bits [15:0] are half 0 and bits [31:16] are half 1. The existing OpBitFieldUExtract / OpBitFieldSExtract lowering already slices the 32-bit constant correctly for any combination of op_sel and op_sel_hi.
Remove the artificial constant restriction, expand tests/semantic/test_alu_pk_int16.py to cover constants in src0/src1 under default and swapped op_sel / op_sel_hi, and update docs/design.md.
All 4,137 semantic tests pass. Translates and validates upscaler shader amd_fidelityfx_upscaler_xbox_00.s. AI-assisted.
|
Independent AI-assisted CPU review at 83110f4 found no translator defect: seven focused tests and nine hand-calculated cases passed; all nine modules passed Vulkan 1.2 spirv-val. Eight high-half controls were rejected on parent ec8ec4c; the low-only control matched both. Coordination hold: open #2224 already removes this same guard and supplies the raw-kernel constant evidence. Please coordinate one implementation before merge. Also cite the gfx1036 constant measurements and wave64 recheck from #2224 next to this contract rule; the current gfx1035 citation establishes arithmetic/selectors rather than these newly accepted constant encodings. No GPU or game data used in this review. |
|
Tested 83110f4 against the hardware. Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE; integer op, so the float MODE does not enter): What the hardware does, which is what the PR says: an inline integer constant is a 32-bit word with its halves as given, positive ones with a zero high half ( Only |
|
Thank you @Vonsek for running the 48-case hardware oracle verification on native RDNA2 gfx1036 and confirming the 48/48 bit-exact match across modifiers and constants! And thank you @kacper-serewis for the review. Since #2224 was already opened earlier with the hardware measurement and GPU test fixture (\cs_w32_pk_int_const.asm), deferring to #2224 to avoid duplicate merges. Closing in favor of #2224. |
|
Thanks @Vonsek for the thorough 48-case RDNA2 \gfx1036\ hardware verification and @kacper-serewis for the review! Since #2224 was already opened earlier with the full GPU test fixture (\cs_w32_pk_int_const.asm), closing this PR in favor of #2224 to avoid duplicate merges. |
Summary
In VOP3P packed 16-bit integer instructions (
v_pk_add/sub_u16/i16,v_pk_mul_lo_u16,v_pk_mad_u16/i16,v_pk_max/min_u16/i16),op_sel_hidefaults to[1, 1], which previously caused the translator to reject any instruction containing a constant operand (raise Unsupported(op + " high half of a constant")).In RDNA2 VOP3P, an immediate constant provides a full 32-bit scalar word where bits [15:0] are half 0 and bits [31:16] are half 1. The existing
OpBitFieldUExtract/OpBitFieldSExtractlowering already slices the 32-bit constant correctly for any combination ofop_selandop_sel_hi:1provides0x00000001(low half 1, high half 0)-1provides0xffffffff(both halves 0xffff)0xffff0008provides low half 8, high half 0xffff)Changes
tools/rdna2spirv.py: Removed the artificial restrictionif a[1 + i]["k"] not in ("vgpr", "sgpr") and (sel[i] or selhi[i]): raise Unsupported(...).tests/semantic/test_alu_pk_int16.py:test_constantsto test inline constants with default and modifiedop_sel/op_sel_hi, negative constants, 32-bit literals in both source positions (src0andsrc1), and 3-sourcev_pk_mad_u16."v_pk_add_u16 v0, v1, 5"fromtest_rejected_forms.docs/design.md: Updated the contract row for Packed 16-bit integer ALU.Testing
python -m unittest tests/semantic/test_alu_pk_int16.py -v: 7/7 tests passed.python -m unittest discover -s tests/semantic -v: all 4,137 tests passed.python -m compileall -q make_game.py tools tests: 0 errors.spirv-val.Claimed in #3232.