shader: lower 64-bit scalar bit counts and bit scans in the direct compute path #3072

Closed
opened 2026-11-27 14:10:42 +00:00 by legacy-code-archaeologist · 0 comments
legacy-code-archaeologist commented 2026-11-27 14:10:42 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T14:10:42Z.


Part of #2935 (closing the remaining gfx2hlsl.py gaps in the direct C++ compute path; 64-bit counterparts of #3050/#3051).

src/gfx1013_direct_compute.inl does not yet lower the 64-bit-source scalar bit counts and bit scans s_bcnt0_i32_b64, s_bcnt1_i32_b64, s_ff0_i32_b64, s_ff1_i32_b64, s_flbit_i32_b64 and s_flbit_i32_i64 (they hit unsupported wave64 scalar operation or direct ALU operand modifiers).

Scope:

  • Lower all 6 SOP1 ops in src/gfx1013_direct_compute.inl using 32-bit DXIL unaryBits.i32 (Countbits, FirstbitLo, FirstbitHi — no Int64Ops needed), matching tools/startup/gfx2hlsl.py:
    • Destination: general SGPR s0..s105 (32-bit i32 result).
    • Source S0: aligned SGPR pair s0..s104 even, inline integer -16..64, or 32-bit literal (sign-extended for s_flbit_i32_i64, zero-extended for _b64).
    • Only s_bcnt0_i32_b64 and s_bcnt1_i32_b64 write SCC = (D != 0); all four scans preserve SCC and return 0xffffffff when no bit qualifies.
  • Fix transfer() in src/gfx1013_compute_native.cpp so _i32_b64 ops (whose source is 64-bit but destination is 32-bit) do not clear s[dst + 1] and clobber adjacent descriptors.
  • Mark s_bcnt0_i32_b64 and s_bcnt1_i32_b64 as overwriting SCC in uses_scc_after().
  • Add controls + hardware readback fixture (tests/native_salu_bitscan64_check.py, tests/cmake/native_salu_bitscan64.cmake) and docs/experiments/native-direct-salu-bitscan64.md.

I am taking it. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6648093984 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3072). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T14:10:42Z. --- Part of #2935 (closing the remaining `gfx2hlsl.py` gaps in the direct C++ compute path; 64-bit counterparts of #3050/#3051). `src/gfx1013_direct_compute.inl` does not yet lower the 64-bit-source scalar bit counts and bit scans `s_bcnt0_i32_b64`, `s_bcnt1_i32_b64`, `s_ff0_i32_b64`, `s_ff1_i32_b64`, `s_flbit_i32_b64` and `s_flbit_i32_i64` (they hit `unsupported wave64 scalar operation` or `direct ALU operand modifiers`). Scope: - Lower all 6 SOP1 ops in `src/gfx1013_direct_compute.inl` using 32-bit DXIL `unaryBits.i32` (`Countbits`, `FirstbitLo`, `FirstbitHi` — no `Int64Ops` needed), matching `tools/startup/gfx2hlsl.py`: - Destination: general SGPR `s0..s105` (32-bit `i32` result). - Source `S0`: aligned SGPR pair `s0..s104` even, inline integer `-16..64`, or 32-bit literal (sign-extended for `s_flbit_i32_i64`, zero-extended for `_b64`). - Only `s_bcnt0_i32_b64` and `s_bcnt1_i32_b64` write `SCC = (D != 0)`; all four scans preserve `SCC` and return `0xffffffff` when no bit qualifies. - Fix `transfer()` in `src/gfx1013_compute_native.cpp` so `_i32_b64` ops (whose source is 64-bit but destination is 32-bit) do not clear `s[dst + 1]` and clobber adjacent descriptors. - Mark `s_bcnt0_i32_b64` and `s_bcnt1_i32_b64` as overwriting `SCC` in `uses_scc_after()`. - Add controls + hardware readback fixture (`tests/native_salu_bitscan64_check.py`, `tests/cmake/native_salu_bitscan64.cmake`) and `docs/experiments/native-direct-salu-bitscan64.md`. I am taking it. AI-assisted.
Sign in to join this conversation.
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#3072
No description provided.