shader: lower s_bitset0/1_b32 in gfx2hlsl (#2023 Item J) #2638

Manually merged
github merged 2 commits from gh-pr/2638/head into gh-pr/2638/base 2026-11-27 01:10:04 +00:00
Owner

@⁠SimSalabimse on GitHub · 2026-11-26 00:00 UTC · original
SimSalabimse:cursor/gfx2hlsl-s-bitset-5a9e → main · +226 −1 · 7 files · 2 commits · merged 2026-11-26 00:17 UTC

Change

Part of #2023 Item J (s_bitset1_b32, with the natural pair s_bitset0_b32) in tools/startup/gfx2hlsl.py.

Ordinary vertex/pixel pipelines that only need an in-place scalar bit set or clear were refusing at these SOP1 forms. The lowering matches pixel_aot / #1579:

  • s_bitset0_b32: D = D & ~(1u << (S0 & 31))
  • s_bitset1_b32: D = D | (1u << (S0 & 31))
  • SCC unchanged
  • Lane-mask and descriptor-bearing SGPRs refused
  • Known constant destination + known bit index folds

Claim before coding. Base is main at e3dda42b.

AI-assisted.

Verification

Commit under test: this PR head.

python3 -B tests/startup_gfx2hlsl_s_bitset_check.py
# all ok

python3 -B tests/startup_gfx2hlsl_s_bitcmp_check.py
python3 -B tests/startup_gfx2hlsl_handler_arity_check.py
python3 -B tests/startup_gfx2hlsl_scalar_arity_check.py
python3 -B tests/startup_translator_check.py
python3 -B tests/docs_links_check.py

All passed on Linux (CPU evaluation of the translated text). Windows WARP/hardware draws were not run here; the fixture is device-free.

CTest filter once configured: ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_s_bitset$' -V.

Evidence and follow-up

  • Hand-assembled SOP1 encodings via disasm_rdna2 / gfx2hlsl.decode; no retail bytes.
  • Negative control: mutating the emitted expression to drop the bit update diverges from the ISA reference.
  • 64-bit s_bitset*_b64 stays refused (out of Item J scope).

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
**@⁠SimSalabimse** on GitHub · 2026-11-26 00:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2638) `SimSalabimse:cursor/gfx2hlsl-s-bitset-5a9e` → `main` · +226 −1 · 7 files · 2 commits · merged 2026-11-26 00:17 UTC ## Change Part of [#2023](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/2023) **Item J** (`s_bitset1_b32`, with the natural pair `s_bitset0_b32`) in `tools/startup/gfx2hlsl.py`. Ordinary vertex/pixel pipelines that only need an in-place scalar bit set or clear were refusing at these SOP1 forms. The lowering matches `pixel_aot` / #1579: - `s_bitset0_b32`: `D = D & ~(1u << (S0 & 31))` - `s_bitset1_b32`: `D = D | (1u << (S0 & 31))` - SCC unchanged - Lane-mask and descriptor-bearing SGPRs refused - Known constant destination + known bit index folds [Claim](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/2023) before coding. Base is `main` at `e3dda42b`. AI-assisted. ## Verification Commit under test: this PR head. ```bash python3 -B tests/startup_gfx2hlsl_s_bitset_check.py # all ok python3 -B tests/startup_gfx2hlsl_s_bitcmp_check.py python3 -B tests/startup_gfx2hlsl_handler_arity_check.py python3 -B tests/startup_gfx2hlsl_scalar_arity_check.py python3 -B tests/startup_translator_check.py python3 -B tests/docs_links_check.py ``` All passed on Linux (CPU evaluation of the translated text). Windows WARP/hardware draws were not run here; the fixture is device-free. CTest filter once configured: `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_s_bitset$' -V`. ## Evidence and follow-up - Hand-assembled SOP1 encodings via `disasm_rdna2` / `gfx2hlsl.decode`; no retail bytes. - Negative control: mutating the emitted expression to drop the bit update diverges from the ISA reference. - 64-bit `s_bitset*_b64` stays refused (out of Item J scope). ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
Port the pixel_aot bit set/clear SOP1 forms so ordinary vertex and pixel
pipelines that only need an in-place scalar bit update stop refusing at
s_bitset1_b32. SCC stays unchanged; lane masks and descriptor SGPRs refuse.

