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

Merged
descent81 merged 2 commits from upstream-pr/618 into main 2026-11-23 04:28:48 +00:00
descent81 commented 2026-11-22 16:06:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by descent81 on 2026-11-22T16:06:58Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6544593194 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/618). Originally posted by [descent81](https://github.com/descent81) on 2026-11-22T16:06:58Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:43:58 +00:00
JB2WIN commented 2026-11-24 06:48:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T19:13:33Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084212917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/618#issuecomment-7084212917). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T19:13:33Z. --- 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.
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!612
No description provided.