shader: lower gfx1013 byte and bit funnel VOP3 instructions in pixel_aot #531
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!531
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-531"
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?
@Vonsek on GitHub · 2026-11-22 09:51 UTC · original
Vonsek:pixel-aot-align-perm→main· +312 −0 · 6 files · 1 commits · draftChange
tools/pixel_aot.pylowers six VOP3-only byte and bit instructions through the existingINTEGERtable, following the AMD RDNA 2 ISA reference:v_alignbit_b32,v_alignbyte_b32,v_perm_b32(helperperm_b32),v_lerp_u8(helperlerp_u8),v_sad_u8(helpersad_u8) andv_sad_u16(helpersad_u16). Alignbit/alignbyte lower to(S1 >> n) | ((S0 << 1u) << (31u - n))so no shift reaches 32 at n = 0. Perm selectors: 0-3 bytes of S1, 4-7 bytes of S0, 8-11 replicate bit 15/31/47/63 of the pair, 12 gives 0x00, 13-255 give 0xff. SAD sums wrap modulo 2^32. Source modifiers,op_sel,clamp, wrong operand counts, 33-bit immediates, unwritten registers, outstanding loads and WQM are rejected.tools/scan_unsupported_shaders.pyrecognises the new forms from the same table.v_sad_u32is left out and stays rejected (see below).Tests:
tests/pixel_aot_check.pyaddsbytes_program(k)with 10 results over SGPR, VGPR, inline and literal operands, exported byte-exact throughv_cvt_f32_ubyte0-3, checked against Python models of the ISA definitions over two input sets. New modedraw-bytes, registered aspixel_aot_bytes_hardwareandpixel_aot_bytes_warp(60 s,FORM_COVERAGE_RECORD, hardware skips with 77): 20 positive draws plus nine negative draws (five program mutations, four wrong reference models) that must reportpixel_mismatch. Controls cover the exact HLSL, helper emission, the selector table, all rejected modifiers and the neighbouringv_sad_u32,v_sad_hi_u8,v_msad_u8,v_mqsad_u32_u8,v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8,v_permlane16_b32,v_permlanex16_b32.tests/form_coverage_check.pyasserts exactly 6 new forms ingfx1013.tsvandrdna2.tsv;tests/rdna2_tools_check.pycovers the scanner.docs/experiments.md#offline-pixel-shader-recompilationdocuments it.Verification
tests/pixel_aot_check.py binary ..., the controls,form_coverage_check.py,rdna2_tools_check.py,pso_readiness_check.py,docs_links_check.py,bidi_controls_check.pyandgit diff --checkpass. Withtools/pixel_aot.pyfrommainthe new tests fail withUnsupported instruction ... v_alignbit_b32.ctest --preset dev --no-tests=error -R '^pixel_aot_(bytes_(hardware|warp)|hardware|warp)$' -Vatfd1ff6fon Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, DXC 1.9.2602.17: 4/4 passed. DXC compiled everybytes_programvariant; all 20 positive draws matched the reference and all nine negative draws reportedpixel_mismatch, on an NVIDIA GeForce RTX 5080 (driver 32.0.16.1692) and on WARP.pixel_aot_bytes_hardwaretook 7.9-8.1 s andpixel_aot_bytes_warp2.0 s, well under the 60 s timeout;pixel_aot_hardware(20.2 s) andpixel_aot_warp(5.8 s) still pass. The D3D12 debug layer was not available. The fullctest --preset dev --no-tests=errorpassed 245/245, withbvh_wave64_hardware,bvh_wave64_warpandwave_shuffle_warpskipped.Evidence and follow-up
v_sad_u32: the ISA text gives a signed difference, while the AMDGPU backend selects it for an unsigned one (umax - umin + c). They disagree for operands of different sign (e.g.0xf3a1b8eb,0x17272174), so the form stays a rejected neighbour until measured.v_alignbit_b32,v_alignbyte_b32,v_perm_b32andv_lerp_u8from #526's rejected-neighbour lists;v_sad_u32stays rejected in both. The hunks do not overlap.v_msad_u8,v_sad_hi_u8,v_qsad_pk_u16_u8,v_mqsad_*,v_permlane16_b32,v_permlanex16_b32.Lower v_alignbit_b32, v_alignbyte_b32, v_perm_b32, v_lerp_u8, v_sad_u8 and v_sad_u16 to HLSL uint expressions or small helpers that follow the RDNA 2 ISA definitions. Source modifiers, op_sel, clamp and the neighbouring byte forms, including v_sad_u32, stay rejected. A new fixture exports each of 10 results byte by byte through v_cvt_f32_ubyte0-3 for two input sets in its own CTest pair, pixel_aot_bytes_{hardware,warp}, with mutated programs and wrong reference models as negative controls. Form coverage and the shader scanner count the six forms.@tedin7 on GitHub · 2026-11-27 09:37 UTC · original
This PR now conflicts with
main. Conflicting files:CMakeLists.txtdocs/experiments.mdtests/form_coverage_check.pytests/pixel_aot_check.pytests/rdna2_tools_check.pytools/pixel_aot.pyCould you merge
maininto your branch (a merge commit, no force push needed) and resolve these? Thank you.AI-assisted; commands listed were executed locally. (
git merge-tree origin/main <head>)@Leyukaka on GitHub · 2026-11-29 10:10 UTC · original
@Vonsek status of the six forms against main
c3259f27(tools/pixel_aot.py):Already on main:
v_alignbit_b32,v_alignbyte_b32:INTEGERtable, lines 857-858 (#692,4d7eb03f).v_sad_u8,v_sad_u16: lines 882 and 884 (#1656,86ffc079).v_sad_hi_u8,v_sad_u32andv_msad_u8are also there (lines 883, 885, 886; #779,dc893933).Not on main:
v_perm_b32,v_lerp_u8: no match intools/pixel_aot.pyortests/pixel_aot_check.py.Could you narrow the branch to
v_perm_b32andv_lerp_u8and merge main? It conflicts inCMakeLists.txt,docs/experiments.md,tests/form_coverage_check.py,tests/pixel_aot_check.py,tests/rdna2_tools_check.pyandtools/pixel_aot.py.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.