Repository navigation
compute: accept vcc_lo and vcc_hi as wave32 SMEM offsets and destinations - #3180
Conversation
|
LGTM! The Wave32 SMEM VCC support is correctly implemented: Key changes:
Implementation notes:
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.
|
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 |
|
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 AI-assisted. |
pigalot
left a comment
There was a problem hiding this comment.
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.
- The buffer-load numeric check on VCC isn't pinned. The symbolic-offset cases use
s_load_dwordx4(the indexed path), nots_buffer_load_dword. This case, added after the existingwave32-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}")
- A VCC index into a descriptor array is not exercised. In
transfer()the offset symbol becomes theindex_maskof anindexed_descriptor.resource()sizes the binding as1 + index_mask / 32. With the mutant, ans_load_dwordx4indexed by a maskedvcc_lowould get~0uinstead 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.
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.
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.
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 acceptvcc_lo(s106) andvcc_hi(s107):Details:
smem_sgpr_limit()gives 108 for wave32 compute and 106 otherwise. The decoder,transfer()and the emitter's offset reads use it.wave64parameter todecode()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
main0f3e8248plus this commit.native_smem_vcc_hardware(new) runs a wave32 request. It reads backs_buffer_load_dwordwith avcc_looffset,s_buffer_load_dwordx2ands_load_dwordx8with avcc_hioffset, and a load intovcc_hi, against the expected source words, with intact guards.native_direct_containerchecks these refusals:vccoffset on a wave64 container stage;vcc_hidestination on wave64;native_scalar_lds_hardwarefails with "native compute PSO creation failed", as it does onmainwithout this change. The other selected tests pass.native_smem_vcc_hardwareandnative_direct_container.Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmain6057071b. Since then only #3147 (3a550d0a) touchesgfx1013_direct_compute.inl, outside the SMEM path.v_cmp_class_f32mask written tovcc_hi, which compute: accept vcc_hi as the wave32 mask of SDWA compares #3157 handles.AI-assisted.