shader: lower the plain bfrev, ffbh and ffbl forms in pixel_aot #749

Merged
JB2WIN merged 1 commit from upstream-pr/755 into main 2026-11-23 01:54:35 +00:00
JB2WIN commented 2026-11-23 00:58:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T00:58:22Z.


Change

tools/pixel_aot.py now lowers the plain VOP1 forms of v_bfrev_b32, v_ffbl_b32, v_ffbh_u32 and v_ffbh_i32, in both the _e32 and _e64 encodings. These forms were already accepted as quad-local DPP; this adds the plain spellings. Following your note in #735, v_xnor_b32 is left to #728. The fixtures still use it as a fourth lane.

  • The forms join the plain INTEGER table and reuse the DPP lowering only where the semantics are the same:
    • reversebits for v_bfrev_b32;
    • firstbitlow for v_ffbl_b32, which gives 0xffffffff for zero, as the DPP path does;
    • the existing dpp_ffbh_u32 and dpp_ffbh_i32 helpers for v_ffbh_*. A new INTEGER_HELPERS map requests them, and each is emitted once, only when used.
  • These are rejected with ValueError: source modifiers, clamp, wrong operand counts and v256. SDWA, 64-bit and 16-bit variants are out of scope.
  • The scanner and PSO-readiness checks pick the forms up from the INTEGER table; no scanner edit was needed.

Refs #735. AI-assisted (Claude Code).

Verification

Environment: Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818. The D3D12 debug layer was enabled. The head is rebased on 356a7be.

  • Draw draw-plain-bitscan (pixel_aot_plain_bitscan_{hardware,warp}):

    • Two shaders: one with the plain spellings, and one mixing _e32 and _e64 with a literal source.
    • The sources are s44..s47 directly, so no input passes through a float VGPR.
    • Nine cases rotate the words 0, 0xffffffff, 0x80000000, 1, 0x7fffffff, 0xffff, 0xaaaaaaaa, 0x12345678 and 0xfffffffe through every source register. That covers the zero/all-ones sentinels and sign-only inputs for every op.
    • Each result is read back full-width through the integer target and compared against an independent Python bit-loop reference.
  • Mutations: four controls must each report a mismatch. On both adapters, the mismatching cases were:

    Mutation Mismatching cases
    ffbh_i32 → ffbh_u32 (signed vs unsigned control) 4 of 9
    ffbl_b32 → ffbh_u32 6 of 9
    xnor_b32 → xor_b32 9 of 9
    bfrev_b32 → not_b32 7 of 9

    Before any draw runs, a Python check confirms that each mutation changes its own lane.

  • Dev-time check (not committed): with the new INTEGER entries removed, both the controls and form_coverage_check.py fail.

  • Results:

    • ctest --preset dev --no-tests=error -R "^pixel_aot_plain_bitscan_": 2/2 passed, in 7.9 s on the hardware adapter and 2.6 s on WARP.
    • Full ctest --preset dev --no-tests=error: 328 of 330 passed. The two failures are pixel_aot_predicate_rounding_{hardware,warp}, caused by the NameError in check_scalar_carry_chain_draw that is already on main and that #752 fixes; it is not related to this change. The skips are bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp, the same as on main.
    • tests/pixel_aot_check.py binary with LLVM 15.0.7 exits 0, including the _e64 literal. llvm-mc runs locally through a clang -cc1as shim.
    • The controls, form_coverage_check.py, rdna2_tools_check.py, pso_readiness_check.py and docs_links_check.py pass.

