Skip to content

shader: lower s_bfe_u64 and s_bfe_i64 in pixel_aot - #642

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
lambirou:shader/lower-s-bfe-b64
Nov 22, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
lambirou:shader/lower-s-bfe-b64

Conversation

@lambirou

Copy link
Copy Markdown
Contributor

Change

Lower the signed and unsigned 64-bit scalar bitfield extracts in pixel_aot, extending the scalar BFE profile from #279. The selector supplies a six-bit offset and a seven-bit width. A zero width returns zero, fields stop at bit 63, and s_bfe_i64 extends the sign of the extracted field. SCC reflects whether either result dword is nonzero.

The lowering reuses the two-dword shifts and accepts aligned numeric SGPR pairs, including when the destination aliases a source. Both the data and field selector can use the supported scalar immediates.

Verification

Tested e4c1dcf on main at b03f754. Windows 11 build 26300, WARP 10.0.26100.10068, AMD Radeon RX 9060 XT driver 32.0.32029.2010, D3D12 debug layer unavailable.

ctest --preset dev --no-tests=error -R '^pixel_aot(_.*)?_warp$|^pixel_aot_blend_scalar_hardware$' --output-on-failure --output-junit "$PWD/out/s-bfe-b64-submission.xml"
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
$llvm = (Resolve-Path 'out/llvm-check/ucrt64/bin').Path
$env:Path = "$llvm;$env:Path"
.\out\pe-env\Scripts\python.exe -B tests/pixel_aot_check.py binary (Join-Path $llvm 'llvm-mc.exe') (Join-Path $llvm 'llvm-objcopy.exe') (Join-Path $llvm 'libLLVM-23.dll')
git diff --check origin/main...HEAD

All 12 CTest checks passed, including 11 WARP tests and the scalar draw on Radeon, with zero skips. The Python checks and LLVM 23.1.5 round-trip passed.

Evidence

The source-built MIT fixture compares both result dwords and SCC against a Python reference through an integer render target. Eleven inputs per form exercise empty fields, a field crossing the dword boundary, a high-word-only result, widths of 64 and 127, ignored selector bits, and a raw signaling NaN bit pattern. SCC starts at the opposite of the expected result. Each shader must report a mismatch against the other form's cross-dword reference. Operand tests cover invalid pairs, EXEC operands, and pending scalar loads.

The focused pre-rebase measurement at base 1947e97 gained two SOP2 forms, from 139 to 141 of 1,968 in gfx1013 and from 135 to 137 of 1,863 in the gfx1030 reference. The coverage test checks both new forms in both references.

Checklist

  • One reviewable behavior.
  • Reproduction commands and observed results included.
  • Negative controls and operand rejection covered.
  • Experiment documentation updated.
  • Source-built inputs only.

AI-assisted implementation and test preparation. The reported Xbox2Windows checks were run locally.

@MarlomMedeiros MarlomMedeiros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Community review + independent run on a second-vendor adapter, since the reported hardware is a Radeon RX 9060 XT.

Environment

  • Commit under test: e4c1dcf (feature) / 6c55a82 (branch head, merge with upstream)
  • Windows 11 build 26300.10075, VS 2026 MSVC 19.52, Ninja, DXC from SDK 10.0.26100
  • ctest --preset dev --no-tests=error -R '^pixel_aot_blend_scalar_(warp|hardware)$' -V: both passed
  • Hardware: NVIDIA GeForce RTX 5070 (vendor=10de device=2f04), driver 32.0.16.2135, D3D12 debug layer enabled, debug_errors=0 debug_warnings=0, pixels=4096 max_absolute_error=0
  • WARP: Microsoft Basic Render Driver, driver 10.0.26100.10068
  • tests/pixel_aot_check.py controls, tests/form_coverage_check.py, tests/rdna2_tools_check.py and the LLVM 15.0.7 binary round-trip all pass on e4c1dcf

Review notes

  • The s_bfe64 helper is the classic left-align extraction: aligned = src << (64 - width - offset) then >> (64 - width) arithmetically for i64 and logically for u64. Field clamp min(width, 64 - offset) implements the ISA's "field stops at bit 63" and width == 0 returns zero. The six-bit offset and seven-bit width match the packed selector.
  • SCC is (x | y) != 0 across both dwords, which the draw verifies through an opposite-seeded s_cselect rather than a bare flag check.
  • Test breadth is good: empty field, zero result, cross-dword negative field, width clamps at both ends, ignored high control bits, sNaN bit preservation, and a Python reference model per case.
  • Interaction note for #651 (exec-masked regions, open): s_bfe_u64/s_bfe_i64 currently sit in the rejected_forms assertion there. Whichever PR merges second updates that list — trivial either way. Inside a masked region these stay s_* ops, correctly denied.
  • Heads-up: the branch head is a merge commit (6c55a82); if upstream prefers linear history a rebase may be requested, and the diff against b03f754 is clean.

No blockers found.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.

@R0Y00
R0Y00 merged commit 7b8b6c4 into R0Y00:main Nov 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants