shader: accept the gfx10 SOPK waitcnt forms with null in pixel_aot #771

Merged
JB2WIN merged 1 commit from upstream-pr/777 into main 2026-11-23 03:00:06 +00:00
JB2WIN commented 2026-11-23 02:22:28 +00:00 (Migrated from github.com)

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


Change

tools/pixel_aot.py now accepts the gfx10 SOPK wait forms when the SGPR operand is null.

Form Behaviour
s_waitcnt_vmcnt null, K Same effect as the vmcnt(K) token of s_waitcnt: the existing token code runs unchanged.
s_waitcnt_lgkmcnt null, K Same effect as the lgkmcnt(K) token.
s_waitcnt_vscnt null, K No-op. pixel_aot lowers no vector memory stores, so nothing is outstanding on the store counter.
  • Why only null: null reads as 0, so the count is the immediate. A real SGPR operand is refused ("only null is modelled") because its runtime value is not tracked.
  • Count range: K must be 0..63, the gfx10 six-bit counter field. LLVM 15 also assembles larger simm16 values such as 0xffff, and pixel_aot refuses them.
  • Unchanged rules: malformed operands are refused, and so is any of these forms after the color export, as for the other s_waitcnt forms.
  • LLVM 15.0.7 (gfx1013) encodings: s_waitcnt_vmcnt null, 0x0 is [0x00,0x00,0x7d,0xbc], s_waitcnt_lgkmcnt null, 0x0 is [0x00,0x00,0x7d,0xbd] and s_waitcnt_vscnt null, 0x0 is [0x00,0x00,0xfd,0xbb].
  • Scanner: the three null forms with K 0..63 are supported. The SGPR form stays unsupported.

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. Head is rebased on 761e323.

  • Controls:
    • Replacing s_waitcnt vmcnt(0) with s_waitcnt_vmcnt null, 0x0 in a sampled program lowers to byte-identical HLSL.
    • The same holds for replacing s_waitcnt lgkmcnt(0) with s_waitcnt_lgkmcnt null, 0x0 in a scalar-load program.
    • Partial counts behave exactly as the token forms. For example, null, 0x1 with two outstanding samples behaves like vmcnt(1).
    • s_waitcnt_vscnt null, 0x0 can be inserted at any position before the export. The HLSL is identical once temporaries are renumbered by first appearance, and byte-identical directly before the export.
    • These are refused with exact messages: an SGPR operand, 0x40, 0xffff, a missing operand, and the forms after the export.
  • Dev-time check (not committed): without the new handling, the controls fail with Unsupported instruction 16: s_waitcnt_vmcnt null, 0x0.
  • Full suite: ctest --preset dev --no-tests=error: 338/338 passed. Skipped: bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp.
  • Binary round trip: tests/pixel_aot_check.py binary with LLVM 15.0.7 exits 0, including a fixture with all three forms. llvm-mc runs locally through a clang -cc1as shim.
  • Other checks: the controls, form_coverage_check.py (three SOPK forms covered, s_waitcnt_depctr and s_waitcnt_expcnt not), rdna2_tools_check.py, pso_readiness_check.py and docs_links_check.py pass.
  • Not measured on GPU: there is no new draw. The evidence is the identical-HLSL controls and the round trip.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6550954828 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/777). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T02:22:28Z. --- ## Change `tools/pixel_aot.py` now accepts the gfx10 SOPK wait forms when the SGPR operand is `null`. | Form | Behaviour | |---|---| | `s_waitcnt_vmcnt null, K` | Same effect as the `vmcnt(K)` token of `s_waitcnt`: the existing token code runs unchanged. | | `s_waitcnt_lgkmcnt null, K` | Same effect as the `lgkmcnt(K)` token. | | `s_waitcnt_vscnt null, K` | No-op. `pixel_aot` lowers no vector memory stores, so nothing is outstanding on the store counter. | - **Why only `null`:** `null` reads as 0, so the count is the immediate. A real SGPR operand is refused ("only null is modelled") because its runtime value is not tracked. - **Count range:** `K` must be 0..63, the gfx10 six-bit counter field. LLVM 15 also assembles larger simm16 values such as `0xffff`, and `pixel_aot` refuses them. - **Unchanged rules:** malformed operands are refused, and so is any of these forms after the color export, as for the other `s_waitcnt` forms. - **LLVM 15.0.7 (gfx1013) encodings:** `s_waitcnt_vmcnt null, 0x0` is `[0x00,0x00,0x7d,0xbc]`, `s_waitcnt_lgkmcnt null, 0x0` is `[0x00,0x00,0x7d,0xbd]` and `s_waitcnt_vscnt null, 0x0` is `[0x00,0x00,0xfd,0xbb]`. - **Scanner:** the three `null` forms with `K` 0..63 are supported. The SGPR form stays unsupported. 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. Head is rebased on `761e323`. - **Controls:** - Replacing `s_waitcnt vmcnt(0)` with `s_waitcnt_vmcnt null, 0x0` in a sampled program lowers to byte-identical HLSL. - The same holds for replacing `s_waitcnt lgkmcnt(0)` with `s_waitcnt_lgkmcnt null, 0x0` in a scalar-load program. - Partial counts behave exactly as the token forms. For example, `null, 0x1` with two outstanding samples behaves like `vmcnt(1)`. - `s_waitcnt_vscnt null, 0x0` can be inserted at any position before the export. The HLSL is identical once temporaries are renumbered by first appearance, and byte-identical directly before the export. - These are refused with exact messages: an SGPR operand, `0x40`, `0xffff`, a missing operand, and the forms after the export. - **Dev-time check (not committed):** without the new handling, the controls fail with `Unsupported instruction 16: s_waitcnt_vmcnt null, 0x0`. - **Full suite:** `ctest --preset dev --no-tests=error`: 338/338 passed. Skipped: `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`. - **Binary round trip:** `tests/pixel_aot_check.py binary` with LLVM 15.0.7 exits 0, including a fixture with all three forms. `llvm-mc` runs locally through a `clang -cc1as` shim. - **Other checks:** the controls, `form_coverage_check.py` (three SOPK forms covered, `s_waitcnt_depctr` and `s_waitcnt_expcnt` not), `rdna2_tools_check.py`, `pso_readiness_check.py` and `docs_links_check.py` pass. - **Not measured on GPU:** there is no new draw. The evidence is the identical-HLSL controls and the round trip. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:44:44 +00:00
