compute: accept vcc_lo and vcc_hi as wave32 SMEM offsets and destinations #3182

Manually merged
github merged 1 commit from github-bot/gh-3180 into gh-pr/3180/base 2026-11-27 21:57:01 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-27 20:31 UTC · original
Leyukaka:smem-vcc → main · +92 −11 · 6 files · 1 commits · merged 2026-11-27 21:54 UTC

Fixes #3173. Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl): in direct wave32 compute, scalar loads accept vcc_lo (s106) and vcc_hi (s107):

  • as their SGPR offset, which must be numeric like any other offset;
  • as destinations, for ranges up to s107.

Details:

  • smem_sgpr_limit() gives 108 for wave32 compute and 106 otherwise. The decoder, transfer() and the emitter's offset reads use it.
  • Wave64 and graphics offsets stay refused. The decoder now refuses any direct compute destination range past the limit (s105 in wave64, s107 in wave32); before, only root-descriptor loads checked it.
  • This adds the same wave64 parameter to decode() as #3159. Whichever lands second gets a small textual conflict that keeps both.

Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on main 0f3e8248 plus this commit.

  • native_smem_vcc_hardware (new) runs a wave32 request. It reads back s_buffer_load_dword with a vcc_lo offset, s_buffer_load_dwordx2 and s_load_dwordx8 with a vcc_hi offset, and a load into vcc_hi, against the expected source words, with intact guards.
  • native_direct_container checks these refusals:
    • a vcc offset on a wave64 container stage;
    • a vcc_hi destination on wave64;
    • a destination range crossing s107;
    • a symbolic (descriptor) value in s106/s107 used as an offset.
  • native_scalar_lds_hardware fails with "native compute PSO creation failed", as it does on main without this change. The other selected tests pass.
  • Mutation check, run by hand: keeping the limit at 106 fails both native_smem_vcc_hardware and native_direct_container.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 6057071b. Since then only #3149 (3a550d0a) touches gfx1013_direct_compute.inl, outside the SMEM path.

  • 59 of 2,689 requests stopped first at "unsupported scalar memory addressing". All 59 now pass it:
    • 51 stop at "direct resource-heap load requires the selected GPU slot and its view type";
    • 8 stop at an SDWA v_cmp_class_f32 mask written to vcc_hi, which #3159 handles.
  • The compiled count stays at 403, and no request that compiled before stops compiling. The requests of one start-up run give the same 59.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-27 20:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3180) `Leyukaka:smem-vcc` → `main` · +92 −11 · 6 files · 1 commits · merged 2026-11-27 21:54 UTC Fixes #3173. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, `src/gfx1013_direct_compute.inl`): in direct wave32 compute, scalar loads accept `vcc_lo` (s106) and `vcc_hi` (s107): - as their SGPR offset, which must be numeric like any other offset; - as destinations, for ranges up to s107. Details: - `smem_sgpr_limit()` gives 108 for wave32 compute and 106 otherwise. The decoder, `transfer()` and the emitter's offset reads use it. - Wave64 and graphics offsets stay refused. The decoder now refuses any direct compute destination range past the limit (s105 in wave64, s107 in wave32); before, only root-descriptor loads checked it. - This adds the same `wave64` parameter to `decode()` as #3159. Whichever lands second gets a small textual conflict that keeps both. **Tests.** The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on `main` `0f3e8248` plus this commit. - `native_smem_vcc_hardware` (new) runs a wave32 request. It reads back `s_buffer_load_dword` with a `vcc_lo` offset, `s_buffer_load_dwordx2` and `s_load_dwordx8` with a `vcc_hi` offset, and a load into `vcc_hi`, against the expected source words, with intact guards. - `native_direct_container` checks these refusals: - a `vcc` offset on a wave64 container stage; - a `vcc_hi` destination on wave64; - a destination range crossing s107; - a symbolic (descriptor) value in s106/s107 used as an offset. - `native_scalar_lds_hardware` fails with "native compute PSO creation failed", as it does on `main` without this change. The other selected tests pass. - Mutation check, run by hand: keeping the limit at 106 fails both `native_smem_vcc_hardware` and `native_direct_container`. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `6057071b`. Since then only #3149 (`3a550d0a`) touches `gfx1013_direct_compute.inl`, outside the SMEM path. - 59 of 2,689 requests stopped first at "unsupported scalar memory addressing". All 59 now pass it: - 51 stop at "direct resource-heap load requires the selected GPU slot and its view type"; - 8 stop at an SDWA `v_cmp_class_f32` mask written to `vcc_hi`, which #3159 handles. - The compiled count stays at 403, and no request that compiled before stops compiling. The requests of one start-up run give the same 59. AI-assisted.
