shader: lower v_alignbit_b32 and v_alignbyte_b32 in pixel_aot #686
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/692"
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 Holastor on 2026-11-22T20:37:47Z.
Summary
Lower 3-operand vector alignment instructions
v_alignbit_b32andv_alignbyte_b32intools/pixel_aot.pyand recognize them intools/scan_unsupported_shaders.py:v_alignbit_b32: concatenates 32-bit sources{S0, S1}into a 64-bit word, shifts right by(S2 & 31u), and returns the low 32 bits.v_alignbyte_b32: concatenates 32-bit sources{S0, S1}into a 64-bit word, shifts right by((S2 & 3u) * 8u), and returns the low 32 bits.KNOWN_RDNA2_BASE_OPCODESintools/scan_unsupported_shaders.py.tests/pixel_aot_check.py.tests/rdna2_tools_check.py.Evidence
Observed result:
tests/pixel_aot_check.py: all assertions and negative controls passed.tests/rdna2_tools_check.py: 52 tests passed (1 capability skip).tests/pixel_aot_check.py:ValueError.v256raisesValueError.abs, negation,clamp) raiseValueError.tests/rdna2_tools_check.py:_e32suffix on 3-operand alignment instructions correctly rejected.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T23:59:48Z.
Review: COMMENTED
Re-reviewed
a7868f1. My earlier fixture request is satisfied: the LLVM 15 job runs the source-built binary round trip, and the dedicatedpixel_aot_align_warptest passed in both Windows jobs in run 45085060300. The UINT draws cover asymmetric words, zero shifts, bit 31/32 and byte 3/4 boundaries and swapped-word mismatch references. The readback establishes the desktop lowering for those inputs.Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-22T21:46:06Z.
Verdict: Request changes (reviewed head
80ea93309a06efbdaf1cc54ab11313420c377d5d, compared againstmainba329ec).Verification
Environment: Windows 11 x64, Python 3.12.10, DXC (
C:\VulkanSDK\1.4.363.0\Bin\dxc.exe) for offline HLSL-to-DXIL compilation, and WSL Archllvm-mc23.1.5 (-triple=amdgcn--amdpal -mcpu=gfx1013) for ISA checks. Zero-GPU review (no WARP or hardware draw executed).Commands and results on
80ea933:python -B tests/pixel_aot_check.py: passed (exit 0).python -B tests/rdna2_tools_check.py: 52 passed, 1 skipped (test_llvm_comparison, skipped becauseLLVM_LIBis not set on Windows).python -B tests/docs_links_check.pyandpython -B tests/bidi_controls_check.py: both passed.git merge-tree --write-tree main 80ea933: clean againstba329ec(exit 0).main(ba329ec): bothv_alignbit_b32andv_alignbyte_b32were absent frompixel_aot.INTEGERand returnedFalseforis_opcode_recognized()andis_instruction_supported().What checked out cleanly:
{S0, S1} >> (S2 & 31)(v_alignbit_b32) and{S0, S1} >> ((S2 & 3) * 8)(v_alignbyte_b32) across 2,304(s0, s1, s2)combinations (s2in0..63, edge bit patterns) against the HLSL expressions: 0 mismatches.dxc -T ps_6_0 -E main -WXandps_6_6 -WX(bothalign_integer_group()and a separate live-export program with constantshift=0,4,32and dynamics46): exit 0, 0 warnings/errors. In the emitted DXIL IR for dynamic shifts, DXC preserves an expliciticmp eq ..., 0branch +phiselectingsrc1, avoiding undefined shift-by-32.llvm-mc -mcpu=gfx1013 -show-encoding): Confirmedv_alignbit_b32(0xd54e...) andv_alignbyte_b32(0xd54f...) assemble with unsuffixed and_e64spellings, and thatllvm-mcrejects_e32(error: e32 variant of this instruction is not supported).Issues to address
No executable draw coverage and
v_alignbit_b32is dead-code-eliminated inalign_integer_group()(seconding @Joacoorandom's review with DXIL evidence):align_integer_group()is only exercised by static HLSL string assertions incheck_controls().align_integer_group()writesv12..v15withv_alignbit_b32and then immediately overwritesv12..v15withv_alignbyte_b32, compilingalign_integer_group()withdxceliminates all fourv_alignbit_b32operations from the DXIL (only the byte-align shifts remain).Translator accepts invalid
_e32suffix on VOP3-only 3-operand instructions:tools/scan_unsupported_shaders.pyrejectsv_alignbit_b32_e32andv_alignbyte_b32_e32(tested intests/rdna2_tools_check.py), matchingllvm-mc -mcpu=gfx1013.tools/pixel_aot.py:1968matchesrf"v_({'|'.join(INTEGER)})(?:_e32|_e64)? (v\d+), (.+)"unconditionally, sopixel_aotcurrently accepts bothv_alignbit_b32_e32 v12, s44, v18, 4andv_alignbyte_b32_e32 v12, s44, v18, 1.pixel_aot.pyand rejecting_e32whenarity > 2(and adding_e32rejection controls tobad_alignintests/pixel_aot_check.py).(Non-blocking note:
scan_unsupported_shaders.is_instruction_supported()also returnsTruefor out-of-range registers likev256/s106, which is pre-existing acrossINTEGERentries and out of scope here.)AI-assisted review (local Python, offline DXC/DXIL, and
llvm-mcchecks executed locally).Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-22T21:37:10Z.
Review of
80ea93309a06efbdaf1cc54ab11313420c377d5d: the Python controls pass, but the new align operations have no observable draw coverage yet.align_integer_group()is only called fromcheck_controls(), where the assertions inspect generated HLSL. It is not dispatched by a draw test or assembled by the binary fixture checks. Also, its fourv_alignbit_b32results in v12–v15 are overwritten by the fourv_alignbyte_b32instructions before export, so simply drawing that program would still not verify alignbit.Suggested fixture split:
((src0 << 32) | src1) >> shift, truncated to 32 bits, with the appropriate masked shift.That would test DXC/runtime semantics and provide evidence for the coverage chart instead of counting acceptance or HLSL spelling alone. Local validation performed:
python3 -B tests/pixel_aot_check.py(pass); no native GPU execution in this review.Implementation: commit dd760a2, submitted directly against this PR's
shader/valu-alignbitbranch as Holastor/Xbox2Windows#1. It splits the observable programs, adds both to the binary round trip, and wires 48 exact-reference rows plus corrupted-reference/source-order mutations into the existing UINT draw tests. All four CI jobs in the linked follow-up passed: LLVM 15 assembly/translation, Linux Python checks, Windows development/WARP, and Windows release/WARP at /O2. The follow-up is ready for review.Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T22:01:46Z.
Thank you both for the detailed reviews!
I have updated the branch with both improvements:
Observable draw coverage & binary round-trip (merged @Joacoorandom's follow-up commit dd760a2):
Reject invalid _e32 suffix on 3-operand instructions (@MatyEjsr's review):
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T23:26:20Z.
The current controls check the generated HLSL and rejected spellings. Please add a source-built LLVM 15 binary round-trip and one exact UINT readback for these two forms before marking them supported. Use different high/low words and tests for zero shifts, bit counts 31/32, and byte counts 3/4, so swapped inputs or an unmasked count changes a result. This can be one focused fixture with an independent host reference.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T23:46:02Z.
Thanks for the guidance, @R0Y00!
We have updated this PR to address all requested items:
Dedicated focused fixture & exact UINT readback (pixel_aot_align_):
Independent host reference controls:
Source-built LLVM 15 binary round-trip:
Documentation & Rebase:
434fabe), resolving conflicts in ests/rdna2_tools_check.py.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T00:12:42Z.
I pushed
f007ac4to resolve the overlap with #728 while keeping both draw modes and CTest registrations. The combined CPU controls and both WARP draw drivers passed locally. Hosted Windows then failed before configuring the project because the cached SPIR-V version probe aborted. #740 fixes that shared CI regression. Both Windows jobs need to run again after that fix is in place.