Notes

  • The draw uses the same denorm mode as check_bfm_draw.
  • Pre-existing behaviour, unchanged here: in int_operand, an untracked VGPR source raises KeyError instead of ValueError.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6550101596 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/755). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T00:58:22Z. --- ## Change `tools/pixel_aot.py` now lowers the plain VOP1 forms of `v_bfrev_b32`, `v_ffbl_b32`, `v_ffbh_u32` and `v_ffbh_i32`, in both the `_e32` and `_e64` encodings. These forms were already accepted as quad-local DPP; this adds the plain spellings. Following your note in #735, `v_xnor_b32` is left to #728. The fixtures still use it as a fourth lane. - The forms join the plain `INTEGER` table and reuse the DPP lowering only where the semantics are the same: - `reversebits` for `v_bfrev_b32`; - `firstbitlow` for `v_ffbl_b32`, which gives `0xffffffff` for zero, as the DPP path does; - the existing `dpp_ffbh_u32` and `dpp_ffbh_i32` helpers for `v_ffbh_*`. A new `INTEGER_HELPERS` map requests them, and each is emitted once, only when used. - These are rejected with `ValueError`: source modifiers, `clamp`, wrong operand counts and `v256`. SDWA, 64-bit and 16-bit variants are out of scope. - The scanner and PSO-readiness checks pick the forms up from the `INTEGER` table; no scanner edit was needed. Refs #735. AI-assisted (Claude Code). ## Verification Environment: Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818. The D3D12 debug layer was enabled. The head is rebased on `356a7be`. - **Draw `draw-plain-bitscan` (`pixel_aot_plain_bitscan_{hardware,warp}`):** - Two shaders: one with the plain spellings, and one mixing `_e32` and `_e64` with a literal source. - The sources are `s44`..`s47` directly, so no input passes through a float VGPR. - Nine cases rotate the words `0`, `0xffffffff`, `0x80000000`, `1`, `0x7fffffff`, `0xffff`, `0xaaaaaaaa`, `0x12345678` and `0xfffffffe` through every source register. That covers the zero/all-ones sentinels and sign-only inputs for every op. - Each result is read back full-width through the integer target and compared against an independent Python bit-loop reference. - **Mutations:** four controls must each report a mismatch. On both adapters, the mismatching cases were: | Mutation | Mismatching cases | |---|---| | `ffbh_i32` → `ffbh_u32` (signed vs unsigned control) | 4 of 9 | | `ffbl_b32` → `ffbh_u32` | 6 of 9 | | `xnor_b32` → `xor_b32` | 9 of 9 | | `bfrev_b32` → `not_b32` | 7 of 9 | Before any draw runs, a Python check confirms that each mutation changes its own lane. - **Dev-time check (not committed):** with the new `INTEGER` entries removed, both the controls and `form_coverage_check.py` fail. - **Results:** - `ctest --preset dev --no-tests=error -R "^pixel_aot_plain_bitscan_"`: 2/2 passed, in 7.9 s on the hardware adapter and 2.6 s on WARP. - Full `ctest --preset dev --no-tests=error`: 328 of 330 passed. The two failures are `pixel_aot_predicate_rounding_{hardware,warp}`, caused by the `NameError` in `check_scalar_carry_chain_draw` that is already on `main` and that #752 fixes; it is not related to this change. The skips are `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`, the same as on `main`. - `tests/pixel_aot_check.py binary` with LLVM 15.0.7 exits 0, including the `_e64` literal. `llvm-mc` runs locally through a `clang -cc1as` shim. - The controls, `form_coverage_check.py`, `rdna2_tools_check.py`, `pso_readiness_check.py` and `docs_links_check.py` pass. ## Notes - The draw uses the same denorm mode as `check_bfm_draw`. - Pre-existing behaviour, unchanged here: in `int_operand`, an untracked VGPR source raises `KeyError` instead of `ValueError`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:44:38 +00:00
JB2WIN commented 2026-11-24 06:48:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T01:42:09Z.


I rebased this on 37ed46d and squashed it into one commit, v_xnor_b32 stays out of scope. pixel_aot_plain_bitscan_{hardware,warp} passes 2/2 (5.9 s / 1.8 s), the controls and the LLVM 15 binary round trip pass, and the full suite has 332 of 333 passing.

The one failure is pixel_aot_predicate_rounding_hardware, which hits its 60 s timeout on this RTX 3080 even when run on its own. This change does not touch that mode. On another branch from the same base it passed in 56.4 s, so on this adapter it now sits right at the 60 s limit on main.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7089351828 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/755#issuecomment-7089351828). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T01:42:09Z. --- I rebased this on `37ed46d` and squashed it into one commit, `v_xnor_b32` stays out of scope. `pixel_aot_plain_bitscan_{hardware,warp}` passes 2/2 (5.9 s / 1.8 s), the controls and the LLVM 15 binary round trip pass, and the full suite has 332 of 333 passing. The one failure is `pixel_aot_predicate_rounding_hardware`, which hits its 60 s timeout on this RTX 3080 even when run on its own. This change does not touch that mode. On another branch from the same base it passed in 56.4 s, so on this adapter it now sits right at the 60 s limit on `main`.
FZNull commented 2026-11-24 06:48:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by FZNull on 2026-11-23T01:53:08Z.