In the direct wave32 compute path, vcc_lo (s106) and vcc_hi (s107) are
ordinary scalar data. Scalar loads may now take either as the SGPR
offset, which must be numeric like any other offset, and may write up to
s107. Wave64, graphics, and destination ranges past s107 stay refused.

native_smem_vcc_hardware reads back s_buffer_load_dword(x2) with vcc_lo
and vcc_hi offsets, s_load_dwordx8 with a vcc_hi offset and a load into
vcc_hi; native_direct_container checks the wave64, range and symbolic
offset refusals.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:34:52 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-27 21:00 UTC · original

LGTM! The Wave32 SMEM VCC support is correctly implemented:

Key changes:

  • smem_sgpr_limit() now returns 108 for wave32 compute (vs 106 for wave64), allowing s[106] and s[107] as valid offsets/destinations
  • VCC words are properly recognized as nonnumeric SGPRs in the SMEM validation logic
  • The test fixture native_smem_vcc_check.py verifies reads from vcc_lo/s[106] and vcc_hi/s[107] with proper readback

Implementation notes:

  • The decode function now accepts a wave64 parameter to distinguish between wave32/wave64 modes
  • SMEM offset validation correctly rejects s[106]/s[107] in wave64 mode (as expected)
  • Cross-VCC destination checks prevent invalid configurations

This enables games using VCC registers for scalar memory addressing in Wave32 compute, which is essential for RDNA 3+ compatibility.

**@⁠KelboLive** on GitHub · 2026-11-27 21:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3180#issuecomment-7228043305) LGTM! The Wave32 SMEM VCC support is correctly implemented: **Key changes:** - `smem_sgpr_limit()` now returns 108 for wave32 compute (vs 106 for wave64), allowing s[106] and s[107] as valid offsets/destinations - VCC words are properly recognized as nonnumeric SGPRs in the SMEM validation logic - The test fixture `native_smem_vcc_check.py` verifies reads from vcc_lo/s[106] and vcc_hi/s[107] with proper readback **Implementation notes:** - The decode function now accepts a `wave64` parameter to distinguish between wave32/wave64 modes - SMEM offset validation correctly rejects s[106]/s[107] in wave64 mode (as expected) - Cross-VCC destination checks prevent invalid configurations This enables games using VCC registers for scalar memory addressing in Wave32 compute, which is essential for RDNA 3+ compatibility.
github-bot force-pushed github-bot/gh-3180 from 6fcbd8238f to 578ae9b2ba 2026-11-27 21:17:36 +00:00 Compare
Author
Owner

@⁠KelboLive on GitHub · 2026-11-27 21:17 UTC · original

The title says "accept vcc_lo and vcc_hi as wave32 SMEM offsets", but this PR removes VCC handling from scalar memory operations and drops the wave64 parameter from decode().

**@⁠KelboLive** on GitHub · 2026-11-27 21:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3180#issuecomment-7228309704) The title says "accept vcc_lo and vcc_hi as wave32 SMEM offsets", but this PR **removes** VCC handling from scalar memory operations and drops the `wave64` parameter from `decode()`.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-27 21:22 UTC · original

