compute: copy descriptor words through VCC as a scalar temporary, wave64 SMEM loads and lane spills #3329

Merged
Leyukaka merged 2 commits from upstream-pr/3329 into main 2026-11-28 22:03:29 +00:00
Leyukaka commented 2026-11-28 09:49:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T09:49:41Z.


Part of #3224 (claimed there). Target branch main.

Some direct compute programs park descriptor words in VCC and move them back, for example s_mov_b64 vcc, s[18:19] while s[18:19] hold the upper words of a buffer descriptor. The move into s106/s107 refused at once with "descriptor used as mask", although VCC is only a scalar temporary there.

Change 1 (src/gfx1013_direct_compute.inl, first commit):

  • In compute, s_mov_b32 and aligned s_mov_b64 copy each word into or out of s106/s107 with its symbol, as for other SGPRs.
    • An indexed descriptor keeps its runtime slot index, and a heap offset keeps its byte offset.
    • transfer() in src/gfx1013_compute_native.cpp already copies both symbols, and VOPC and carry writes already make VCC numeric again (s106 only in wave32).
  • Every consumer that reads VCC as a mask or as numeric data checks that the VCC words reaching it are numeric, and refuses otherwise:
    • the operand reader (limit raised to s107 for VCC in compute);
    • carry-in and v_cndmask;
    • the scalar matches that bypass the operand reader;
    • DPP with a preserved destination;
    • SMEM offsets (already the case on main);
    • s_cbranch_vccz/vccnz, on s106 in wave32 and on both words in wave64.
  • EXEC and M0 stay refused as before.

Change 2 (src/gfx1013_direct_compute.inl, src/gfx1013_compute_native.cpp, second commit):

  • Wave64 table and heap-offset descriptor loads (s_load_dwordx4/x8) may end at s106/s107; the "symbolic scalar memory destination overlaps wave64 VCC" refusal is removed and the load writes the descriptor symbols there (shown for table loads; a heap-offset load into s[104:107] now reaches the heap contract check).
  • v_writelane_b32 and v_readlane_b32 spill and reload s106/s107 like other SGPRs (bound raised from s105 to s107 in both files); a symbolic reload into anything above s107 is still refused.
  • A later read of VCC as a mask still refuses with "unbound numeric SGPR s106".

Tests for change 1. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on main 32dc3d7c plus the first commit.

  • The new native_vcc_descriptor_copy_controls:
    • loads a descriptor into s[16:19] and parks s[18:19] in VCC, with one pair move or two word moves;
    • clears s[18:19], moves VCC back and stores through s[16:19];
    • checks that each round trip, wave32 and wave64, gives the same single raw UAV store call as the program without it;
    • checks that the park followed by s_cbranch_vccz, by v_cndmask_b32 with VCC, or by s_mov_b64 exec, vcc is refused.
  • With main's compile_dxil the round trip is refused at the park with "descriptor used as mask", so the test fails there.
  • native_vcc_descriptor_copy_hardware passes on the RTX 5080: 320 output and guard words for each of the four round trips. native_vcc_descriptor_copy_warp reports a capability skip (77).
  • ctest -R "native_|startup_compute|compile_dxil|salu": 528 of 529 pass, plus one transient failure.
    • native_scalar_lds_hardware fails as on main.
    • cpu_native_exe_termination failed once during the parallel run and passes when run alone.
  • I measured my local set of 882 captured compute requests with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests (counts only):
    • 250 compile on main 3f780716, and 251 with this commit (the commits from 3f780716 to 32dc3d7c only touch tools/probe_root_devices.py and its tests);
    • the added program is 4,282 dispatches in that run;
    • none is lost, and the 250 programs that already compiled produce byte-identical output.
    • The other 3 programs with this refusal now stop at v_dot4_i32_i8 with op_sel_hi:[1,0,1]. That stays refused: as I wrote on #3224, its semantics for an inline constant are not established.