JB2WIN commented 2026-11-24 06:48:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T02:36:54Z.


Source note on the null-only scope: LLVM 15.0.7 SIInsertWaitcnts.cpp creates these instructions only with SGPR_NULL (L1296-L1297, L1812-L1813), and it asserts that operand for an existing S_WAITCNT_VSCNT (L866). SOPInstructions.td (SOPK_WAITCNT, L933-944) types the operand as SReg_32:$sdst, s16imm:$simm16 but does not define how a non-null SGPR combines with the count. That is why this PR refuses the SGPR form.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7090076547 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/777#issuecomment-7090076547). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T02:36:54Z. --- Source note on the `null`-only scope: LLVM 15.0.7 `SIInsertWaitcnts.cpp` creates these instructions only with `SGPR_NULL` ([L1296-L1297](https://github.com/llvm/llvm-project/blob/llvmorg-15.0.7/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp#L1296-L1297), [L1812-L1813](https://github.com/llvm/llvm-project/blob/llvmorg-15.0.7/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp#L1812-L1813)), and it asserts that operand for an existing `S_WAITCNT_VSCNT` (L866). `SOPInstructions.td` (`SOPK_WAITCNT`, L933-944) types the operand as `SReg_32:$sdst, s16imm:$simm16` but does not define how a non-null SGPR combines with the count. That is why this PR refuses the SGPR form.
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!771
No description provided.