shader: lower 64-bit scalar ALU and 32-bit BFE in pixel_aot #275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/279"
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 MarlomMedeiros on 2026-11-21T20:15:15Z.
Change
Extends
tools/pixel_aot.pywith the 64-bit SOP1/SOP2 scalar ALU family and 32-bit scalar bitfield extracts as a non-overlapping complement to open PR #257 (pixel-aot-scalar-alu, which covers 32-bit scalar ALU,s_not_b32,s_cmp_*,s_movk_i32, and full carry/overflow/relational SCC tracking):s_cmov_b64,s_not_b64,s_brev_b64s_and_b64(general even-aligned SGPR pairs alongside the existing exec restore),s_or_b64,s_xor_b64,s_andn2_b64,s_orn2_b64s_lshl_b64,s_lshr_b64,s_ashr_i64,s_bfm_b64s_bfe_u32,s_bfe_i32Each 64-bit result lowers to an HLSL
uint2SSA local bound across an even-aligned SGPR pair (s0..s105), and each 32-bit extract lowers to auintlocal. Constant-buffer inputs are read viaasuint(params[...])and vector operands read scalar results viaasfloat(...). Inline decimal integers sign-extend to 64 bits; 32-bit hex literals zero-extend forb64operations and sign-extend fors_ashr_i64. Helper functions for shifts,s_bfm_b64, ands_bfe_*are emitted on demand so existing shaders emit unchanged HLSL.Minimal nonzero-result SCC tracking is maintained for the newly lowered SCC-writing operations so
s_cmov_b64selects between source and existing destination pairs;s_brev_b64,s_bfm_b64, ands_cmov_b64preserve SCC, ands_wqm_b64and exec-restorings_and_b64clear it.Complement split with PR #257 and out-of-scope boundaries
s_add/sub/min/max/mul/and/or/xor/andn2/orn2/lshl/lshr/ashr/cselect_*),s_not_b32,s_cmp_*, and PR #257's carry/overflow/relational SCC model remain untouched and tested as rejections here.s_and_saveexec_b64,s_or_saveexec_b64,s_andn2_saveexec_b64),exec/vcc/VGPR/m0operands, unaligned or out-of-range pairs, pending scalar load read/write overlaps, untracked SCC or unset/non-numeric destination pairs ons_cmov_b64,s_cselect_b64,s_bfe_{u,i}64,s_{nand,nor,xnor}_b64,s_cmp_eq_u64,s_bitcmp1_b64, ands_bfm_b32.Verification
bc1efe7(branched fromorigin/main496fc28)origin/main:tools/pixel_aot.pyrejectsscalar64()withUnsupported instruction 30: s_and_b64 s[72:73], s[52:53], s[54:55].scalar64()intests/pixel_aot_check.pyexercises all 14 forms across two 12-word constant sets (including NaN bit patterns, negative 64-bit inputs, zero/small/>=32/wrapped shift counts,s_bfm_b64width boundaries0,1..31,32,>32, signed/unsigneds_bfe_*foroffset + width < 32and>= 32, and SCC preservation throughs_cmov_b64,s_brev_b64, ands_bfm_b64).scalar64_reference()independently interprets the sequence in wide-integer Python and asserts all 10 observed SCC bits flip between the two constant sets, packing the 64-bit accumulator and 10 SCC bits into four exact binary16 fields (1 + k/1024). Four mutations (s_ashr_i64→s_lshr_b64,s_bfe_i32→s_bfe_u32,s_andn2_b64→s_and_b64, and replacings_cmov_b64 ..., -1with0) must each reportpixel_mismatch.26300.10075, MSVC19.52.37029.0, DXC1.9.2602.17:pixel_aot_hardware: NVIDIA GeForce RTX 5070 (10de:2f04), driver32.0.16.2135,debug_layer=enabled,debug_errors=0 debug_warnings=0,pixels=4096 channels=16384 max_absolute_error=0across all draws and both constant sets; all 4 mutations triggeredpixel_mismatch.pixel_aot_warp: Microsoft Basic Render Driver (1414:008c), driver10.0.26100.10068,debug_layer=enabled,debug_errors=0 debug_warnings=0,pixels=4096 channels=16384 max_absolute_error=0across all draws and mutations.docs_links: 10 Markdown files, 63 links checked, passed.form_coverage_check.py: passed (verifies all 14 forms againstgfx1013.tsvandrdna2.tsv, and confirms rejected neighbors stay uncovered).origin/main:SOP13/65 -> 6/65 (+3),SOP21/51 -> 11/51 (+10), totalgfx101357 -> 70 / 1968 andgfx103057 -> 70 / 1863 (+13 forms, 0 unmatched). Combined with PR #257 (+32 forms), SOP1 reaches 7/65 and SOP2 reaches 29/51.scalar64()roundtrip identically throughlibLLVM-20;scalar64()is also registered incheck_binary()for the Ubuntu LLVM 15 CI job (tests/pixel_aot_check.py binary).Evidence and open scope
-Gis -T ps_6_0compilation, bitwise D3D12 readback on hardware (RTX 5070) and WARP with debug layer enabled, and instruction-form accounting.lower()over a local set of 12,101 pixel-shader binaries,s_cmov_b64was the first unsupported instruction in 2,898 of them (24%). With this change, 2,479 of those (86%) now lower past that instruction and fail later on out-of-scope operations such asexecoperands or registers written by ops outside this scope. Two-wide scalar pairs require even alignment, matching whatllvm-mcaccepts for the ISA; the remaining rejections are the designed loud-failure boundaries.Imported from R0Y00/Xbox2Windows. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-21T20:15:26Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T20:28:14Z.
392c144conflicts intests/pixel_aot_check.py. Please keep the new single-word constant-buffer tests from #277 alongside yours. #257 also changes how scalar results and SCC are represented; when the first PR lands, please verify a 32-bit result consumed by a 64-bit operation and a 64-bit SCC producer consumed by the 32-bit select on the combined head.Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T20:38:04Z.
Rebased onto
c832696as 0107260. The single-word constant-buffer controls from #277 are kept alongsidescalar64(); bothwith_scalar_constant_reads()andscalar64()now sit incheck_binary, andctest -R '^(pixel_aot_|docs_links)'plusform_coverage_check.pypass on the combined head (RTX 5070 + WARP,max_absolute_error=0).On the representation question: this branch reads scalar state through
scalar_u32, which already accepts theparams[k].xyzwstrings the #277 path stores, so a single-words_buffer_load_dwordresult is a valid 64-bit operand here. When the first of the two PRs lands I will verify on the combined head, with fixture cases, that:s_and_b64low word and ans_bfe_*source),s_not_b64or a bitwise b64 op) feeds the 32-bit select (s_cselect_b32or thev_cndmaskpath).If #257 lands first I will fold those cases into this fixture set before re-verifying; if this one lands first the same two cases apply to the follow-up.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T20:57:24Z.
After #258 landed the new head
0107260bconflicts only intests/pixel_aot_check.py. Please preserve its truncation draw alongside the 64-bit/BFE cases; the previously agreed combined SCC checks can follow when #257 is integrated.Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T20:59:43Z.
Rebased onto
d311159as bc1efe7. Thetruncate_valuesdraw and binary registrations from #258 are preserved alongside the 64-bit/BFE fixture; bothctest -R '^(pixel_aot_|docs_links)'andform_coverage_check.pypass on the combined head. Noted on the combined SCC checks with #257: they stay queued for whichever side integrates second.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:28:10Z.
At
bc1efe7, the merge conflicts are intests/pixel_aot_check.py. Please retain the ceiling draw in the combined pixel suite. The cross-width cases with #257 remain for whichever PR lands second.Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T21:38:12Z.
Rebased onto
b53bfb0asd8bf0c0. Theceiling()draw andcheck_ceiling_drawscall are kept alongsidescalar64(), andcheck_binaryregisters bothceiling()andscalar64(); the cube and fract draws from the same wave also remain.pixel_aot_check.py drawpasses on both backends (RTX 5070 hardware + WARP,max_absolute_error=0, debug layer clean),check_controls,form_coverage_check.pyanddocs_links_check.pypass on the combined head. The binary mode still runs in CI (LLVM 15). Cross-width checks with #257 stay queued for whichever side lands second.