shader: lower v_sat_pk_u8_i16 in pixel_aot #1245
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1252"
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 FAJIFBEFJHA on 2026-11-24T05:32:21Z.
Change
Add plain e32 and e64 lowering for
v_sat_pk_u8_i16inpixel_aot. The fixture previously stopped atUnsupported instruction 22: v_sat_pk_u8_i16_e32 v12, s44.The integer lowering sign-extends each packed halfword, clamps it to 0–255, and places the results in the corresponding low two bytes. AMD RDNA 2 specifies a 32-bit destination with bits 31:16 cleared. LLVM 15 declares the instruction with the
VOP_I32_I32profile, which corroborates the destination width. AMD RDNA 2 ISA, §12.8, opcode 98 · AMD signed saturation bounds · LLVM 15.0.7 TableGenThe DPP conversion was removed before #421 merged. The
low16contract in #732 covers non-packed 16-bit destinations. #779 deferred this opcode. #421 · #732 · #779Verification
Tested
d8a478b352bb706a9d00c60e8dd132ab4d147c3bbased on upstreammainat0fa43ad6216b711b8e81daf2aa04362f1cc3f99c.Windows Debug on Windows 11 x64 build
26300.9974, DXC1.8.2502.11.rdna2_tools_checkentry recorded 15 internal LLVM-dependent skips.1002:7480, driver32.0.32029.2010) and in-box WARP (1414:008c, driver10.0.26100.9818) each matched two draws and detected all three intentionally wrong references. The D3D12 debug layer was enabled and reported zero errors and warnings for those draws.git diff --checkpassed.Binary and Python checks on Ubuntu 22.04.5 x86-64 under WSL 2, LLVM
15.0.7.pixel_aotchecks passed. The binary fixture assembles and disassembles both gfx1013 encodings and checks that they lower identically to the source fixture.rdna2_tools_check.pyran 129 tests with 128 passed and one capability skip. LLVM 15 could not decodebuffer_load_format_d16_hi_xfor gfx1013.Evidence and follow-up
The fixture is synthetic assembly covered by the project's MIT license. It reads back full uint32 values from an
R32G32B32A32_UINTrender target, including an e64 instruction that overwrites its source register. The three negative controls detect swapped bytes, unsigned input handling, and stale destination bits 31:16. The draws measure the translated desktop DXIL. Reproduction notesChecklist
AI-assisted (Codex).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:39:13Z.
Review: COMMENTED
Dual-platform review of
d8a478b352bb706a9d00c60e8dd132ab4d147c3b(shader: lower v_sat_pk_u8_i16 in pixel_aot).Linux Checks (LLVM 19.1.7)
docs_links_check.py: PASS (16 Markdown files, 281 links)bidi_controls_check.py: PASS (1053 tracked files, no bidirectional controls)form_coverage_check.py: PASSpixel_aot_check.py(static): PASScheck_sat_pack_u8_lowering(): PASSsat_pack_u8_program()LLVM-19 binary round-trip (llvm-mc-19 -mcpu=gfx1013,llvm-objcopy-19,libLLVM-19.sodisassemble +translate_int): PASSgit diff --check origin/main...HEAD: PASSAGENTS.md/ title-neutrality audit: PASS (all 4 changed files are title-neutral)pixel_aot_check.py binaryandrdna2_tools_check.pyunder LLVM 19 (vs CI's LLVM 15):pixel_aot_check.py binarystopped earlier at pre-existingcheck_f16_cvt_int16_binary(v_cvt_f16_i16_e32 v1, 0xfff0), andrdna2_tools_check.pyhad 3 failures / 3 errors out of 129 tests due to LLVM 19 vs LLVM 15 assembly/disassembly differences unrelated to this PR.Windows Server 2025 (MSVC 14.44 + sccache + WARP)
Command:
run_pr_test.ps1 -Pr 1252 -Targets offscreen_check,d3d12_xs_shim -Regex pixel_aot_core_vector_warpdev(Debug): configure 1.55s, build 21.46s,ctest(pixel_aot_core_vector_warp) 1/1 Passed in 5.10srelease(/O2): configure 1.58s, build 21.27s,ctest(pixel_aot_core_vector_warp) 1/1 Passed in 4.70sCode Audit & Edge Cases (
tools/pixel_aot.py,tests/pixel_aot_check.py)uint(clamp(asint({0} << 16) >> 16, 0, 255)) | (uint(clamp(asint({0}) >> 16, 0, 255)) << 8):{0} << 16then arithmeticasint(...) >> 16sign-extendsbits[15:0]to[-32768, 32767];clamp(..., 0, 255)saturates negative inputs (-32768..-1 -> 0) and values>255 -> 255, placing the result inbits[7:0].asint({0}) >> 16sign-extendsbits[31:16]to[-32768, 32767];clamp(..., 0, 255)saturates identically and shifts intobits[15:8].lo | (hi << 8)and upper 16 bits (bits[31:16]) zeroed: verified both statically and incheck_sat_pack_u8_drawon WARP (including negative controls for swapped lanes, unsigned source, and stale upper word, plus in-placev15, v15).clamp,-v18, extra operand, 64-bit literal, SDWA) are all rejected bycheck_sat_pack_u8_lowering().