shader: expand 64-bit scalar bitfield extraction in pixel_aot and scanner #694
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/700"
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:54:54Z.
Summary
Expand 64-bit scalar bitfield extraction and mask operations in
tools/pixel_aot.pyandtools/scan_unsupported_shaders.py:tools/pixel_aot.py: expandscalar_u64()to accept full 64-bit hexadecimal literals (0x[0-9a-f]{1,16}), preserving 32-bit sign extension for literals up to 8 hex digits (len <= 10).tools/scan_unsupported_shaders.py:s_bfe_u64ands_bfe_i64inSUPPORTED_INSTRUCTIONS_REGEXandKNOWN_RDNA2_BASE_OPCODES.SCALAR64_SOURCEpattern to accept 64-bit hex literals up to 16 hex digits (0x[0-9a-f]{1,16}).tests/pixel_aot_check.py:SCALAR_BFE64_OPS.SCALAR_BFE64_OPS <= ACCEPTED.s_bfm_b64forms (single SGPR destination, VGPR sources, missing operands, out-of-range SGPRs).tests/rdna2_tools_check.py:s_bfe_u64,s_bfe_i64, ands_bfm_b64with 64-bit registers, hex literals, and immediate control constants.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:0x10000000000000000) correctly rejected byscalar_u64.s_bfm_b64with single destination, VGPR source, or out-of-range SGPR correctly rejected.tests/rdna2_tools_check.py:Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-22T21:51:39Z.
Verdict: Request changes (reviewed head
88f444e704fa2892610cfd16c2564829043581c1, compared againstmain4c3b573).Verification
Environment: Windows 11 x64, Python 3.12.10, DXC (
C:\VulkanSDK\1.4.363.0\Bin\dxc.exe) for offline HLSL compile checks, and WSL Archllvm-mc23.1.5 (-triple=amdgcn--amdpal -mcpu=gfx1013) for ISA encoding checks. Zero-GPU review (no WARP or hardware draw executed).Commands and results on
88f444e: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.dxc -T ps_6_0 -E main -WXonscalar_bfe64("s_bfe_u64"|"s_bfe_i64", "0x8123456789abcdef", control="0x200020"): exit 0, 0 warnings.git merge-tree --write-tree main 88f444e: clean against4c3b573(exit 0); conflicts with #688 (git merge-treeexit 1).Issues to address
Arbitrary 64-bit hex literals are not encodable on
gfx1013:ssrc == 255) are strictly a single 32-bit dword (zero-extended for_u64/_b64, sign-extended for_i64).llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -show-encoding:s_bfe_u64 s[0:1], 0x8123456789abcdef, s4->error: invalid operand for instructions_bfe_i64 s[0:1], 0x8123456789abcdef, s4->error: invalid operand for instructions_bfe_u64 s[0:1], 0x100000000, s4->error: invalid operand for instructions_and_b64 s[0:1], 0x8123456789abcdef, s[2:3]->error: invalid operand for instruction0x80000000, or assembly input0xffffffff80000000ons_bfe_i64) is assembled and disassembled back withllvm-mc --disassemble, LLVM always prints the 8-hex-digit literal (0x80000000).SCALAR64_SOURCEandscalar_u64()to0x[0-9a-f]{1,16}therefore accepts unencodable 64-bit hex literals across all 64-bit SALU rules (s_bfe_*64,s_and_b64,s_lshl_b64,s_cmp_eq_u64, etc.).String-length-dependent sign extension in
scalar_u64():if len(token) <= 10:makes the decoded 64-bit value depend on leading zeros rather than the numeric value: forsigned=True,scalar_u64("0x80000000", ..., signed=True)returns('2147483648u', '4294967295u'), whilescalar_u64("0x080000000", ..., signed=True)returns('2147483648u', '0u').scalar_u64()aligned with realgfx1013literals, reverting the0x[0-9a-f]{1,16}widening avoids both issues (or if sign-extended 64-bit hex spelling like0xffffffff80000000is specifically needed, only accept values representable as a 32-bit SOP literal).Conflict and contradiction with #688:
s_bfe_u64 s0, s[2:3], s4,s_bfe_u64 s[0:1], s2, s4,s_bfm_b64 s0, s2, s3) are rejected, while #688 changespixel_aot.pyandscan_unsupported_shaders.pyto accept those same forms (and both PRs conflict intools/scan_unsupported_shaders.pyandtests/rdna2_tools_check.py).Registering
s_bfe_u64/s_bfe_i64inscan_unsupported_shaders.py(SUPPORTED_INSTRUCTIONS_REGEX+KNOWN_RDNA2_BASE_OPCODES), the 32-bit immediate control word check (0x200020, confirmed valid inllvm-mc), and thes_bfm_b64negative controls are all solid on their own.AI-assisted review (local Python, offline DXC, and
llvm-mcchecks executed locally).Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T22:28:32Z.
Thanks @MatyEjsr for the thorough review and ISA verification!
We've addressed all three points:
0x[0-9a-f]{1,16}widening:SCALAR64_SOURCEintools/scan_unsupported_shaders.pyandscalar_u64()intools/pixel_aot.pystrictly keep 32-bit hex literals0x[0-9a-f]{1,8}, matching real GFX1013 encodability where literal constants (ssrc == 255) are single 32-bit dwords.scalar_u64()directly sign-extends 32-bit literals based on bit 31 (value & 0x80000000) whensigned=True. Added rejection controls intests/pixel_aot_check.pyfor literals > 32 bits (0x8123456789abcdefand0x100000000) and scanner rejection checks intests/rdna2_tools_check.py.disasm_rdna2.py(formatting 64-bit SOP1/SOP2 operands as pairss[N:N+1]), completely removing the single-SGPR widening frompixel_aot.py/scan_unsupported_shaders.py. Rebased this branch ontomainwith 0 conflicts.All test suites pass locally (
tests/rdna2_tools_check.py,tests/pixel_aot_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py,tests/pso_readiness_check.py,tests/dxil_retarget_check.py).