Skip to content

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

Merged
pigalot merged 1 commit into
R0Y00:mainfrom
Leyukaka:smem-vcc
Nov 27, 2026
Merged

pigalot merged 1 commit into
R0Y00:mainfrom
Leyukaka:smem-vcc

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

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 compute: accept vcc_hi as the wave32 mask of SDWA compares #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:
  • 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

Copy link
Copy Markdown
Contributor

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.

…s a destination

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.
@KelboLive

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator Author

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 pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
pigalot merged commit 63fd6ea into R0Y00:main Nov 27, 2026
5 checks passed
Leyukaka added a commit to Leyukaka/Xbox2Windows that referenced this pull request Nov 28, 2026
Direct wave64 compute now gives scalar loads the same SGPR bound as
wave32 since R0Y00#3180: destination ranges may end at s107 (VCC_HI), and
VCC_LO/VCC_HI may be the SGPR offset. In the direct wave64 model VCC
is two scalar words that both host wave32 halves hold identically
(ballot writers publish both words through the exchange), so a
uniform numeric load into s106/s107 is read back the same way by
s_mov, v_cndmask and the VCC branches. Table descriptor loads and
resource-heap loads at an added byte offset (R0Y00#3253), which track
descriptor identity or a slot index instead of payload bits, still
refuse when their destination overlaps VCC in wave64. Graphics and ranges past
s107 keep their refusals.

New test native_smem_vcc_wave64 (controls, hardware): x4 and x8 loads
ending at s107, VCC_LO and VCC_HI offsets, and a 64-bit mask loaded
into VCC driving v_cndmask in both host halves under a patterned EXEC.
native_direct_container replaces the wave64 VCC refusals it had with a
symbolic-destination refusal.

native_heap_offset_add gains a wave64 control: an added-offset heap
address loaded into s[104:107] refuses with the overlap message.
R0Y00 pushed a commit that referenced this pull request Nov 28, 2026
Direct wave64 compute now gives scalar loads the same SGPR bound as
wave32 since #3180: destination ranges may end at s107 (VCC_HI), and
VCC_LO/VCC_HI may be the SGPR offset. In the direct wave64 model VCC
is two scalar words that both host wave32 halves hold identically
(ballot writers publish both words through the exchange), so a
uniform numeric load into s106/s107 is read back the same way by
s_mov, v_cndmask and the VCC branches. Table descriptor loads and
resource-heap loads at an added byte offset (#3253), which track
descriptor identity or a slot index instead of payload bits, still
refuse when their destination overlaps VCC in wave64. Graphics and ranges past
s107 keep their refusals.

New test native_smem_vcc_wave64 (controls, hardware): x4 and x8 loads
ending at s107, VCC_LO and VCC_HI offsets, and a 64-bit mask loaded
into VCC driving v_cndmask in both host halves under a patterned EXEC.
native_direct_container replaces the wave64 VCC refusals it had with a
symbolic-destination refusal.

native_heap_offset_add gains a wave64 control: an added-offset heap
address loaded into s[104:107] refuses with the overlap message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

direct compute: vcc_lo / vcc_hi as wave32 SMEM offsets and destinations

3 participants