Verified on d3649785737e4e04a5330a30c1f47dc184d4cccf (rebased onto main 37ed46d) on an NVIDIA GeForce RTX 4060 (driver 32.0.16.2124, Windows 11 build 26300) and on WARP (Microsoft Basic Render Driver, driver 10.0.26100.10068). The D3D12 debug layer is unavailable on this host.

  • Merge onto main 37ed46d: clean fast-forward, no conflicts.
  • Full Debug build (MSVC 19.50.35726, CMake 4.5.1, Ninja, DXC 1.9.2609.5): success, 0 errors.
  • ctest --test-dir out/build/wt-pr755 --no-tests=error -R '^pixel_aot_' -V: 32/32 passed in 346.5 s, and no test hit CTest's 60 s cap in this run, so the out-of-ctest fallback was not needed.
    • pixel_aot_plain_bitscan_hardware: passed in 5.94 s on the RTX 4060. The fixture compares its nine rotated-word cases against the Python bit-loop reference and asserts all four mutations.
    • pixel_aot_plain_bitscan_warp: passed in 1.43 s on WARP with the same cases and mutations.
    • Regression pixel_aot_hardware: passed in 52.72 s, max_absolute_error=0; pixel_aot_warp: passed in 10.35 s, max_absolute_error=0.
  • python -B tests/form_coverage_check.py: passed in 6.5 s. The new records list v_bfrev_b32, v_bfrev_b32_e64, v_ffbh_u32, v_ffbh_u32_e32, v_ffbh_u32_e64, v_ffbh_i32, v_ffbl_b32_e32, v_xnor_b32 and v_xnor_b32_e64; the out-of-scope e64 spellings (v_ffbl_b32_e64, v_ffbh_i32_e64) stay uncovered, as the PR states.

After the run main moved to f714d2f; git merge-tree reports this head still merges without conflicts there, though the suite was not re-run on that tip.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7089492356 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/755#issuecomment-7089492356). Originally posted by [FZNull](https://github.com/FZNull) on 2026-11-23T01:53:08Z. --- Verified on `d3649785737e4e04a5330a30c1f47dc184d4cccf` (rebased onto main `37ed46d`) on an NVIDIA GeForce RTX 4060 (driver 32.0.16.2124, Windows 11 build 26300) and on WARP (Microsoft Basic Render Driver, driver 10.0.26100.10068). The D3D12 debug layer is unavailable on this host. - Merge onto main `37ed46d`: clean fast-forward, no conflicts. - Full Debug build (MSVC 19.50.35726, CMake 4.5.1, Ninja, DXC 1.9.2609.5): success, 0 errors. - `ctest --test-dir out/build/wt-pr755 --no-tests=error -R '^pixel_aot_' -V`: **32/32 passed in 346.5 s**, and no test hit CTest's 60 s cap in this run, so the out-of-ctest fallback was not needed. - `pixel_aot_plain_bitscan_hardware`: passed in 5.94 s on the RTX 4060. The fixture compares its nine rotated-word cases against the Python bit-loop reference and asserts all four mutations. - `pixel_aot_plain_bitscan_warp`: passed in 1.43 s on WARP with the same cases and mutations. - Regression `pixel_aot_hardware`: passed in 52.72 s, `max_absolute_error=0`; `pixel_aot_warp`: passed in 10.35 s, `max_absolute_error=0`. - `python -B tests/form_coverage_check.py`: passed in 6.5 s. The new records list `v_bfrev_b32`, `v_bfrev_b32_e64`, `v_ffbh_u32`, `v_ffbh_u32_e32`, `v_ffbh_u32_e64`, `v_ffbh_i32`, `v_ffbl_b32_e32`, `v_xnor_b32` and `v_xnor_b32_e64`; the out-of-scope e64 spellings (`v_ffbl_b32_e64`, `v_ffbh_i32_e64`) stay uncovered, as the PR states. After the run `main` moved to `f714d2f`; `git merge-tree` reports this head still merges without conflicts there, though the suite was not re-run on that tip. _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!749
No description provided.