Thanks for the look. I think that reading may come from a comparison with the pre-rebase branch, which predated #3159. The branch is rebased on 108f554e (#3159), head 578ae9b2, and its diff against that base only adds the wave32 SMEM vcc_lo/vcc_hi handling. decode() keeps the wave64 parameter that #3159 introduced. native_smem_vcc_hardware, native_sdwa_vcc_hi_hardware and native_direct_container pass on the rebased tree.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-27 21:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3180#issuecomment-7228389979) Thanks for the look. I think that reading may come from a comparison with the pre-rebase branch, which predated #3159. The branch is rebased on `108f554e` (#3159), head `578ae9b2`, and its diff against that base only adds the wave32 SMEM `vcc_lo`/`vcc_hi` handling. `decode()` keeps the `wave64` parameter that #3159 introduced. `native_smem_vcc_hardware`, `native_sdwa_vcc_hi_hardware` and `native_direct_container` pass on the rebased tree. AI-assisted.
github-bot changed target branch from main to gh-pr/3180/base 2026-11-27 21:56:59 +00:00
github manually merged commit 578ae9b2ba into gh-pr/3180/base 2026-11-27 21:57:01 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 21:53 UTC · original · approved these changes

Independently reviewed 578ae9b2 integrated over main 2dde49a8 (tree 2c7529a3). The merge is clean and git diff --cached --check is clean.

What I traced. smem_sgpr_limit() is 108 only for direct, non-graphics wave32 compute (decode passes direct && !graphics && !wave64). Graphics, wave64 and non-direct decodes keep the old soffset > 105 rule. The new limit reaches all five SMEM checks: the decode offset check, the new decode destination-range refusal, the transfer() index, the root-descriptor i.dst + n range, and the two operand32(i, so, limit) offset reads. The numeric check then covers s106/s107. Their entry state is unknown (numeric), because initial marks only s0..s105 unbound. A VOPC mask in vcc_lo is lane_mask, so using it as an SMEM offset stays refused. That errs on the safe side. KelboLive's second comment (that the PR removes VCC handling and the wave64 parameter) doesn't match the diff against 108f554e.

What I ran. I built compile_dxil native_store_replay native_wave_request_gpu in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_direct_container|native_smem_vcc_hardware|native_sdwa_vcc_hi_hardware|native_scalar_lds_hardware|native_wave_request_hardware)$'

5/5 pass in Debug and in Release /O2, with no skips. native_smem_vcc_hardware matched 24 result words and all guards. native_scalar_lds_hardware passes here on main and on the merge, so the PSO failure in the description doesn't reproduce on this machine.

Negative control and mutants. Each mutant was rebuilt in dev, then run against native_direct_container and native_smem_vcc_hardware:

Mutant Result
both source files back to main killed: native_smem_vcc_hardware fails, native_direct_container fails at "unsupported root descriptor load range"
wave32 limit 108 → 106 killed (both)
drop the decode destination-range refusal killed (native_direct_container)
root-descriptor range > limit → > 106 killed (native_smem_vcc_hardware)
indexed-descriptor offset operand32(i, so, limit) → operand32(i, so) killed (native_direct_container)
buffer-load offset operand32(i, so, limit) → operand32(i, so) survives
transfer() index < smem_sgpr_limit(...) → <= 105 survives

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking.

  1. The buffer-load numeric check on VCC isn't pinned. The symbolic-offset cases use s_load_dwordx4 (the indexed path), not s_buffer_load_dword. This case, added after the existing wave32-smem-symbolic-offset-* loop, passes on this head and kills the surviving mutant:
    for offset in (106, 107):
        check(f"wave32-smem-buffer-symbolic-offset-{offset}", cs,
              compute(words(0xbe810380, 0xf4080000 | 104 << 6, 125 << 25, 0xf4080000 | 12 << 6, 125 << 25,
                            0xf4200206, offset << 25, end), table=True),
              f"unbound numeric SGPR s{offset}")
    
  2. A VCC index into a descriptor array is not exercised. In transfer() the offset symbol becomes the index_mask of an indexed_descriptor. resource() sizes the binding as 1 + index_mask / 32. With the mutant, an s_load_dwordx4 indexed by a masked vcc_lo would get ~0u instead of the mask. No fixture loads a descriptor through a VCC index, so this branch is still unexercised. That is my reading of the code; I haven't run it.

