shader: lower the 16-bit three-operand integer VOP3 ops in pixel_aot #828
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/834"
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 JB2WIN on 2026-11-23T09:56:44Z.
Change
tools/pixel_aot.pynow lowers the eight 16-bit three-operand integer VOP3 forms:v_mad_u16,v_mad_i16,v_min3_{i16,u16},v_max3_{i16,u16}andv_med3_{i16,u16}. They follow the low-16-only contract from #732. The result is tracked as a low-16 value, and the same readers as in #732 may consume it: the 16-bit ops, the 16-bit compares and SDWAWORD_0/BYTE_0/BYTE_1. Every whole-word or high-half reader stays refused.Semantics, from LLVM 15.0.7
VOP3Instructions.td:V_MAD_{U,I}16(L318-319) are selected throughTernary_i16_Pats<mul, add>(L392-393). Without clamp the result is(a*b + c) & 0xffff, and the u16 and i16 forms give the same low bits.V_{MIN3,MAX3,MED3}_{I,U}16map toAMDGPU{s,u}{min3,max3,med3}(L520-529). The signed forms sign-extend the low halves, andmed3is the median.Encodings and refusals:
v_mad_u16 v5, v1, v2, v3encodes as[0x05,0x00,0x40,0xd7,0x01,0x05,0x0e,0x04]. The translator accepts the plain spelling and_e64.clampandop_selassemble in LLVM but are refused here, since neither is modelled.Changed expectations:
v_mad_u16/v_mad_i16were listed as refused neighbours in the controls,rdna2_tools_check.pyandform_coverage_check.py. They are now supported. Their refusals are replaced by stricter ones (clamp,op_sel, operand format), and the neighboursv_mad_u32_u16,v_mad_i32_i16andv_sad_u16take their place as negative controls.Refs #669. AI-assisted (Claude Code).
Verification
Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP, at
523d9ac.Draw
draw-int16-ternary(pixel_aot_int16_ternary_{hardware,warp}): results are widened through SDWAWORD_0and checked against an independent Python reference. The six word sets separate signed from unsigned,med3frommin3/max3, and themadwrap, and the source high halves differ.Mutations. Each must mismatch, and each does:
min3/max3read as unsigned;med3read as unsigned;med3replaced bymin3;madaddend dropped;A
WORD_1widen is refused at lowering.mad_i16againstmad_u16is not a usable mutation, because both give the same low bits; an assertion pins that.Commands:
ctest --preset dev --no-tests=error -R "^pixel_aot_int16_ternary_": 2/2 passed.ctest --preset dev --no-tests=error -j4passed with no failures. The only skips were the capability skips (bvh_wave64_*,wave_shuffle_warp,spirv_minlod).form_coverage_check.py,rdna2_tools_check.py,pso_readiness_check.pyanddocs_links_check.pypass.Not covered: the high half of the destination is still not measured on hardware (#669).
🤖 Generated with Claude Code