Co-authored-by: SimSalabimse <[email protected]>
s_bitset0/1_b32 reused the plain-scalar sym allow-list line, so the
sopk_accum mutant needle was no longer unique. Match the sopk raise that
formats with `base` instead.

Co-authored-by: SimSalabimse <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:10:03 +00:00
github manually merged commit 8b477af449 into gh-pr/2638/base 2026-11-27 01:10:04 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 00:11 UTC · original · reviewed

Review of head 8b477af4 (comment only, no approval and no merge).

Duplicate slice (blocking the merge decision). #2420 (open, opened 2026-11-25 16:08Z) already lowers s_bitset0_b32 and s_bitset1_b32 in tools/startup/gfx2hlsl.py for #2023 Item J, with its own test tests/startup_gfx2hlsl_bitset_check.py and the same CMake and windows.yml wiring. This PR covers the same two opcodes. Only one of them can land, and the two add different test file names, so both would also add duplicate test registrations. I leave the choice to @⁠R0Y00. #2420 is currently CONFLICTING with main and this PR is MERGEABLE, which may matter for the decision.

Code (tools/startup/gfx2hlsl.py, scalar_bitset)

  • Semantics match the ISA: D &= ~(1u << (S0 & 31)) and D |= (1u << (S0 & 31)), SCC unchanged, D read before write.
  • Lane masks and sub-range or high SGPRs are refused; constant D with constant S0 folds correctly.
  • No defect found in the lowering itself.

Test gap. tests/startup_gfx2hlsl_s_bitset_check.py evaluates the translated text on the CPU only. For a shader/math lowering we need a real D3D12 WARP GPU readback compared with a CPU reference. The PR states WARP was not run. Please add a WARP readback case (extend the existing WARP shader test suite) before this is merge-ready.

Checks run locally (worktree on the PR head): git diff --stat origin/main...HEAD, diff read for tools/, CMakeLists.txt, .github/, AGENTS.md, and a search for other PRs on the same opcodes (gh pr list --search s_bitset).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 00:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2638#pullrequestreview-6066787672) · **reviewed** Review of head 8b477af4 (comment only, no approval and no merge). **Duplicate slice (blocking the merge decision).** #2420 (open, opened 2026-11-25 16:08Z) already lowers `s_bitset0_b32` and `s_bitset1_b32` in `tools/startup/gfx2hlsl.py` for #2023 Item J, with its own test `tests/startup_gfx2hlsl_bitset_check.py` and the same CMake and `windows.yml` wiring. This PR covers the same two opcodes. Only one of them can land, and the two add different test file names, so both would also add duplicate test registrations. I leave the choice to @⁠R0Y00. #2420 is currently CONFLICTING with main and this PR is MERGEABLE, which may matter for the decision. **Code (tools/startup/gfx2hlsl.py, `scalar_bitset`)** - Semantics match the ISA: `D &= ~(1u << (S0 & 31))` and `D |= (1u << (S0 & 31))`, SCC unchanged, D read before write. - Lane masks and sub-range or high SGPRs are refused; constant D with constant S0 folds correctly. - No defect found in the lowering itself. **Test gap.** `tests/startup_gfx2hlsl_s_bitset_check.py` evaluates the translated text on the CPU only. For a shader/math lowering we need a real D3D12 WARP GPU readback compared with a CPU reference. The PR states WARP was not run. Please add a WARP readback case (extend the existing WARP shader test suite) before this is merge-ready. **Checks run locally** (worktree on the PR head): `git diff --stat origin/main...HEAD`, diff read for `tools/`, `CMakeLists.txt`, `.github/`, `AGENTS.md`, and a search for other PRs on the same opcodes (`gh pr list --search s_bitset`). AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.