shader: lower s_bfe_u64 and s_bfe_i64 in pixel_aot #636

Merged
lambirou merged 2 commits from upstream-pr/642 into main 2026-11-22 18:06:35 +00:00
lambirou commented 2026-11-22 17:14:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-22T17:14:05Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6545304179 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/642). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T17:14:05Z. --- ## 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. ```powershell 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 - [x] One reviewable behavior. - [x] Reproduction commands and observed results included. - [x] Negative controls and operand rejection covered. - [x] Experiment documentation updated. - [x] Source-built inputs only. AI-assisted implementation and test preparation. The reported Xbox2Windows checks were run locally.
upstream-sync closed this pull request 2026-11-24 06:44:07 +00:00
MarlomMedeiros commented 2026-11-24 06:44:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T18:05:47Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6013659583 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/642#pullrequestreview-6013659583). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-22T18:05:47Z. **Review:** COMMENTED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!636
No description provided.