Tests for change 2. Same setup, on main 8ecd30fe plus both commits.

  • New native_vcc_descriptor_copy_{smem_store,smem_mask,smem_range,spill_image,spill_mask}: a wave64 x4 load into s[104:107] stored through directly; the same load followed by s_cbranch_vccnz (refused); an x8 load into s[104:111] (refused as a range); an x8 image descriptor in s[100:107] spilled to a VGPR with v_writelane_b32 (s100..s105, vcc_lo, vcc_hi), cleared, reloaded and used by image_store; the same spill followed by s_cbranch_vccnz (refused). native_direct_container and native_heap_offset_add now expect the accepted load or the heap contract instead of the overlap refusal.
  • ctest -R "^(native_vcc_descriptor_copy_.*|native_direct_container|native_heap_offset_add|native_lane_access.*)$": 10 pass, native_vcc_descriptor_copy_warp skips (77). ctest -R "native_|compile_dxil|salu" after a full build: all pass except native_fixed_mesh57_waterfall_fine_hardware and native_scalar_lds_hardware, which fail on main too.
  • Mutations: the v_writelane_b32 source bound back to <= 105 in gfx1013_direct_compute.inl makes spill_image and spill_mask fail; restoring the SMEM overlap refusal makes smem_store, smem_mask, native_direct_container and native_heap_offset_add fail.
  • On the 900 s census in #3224 (compile_dxil --jobs 4 gfx1013-direct-cs@0 --requests), four programs stopped at the SMEM overlap and then at the vcc_lo/vcc_hi spill; they now pass both. Three then stop at direct descriptor address outside bound table (#3221) and one at unbound numeric SGPR s61, so none compiles with this alone.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5538906189 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3329). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T09:49:41Z. --- Part of #3224 (claimed there). Target branch `main`. Some direct compute programs park descriptor words in VCC and move them back, for example `s_mov_b64 vcc, s[18:19]` while s[18:19] hold the upper words of a buffer descriptor. The move into s106/s107 refused at once with "descriptor used as mask", although VCC is only a scalar temporary there. **Change 1** (`src/gfx1013_direct_compute.inl`, first commit): - In compute, `s_mov_b32` and aligned `s_mov_b64` copy each word into or out of s106/s107 with its symbol, as for other SGPRs. - An indexed descriptor keeps its runtime slot index, and a heap offset keeps its byte offset. - `transfer()` in `src/gfx1013_compute_native.cpp` already copies both symbols, and VOPC and carry writes already make VCC numeric again (s106 only in wave32). - Every consumer that reads VCC as a mask or as numeric data checks that the VCC words reaching it are numeric, and refuses otherwise: - the operand reader (limit raised to s107 for VCC in compute); - carry-in and `v_cndmask`; - the scalar matches that bypass the operand reader; - DPP with a preserved destination; - SMEM offsets (already the case on `main`); - `s_cbranch_vccz`/`vccnz`, on s106 in wave32 and on both words in wave64. - EXEC and M0 stay refused as before. **Change 2** (`src/gfx1013_direct_compute.inl`, `src/gfx1013_compute_native.cpp`, second commit): - Wave64 table and heap-offset descriptor loads (`s_load_dwordx4`/`x8`) may end at s106/s107; the "symbolic scalar memory destination overlaps wave64 VCC" refusal is removed and the load writes the descriptor symbols there (shown for table loads; a heap-offset load into s[104:107] now reaches the heap contract check). - `v_writelane_b32` and `v_readlane_b32` spill and reload s106/s107 like other SGPRs (bound raised from s105 to s107 in both files); a symbolic reload into anything above s107 is still refused. - A later read of VCC as a mask still refuses with "unbound numeric SGPR s106". **Tests for change 1.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on `main` `32dc3d7c` plus the first commit. - The new `native_vcc_descriptor_copy_controls`: - loads a descriptor into s[16:19] and parks s[18:19] in VCC, with one pair move or two word moves; - clears s[18:19], moves VCC back and stores through s[16:19]; - checks that each round trip, wave32 and wave64, gives the same single raw UAV store call as the program without it; - checks that the park followed by `s_cbranch_vccz`, by `v_cndmask_b32` with VCC, or by `s_mov_b64 exec, vcc` is refused. - With `main`'s `compile_dxil` the round trip is refused at the park with "descriptor used as mask", so the test fails there. - `native_vcc_descriptor_copy_hardware` passes on the RTX 5080: 320 output and guard words for each of the four round trips. `native_vcc_descriptor_copy_warp` reports a capability skip (77). - `ctest -R "native_|startup_compute|compile_dxil|salu"`: 528 of 529 pass, plus one transient failure. - `native_scalar_lds_hardware` fails as on `main`. - `cpu_native_exe_termination` failed once during the parallel run and passes when run alone. - I measured my local set of 882 captured compute requests with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` (counts only): - 250 compile on `main` `3f780716`, and 251 with this commit (the commits from `3f780716` to `32dc3d7c` only touch `tools/probe_root_devices.py` and its tests); - the added program is 4,282 dispatches in that run; - none is lost, and the 250 programs that already compiled produce byte-identical output. - The other 3 programs with this refusal now stop at `v_dot4_i32_i8` with `op_sel_hi:[1,0,1]`. That stays refused: as I wrote on #3224, its semantics for an inline constant are not established. **Tests for change 2.** Same setup, on `main` `8ecd30fe` plus both commits. - New `native_vcc_descriptor_copy_{smem_store,smem_mask,smem_range,spill_image,spill_mask}`: a wave64 x4 load into s[104:107] stored through directly; the same load followed by `s_cbranch_vccnz` (refused); an x8 load into s[104:111] (refused as a range); an x8 image descriptor in s[100:107] spilled to a VGPR with `v_writelane_b32` (s100..s105, `vcc_lo`, `vcc_hi`), cleared, reloaded and used by `image_store`; the same spill followed by `s_cbranch_vccnz` (refused). `native_direct_container` and `native_heap_offset_add` now expect the accepted load or the heap contract instead of the overlap refusal. - `ctest -R "^(native_vcc_descriptor_copy_.*|native_direct_container|native_heap_offset_add|native_lane_access.*)$"`: 10 pass, `native_vcc_descriptor_copy_warp` skips (77). `ctest -R "native_|compile_dxil|salu"` after a full build: all pass except `native_fixed_mesh57_waterfall_fine_hardware` and `native_scalar_lds_hardware`, which fail on `main` too. - Mutations: the `v_writelane_b32` source bound back to `<= 105` in `gfx1013_direct_compute.inl` makes `spill_image` and `spill_mask` fail; restoring the SMEM overlap refusal makes `smem_store`, `smem_mask`, `native_direct_container` and `native_heap_offset_add` fail. - On the 900 s census in #3224 (`compile_dxil --jobs 4 gfx1013-direct-cs@0 --requests`), four programs stopped at the SMEM overlap and then at the `vcc_lo`/`vcc_hi` spill; they now pass both. Three then stop at `direct descriptor address outside bound table` (#3221) and one at `unbound numeric SGPR s61`, so none compiles with this alone.