Verdict: approve on 578ae9b2.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.26100, DXC 1.9.2602.17; Python 3.12.10; wave32. Debug-layer status was not checked.
CI: Build and test on Windows passes on 578ae9b2 (the pr preset doesn't include these tests).

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 21:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3180#pullrequestreview-6093687583) · **approved these changes** Independently reviewed `578ae9b2` integrated over `main` `2dde49a8` (tree `2c7529a3`). The merge is clean and `git diff --cached --check` is clean. **What I traced.** `smem_sgpr_limit()` is 108 only for direct, non-graphics wave32 compute (`decode` passes `direct && !graphics && !wave64`). Graphics, wave64 and non-direct decodes keep the old `soffset > 105` rule. The new limit reaches all five SMEM checks: the decode offset check, the new decode destination-range refusal, the `transfer()` index, the root-descriptor `i.dst + n` range, and the two `operand32(i, so, limit)` offset reads. The numeric check then covers s106/s107. Their entry state is `unknown` (numeric), because `initial` marks only s0..s105 `unbound`. A VOPC mask in `vcc_lo` is `lane_mask`, so using it as an SMEM offset stays refused. That errs on the safe side. KelboLive's second comment (that the PR removes VCC handling and the `wave64` parameter) doesn't match the diff against `108f554e`. **What I ran.** I built `compile_dxil native_store_replay native_wave_request_gpu` in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_direct_container|native_smem_vcc_hardware|native_sdwa_vcc_hi_hardware|native_scalar_lds_hardware|native_wave_request_hardware)$' ``` 5/5 pass in Debug and in Release `/O2`, with no skips. `native_smem_vcc_hardware` matched 24 result words and all guards. `native_scalar_lds_hardware` passes here on `main` and on the merge, so the PSO failure in the description doesn't reproduce on this machine. **Negative control and mutants.** Each mutant was rebuilt in `dev`, then run against `native_direct_container` and `native_smem_vcc_hardware`: | Mutant | Result | |---|---| | both source files back to `main` | killed: `native_smem_vcc_hardware` fails, `native_direct_container` fails at "unsupported root descriptor load range" | | wave32 limit `108` → `106` | killed (both) | | drop the decode destination-range refusal | killed (`native_direct_container`) | | root-descriptor range `> limit` → `> 106` | killed (`native_smem_vcc_hardware`) | | indexed-descriptor offset `operand32(i, so, limit)` → `operand32(i, so)` | killed (`native_direct_container`) | | buffer-load offset `operand32(i, so, limit)` → `operand32(i, so)` | **survives** | | `transfer()` index `< smem_sgpr_limit(...)` → `<= 105` | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** 1. **The buffer-load numeric check on VCC isn't pinned.** The symbolic-offset cases use `s_load_dwordx4` (the indexed path), not `s_buffer_load_dword`. This case, added after the existing `wave32-smem-symbolic-offset-*` loop, passes on this head and kills the surviving mutant: ```python for offset in (106, 107): check(f"wave32-smem-buffer-symbolic-offset-{offset}", cs, compute(words(0xbe810380, 0xf4080000 | 104 << 6, 125 << 25, 0xf4080000 | 12 << 6, 125 << 25, 0xf4200206, offset << 25, end), table=True), f"unbound numeric SGPR s{offset}") ``` 2. **A VCC index into a descriptor array is not exercised.** In `transfer()` the offset symbol becomes the `index_mask` of an `indexed_descriptor`. `resource()` sizes the binding as `1 + index_mask / 32`. With the mutant, an `s_load_dwordx4` indexed by a masked `vcc_lo` would get `~0u` instead of the mask. No fixture loads a descriptor through a VCC index, so this branch is still unexercised. That is my reading of the code; I haven't run it. **Verdict:** approve on `578ae9b2`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.26100, DXC 1.9.2602.17; Python 3.12.10; wave32. Debug-layer status was not checked. CI: `Build and test on Windows` passes on `578ae9b2` (the `pr` preset doesn't include these tests). This reply was AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.