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

Merged
Leyukaka merged 1 commit from upstream-pr/3180 into main 2026-11-27 21:54:55 +00:00
Leyukaka commented 2026-11-27 20:31:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T20:31:00Z.


Fixes #3171. 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 #3157. 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 #3147 (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 #3157 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5532722376 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3180). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T20:31:00Z. --- Fixes #3171. 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 #3157. 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 #3147 (`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 #3157 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.
KelboLive commented 2026-11-27 21:00:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T21:00:21Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228043305 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3180#issuecomment-7228043305). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T21:00:21Z. --- 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 commented 2026-11-27 21:17:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T21:17:25Z.


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().

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228309704 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3180#issuecomment-7228309704). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T21:17:25Z. --- 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()`.
Leyukaka commented 2026-11-27 21:22:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T21:22:44Z.


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

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228389979 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3180#issuecomment-7228389979). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T21:22:44Z. --- Thanks for the look. I think that reading may come from a comparison with the pre-rebase branch, which predated #3157. The branch is rebased on `108f554e` (#3157), head `578ae9b2`, and its diff against that base only adds the wave32 SMEM `vcc_lo`/`vcc_hi` handling. `decode()` keeps the `wave64` parameter that #3157 introduced. `native_smem_vcc_hardware`, `native_sdwa_vcc_hi_hardware` and `native_direct_container` pass on the rebased tree. AI-assisted.
pigalot commented 2026-11-27 21:53:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T21:53:35Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093687583 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3180#pullrequestreview-6093687583). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T21:53:35Z. **Review:** APPROVED --- 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.
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!3180
No description provided.