Leyukaka commented 2026-11-28 20:21:27 +00:00 (Migrated from github.com)

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


Rebased on main 8ecd30fe and added a second commit for the wave64 SMEM refusal claimed on #3224: table and heap-offset descriptor loads may end at s106/s107, and v_writelane_b32/v_readlane_b32 carry those words like other SGPRs. The body now covers both commits, with tests, mutations and the census result (the four programs get past both VCC refusals; none compiles with this alone).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7245226453 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3329#issuecomment-7245226453). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T20:21:27Z. --- Rebased on `main` `8ecd30fe` and added a second commit for the wave64 SMEM refusal claimed on #3224: table and heap-offset descriptor loads may end at s106/s107, and `v_writelane_b32`/`v_readlane_b32` carry those words like other SGPRs. The body now covers both commits, with tests, mutations and the census result (the four programs get past both VCC refusals; none compiles with this alone).
tedin7 commented 2026-11-28 22:03:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T22:03:25Z.

Review: COMMENTED


Reviewed head 95414551.

Code read (gfx1013_direct_compute.inl, gfx1013_compute_native.cpp): s_mov_b32/s_mov_b64 now copy each word per identity into or out of s106/s107 in compute; every VCC consumer found in the diff (operand reader, carry-in and v_cndmask, scalar bypass matches, DPP with preserved destination, s_cbranch_vccz/vccnz, lane read/write) first requires the VCC words to be numeric and refuses otherwise. EXEC and M0 stay refused. The wave64 SMEM overlap refusal is removed only for table and heap-offset loads, with the new SMEM range and mask refusal tests behind it. No issue found.

Verification (Win2025, dev and release, this head):

  • x2w_pipe.py win2025 3329 --regex 'native_vcc_descriptor_copy|native_direct_container|native_heap_offset_add': 10/10 passed on dev and 10/10 on release, including native_vcc_descriptor_copy_warp and _hardware.
  • Required CI on the head is green; 1 commit behind main; no change requests.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100272427 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3329#pullrequestreview-6100272427). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T22:03:25Z. **Review:** COMMENTED --- Reviewed head 95414551. Code read (`gfx1013_direct_compute.inl`, `gfx1013_compute_native.cpp`): `s_mov_b32`/`s_mov_b64` now copy each word per identity into or out of s106/s107 in compute; every VCC consumer found in the diff (operand reader, carry-in and `v_cndmask`, scalar bypass matches, DPP with preserved destination, `s_cbranch_vccz/vccnz`, lane read/write) first requires the VCC words to be numeric and refuses otherwise. EXEC and M0 stay refused. The wave64 SMEM overlap refusal is removed only for table and heap-offset loads, with the new SMEM range and mask refusal tests behind it. No issue found. Verification (Win2025, dev and release, this head): - `x2w_pipe.py win2025 3329 --regex 'native_vcc_descriptor_copy|native_direct_container|native_heap_offset_add'`: 10/10 passed on dev and 10/10 on release, including `native_vcc_descriptor_copy_warp` and `_hardware`. - Required CI on the head is green; 1 commit behind main; no change requests. AI-assisted; commands listed were executed locally.
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!3329
No description provided.