shader: lower scalar first-bit scans in pixel_aot #618

Manually merged
github merged 2 commits from gh-pr/618/head into gh-pr/618/base 2026-11-26 22:06:17 +00:00
Owner

@⁠descent81 on GitHub · 2026-11-22 16:06 UTC · original
descent81:shader/scalar-first-bit → main · +67 −0 · 4 files · 2 commits · merged 2026-11-23 04:28 UTC

Change

Add s_ff0_i32_b32, s_ff1_i32_b32, s_ff0_i32_b64, and s_ff1_i32_b64. These SOP1 instructions search from the least-significant bit and return its index when the requested bit is found, or 0xffffffff otherwise. The 64-bit path reads the existing SGPR pair and only searches the high word when the low word has no match. Both widths preserve SCC, as specified in the AMD RDNA 2 ISA reference.

The source-built fixture uses a Python bit-by-bit reference, compares the full 32-bit results and reads SCC before the result comparison can overwrite it. An all-zero and an all-one input check the no-match result for both bit values. Other inputs cover the 31/32 boundary, a low-word match that must win over a high-word match, and a single set bit at position 63. A shader that drops the high word must fail the same reference on that last input.

Verification

Tested 8fedbcc on base e7e9133.

  • Windows D3D12: RTX 4060 (32.0.16.1088) and WARP (10.0.26100.9818) matched all 4,096 pixels in each of 12 positive draws per backend. Both detected the low-word-only mutation. The complete predicate/rounding CTest passed on hardware (34.41 s) and WARP (6.84 s), with no skips.
  • LLVM 15: The full binary and translator controls passed on base and head. Comparing the recorded forms against the existing reference lists gives gfx1013 465 → 469 and gfx1030 461 → 465. The difference is exactly the four SOP1 forms above, with no removals. These are local binary-fixture counts.
python -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failure

Evidence and follow-up

The fixture uses source-written assembly and synthetic constants under the repository's MIT license. The vector bit-scan work in #541 and the scalar bit-count work use separate instructions.

AI-assisted.

**@⁠descent81** on GitHub · 2026-11-22 16:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/618) `descent81:shader/scalar-first-bit` → `main` · +67 −0 · 4 files · 2 commits · merged 2026-11-23 04:28 UTC ## Change Add `s_ff0_i32_b32`, `s_ff1_i32_b32`, `s_ff0_i32_b64`, and `s_ff1_i32_b64`. These SOP1 instructions search from the least-significant bit and return its index when the requested bit is found, or `0xffffffff` otherwise. The 64-bit path reads the existing SGPR pair and only searches the high word when the low word has no match. Both widths preserve SCC, as specified in the [AMD RDNA 2 ISA reference](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture). The source-built fixture uses a Python bit-by-bit reference, compares the full 32-bit results and reads SCC before the result comparison can overwrite it. An all-zero and an all-one input check the no-match result for both bit values. Other inputs cover the 31/32 boundary, a low-word match that must win over a high-word match, and a single set bit at position 63. A shader that drops the high word must fail the same reference on that last input. ## Verification Tested `8fedbcc` on base `e7e9133`. - **Windows D3D12:** RTX 4060 (32.0.16.1088) and WARP (10.0.26100.9818) matched all 4,096 pixels in each of 12 positive draws per backend. Both detected the low-word-only mutation. The complete predicate/rounding CTest passed on hardware (34.41 s) and WARP (6.84 s), with no skips. - **LLVM 15:** The full binary and translator controls passed on base and head. Comparing the recorded forms against the existing reference lists gives gfx1013 **465 → 469** and gfx1030 **461 → 465**. The difference is exactly the four SOP1 forms above, with no removals. These are local binary-fixture counts. ```sh python -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failure ``` ## Evidence and follow-up The fixture uses source-written assembly and synthetic constants under the repository's MIT license. The vector bit-scan work in #541 and the scalar bit-count work use separate instructions. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:06:15 +00:00
github manually merged commit 027afbac9d into gh-pr/618/base 2026-11-26 22:06:17 +00:00
Author
Owner

@⁠JB2WIN on GitHub · 2026-11-22 19:13 UTC · original

Independent Windows run of this PR on physical hardware:

  • Commit under test: 8fedbcc (PR head), built from source
  • Windows 11 (10.0.26200.9974), VS Build Tools 2026 (MSVC 19.51), SDK 10.0.26100.8249 (DXC 1.8.2502.11), dev preset
  • NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, D3D12 debug layer enabled

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V: 22/22 passed on hardware and WARP, no skips. The debug layer reported debug_errors=0 on all 460 draws. I did not run any mutations.

AI-assisted.

**@⁠JB2WIN** on GitHub · 2026-11-22 19:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/618#issuecomment-7084212917) Independent Windows run of this PR on physical hardware: - Commit under test: `8fedbcc` (PR head), built from source - Windows 11 (10.0.26200.9974), VS Build Tools 2026 (MSVC 19.51), SDK 10.0.26100.8249 (DXC 1.8.2502.11), dev preset - NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, D3D12 debug layer enabled `ctest --preset dev --no-tests=error -R '^pixel_aot_' -V`: **22/22 passed** on hardware and WARP, no skips. The debug layer reported `debug_errors=0` on all 460 draws. I did not run any mutations. AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.