compute: let direct wave64 scalar loads use VCC as scalar data #3267

Manually merged
github merged 1 commit from github-bot/gh-3265 into gh-pr/3265/base 2026-11-28 04:22:10 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-28 02:44 UTC · original
Leyukaka:smem-vcc-wave64 → main · +159 −16 · 7 files · 1 commits · merged 2026-11-28 04:13 UTC

Part of #2935 and #3226. Target branch main. Extends #3182 to direct wave64 compute.

Change. The direct wave64 compute path now gives scalar loads the SGPR bound that wave32 has had since #3182.

  • src/gfx1013_compute_native.cpp, smem_sgpr_limit and its two callers: 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 reads back the same way through s_mov, v_cndmask and the VCC branches. The branches OR the two words.
  • src/gfx1013_direct_compute.inl: the direct compute lowering's own smem_sgpr_limit call takes the same bound. Table descriptor loads track descriptor identity rather than payload bits. In wave64 they now refuse when their destination overlaps VCC, with "symbolic scalar memory destination overlaps wave64 VCC".
  • #3247 and my earlier comment on #3226 said VCC stays refused in wave64, because nothing guarantees both its words. That holds for an unwritten VCC. Here the load itself writes both words with the same value in each host half.
  • Graphics and ranges past s107 keep their refusals.
  • docs/experiments.md: the SMEM note now says wave64 as well.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on main f9286e7d plus this commit.

  • New native_smem_vcc_wave64_controls and _hardware cover, in 64-thread wave64 groups:
    • s_buffer_load_dwordx4 into s[104:107] and s_load_dwordx8 into s[100:107];
    • VCC_LO and VCC_HI as SGPR offsets;
    • a 64-bit mask loaded into VCC that drives v_cndmask_b32 in both host halves, under a patterned EXEC.
  • The readback compares all 2,064 words, guards included, against a CPU reference. A wrong VCC half would change guest lanes 0 and 33.
  • The controls also check that a range ending past s107 refuses.
  • native_direct_container used to check three wave64 decoder refusals: two VCC offsets and a destination at s107. Those decoder refusals no longer apply, and the s107 destination is accepted. It checks the symbolic-destination refusal instead.
  • With main's compile_dxil, the controls stop at "unsupported scalar memory destination range".
  • Mutation checks by hand:
    • restoring the wave32-only bound in the decoder fails both new tests;
    • removing the symbolic-destination refusal fails native_direct_container.
  • On a full build, ctest -R "native_|startup_compute|compile_dxil|salu|smem" passes 435 of 436. native_scalar_lds_hardware fails as on main.

Measured with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, base and change both on main f9286e7d.

  • Local capture of 2,689 requests: 509 to 512 compile. Of the 51 programs that stopped at this refusal, 3 compile. The others stop later:
    • 10 at the resource-heap slot refusal;
    • 9 at "direct descriptor address outside bound table";
    • 9 at "multi-wave64 exchange requires converged group control flow";
    • 8 at "unsupported wave64 scalar operation";
    • 7 at "invalid s_not_b64 source";
    • 2 at the numeric SCC refusal;
    • 1 each at image modifiers, s_ff1_i32_b64 and the global-load refusal.
  • The 882 requests of #3226: no new compile (135). All 17 programs that stopped here stop later.
  • No program that compiled before stops compiling, and no other first refusal changes.
  • Counts and instruction shape only.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-28 02:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3265) `Leyukaka:smem-vcc-wave64` → `main` · +159 −16 · 7 files · 1 commits · merged 2026-11-28 04:13 UTC Part of #2935 and #3226. Target branch `main`. Extends #3182 to direct wave64 compute. **Change.** The direct wave64 compute path now gives scalar loads the SGPR bound that wave32 has had since #3182. - `src/gfx1013_compute_native.cpp`, `smem_sgpr_limit` and its two callers: 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 reads back the same way through `s_mov`, `v_cndmask` and the VCC branches. The branches OR the two words. - `src/gfx1013_direct_compute.inl`: the direct compute lowering's own `smem_sgpr_limit` call takes the same bound. Table descriptor loads track descriptor identity rather than payload bits. In wave64 they now refuse when their destination overlaps VCC, with "symbolic scalar memory destination overlaps wave64 VCC". - #3247 and my earlier comment on #3226 said VCC stays refused in wave64, because nothing guarantees both its words. That holds for an unwritten VCC. Here the load itself writes both words with the same value in each host half. - Graphics and ranges past s107 keep their refusals. - `docs/experiments.md`: the SMEM note now says wave64 as well. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on `main` `f9286e7d` plus this commit. - New `native_smem_vcc_wave64_controls` and `_hardware` cover, in 64-thread wave64 groups: - `s_buffer_load_dwordx4` into s[104:107] and `s_load_dwordx8` into s[100:107]; - VCC_LO and VCC_HI as SGPR offsets; - a 64-bit mask loaded into VCC that drives `v_cndmask_b32` in both host halves, under a patterned EXEC. - The readback compares all 2,064 words, guards included, against a CPU reference. A wrong VCC half would change guest lanes 0 and 33. - The controls also check that a range ending past s107 refuses. - `native_direct_container` used to check three wave64 decoder refusals: two VCC offsets and a destination at s107. Those decoder refusals no longer apply, and the s107 destination is accepted. It checks the symbolic-destination refusal instead. - With `main`'s `compile_dxil`, the controls stop at "unsupported scalar memory destination range". - Mutation checks by hand: - restoring the wave32-only bound in the decoder fails both new tests; - removing the symbolic-destination refusal fails `native_direct_container`. - On a full build, `ctest -R "native_|startup_compute|compile_dxil|salu|smem"` passes 435 of 436. `native_scalar_lds_hardware` fails as on `main`. **Measured** with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`, base and change both on `main` `f9286e7d`. - Local capture of 2,689 requests: 509 to 512 compile. Of the 51 programs that stopped at this refusal, 3 compile. The others stop later: - 10 at the resource-heap slot refusal; - 9 at "direct descriptor address outside bound table"; - 9 at "multi-wave64 exchange requires converged group control flow"; - 8 at "unsupported wave64 scalar operation"; - 7 at "invalid s_not_b64 source"; - 2 at the numeric SCC refusal; - 1 each at image modifiers, `s_ff1_i32_b64` and the global-load refusal. - The 882 requests of #3226: no new compile (135). All 17 programs that stopped here stop later. - No program that compiled before stops compiling, and no other first refusal changes. - Counts and instruction shape only. AI-assisted.
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, which
track descriptor identity 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 02:46:34 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 03:30 UTC · original · reviewed

Review of head a71822e0. The change looks right to me, but the branch now conflicts with main and gh pr update-branch refuses, so it cannot be merged as is.

Conflict. #3255 (merged) added the low.type == Symbol::Type::heap_offset block in src/gfx1013_direct_compute.inl at the same spot as this PR's new wave64 VCC check, right after const bool root = ... in the SMEM branch. They do not interact (one tests Symbol::Type::table, the other heap_offset), so keeping both works. I tested this order:

            const bool root = low.type == Symbol::Type::root_address;
            // Table descriptor lowering tracks identities and slot indices instead of loading payload bits.
            if (wave64 && !graphics_input && i.op < 8 && low.type == Symbol::Type::table &&
                i.dst + memory_count(i) > 106)
                refuse(i.pc, "symbolic scalar memory destination overlaps wave64 VCC");
            if (low.type == Symbol::Type::heap_offset) {
                ... (the #3253 block, unchanged)
            }

src/gfx1013_compute_native.cpp and tests/native_direct_container_check.py merge on their own.

What I checked on the change itself:

  • smem_sgpr_limit now takes direct && !graphics in the decoder and in transfer. For the non-direct path the bound was already 106 in the decoder, so the transfer change does not widen it.
  • The direct lowering uses the same bound, and wave64 table loads that would write symbolic slot words into s106/s107 are refused with the new text.
  • native_smem_vcc_wave64_check.py compares every output word, guards included, with a CPU reference: s[104:107] and s[100:107] loads, VCC_LO/VCC_HI as SGPR offsets, and a loaded 64-bit VCC that drives v_cndmask_b32 under a patterned EXEC.

Commands run, on this head plus the keep-both merge of main above (applied as a patch):

  • Linux: python3 tests/docs_links_check.py ok, python3 tests/bidi_controls_check.py ok, git diff --check clean, python3 -m py_compile on both touched test files ok.
  • Windows Server 2025, D3D12 WARP 1.0.22, -R '^native_(smem_vcc_wave64_controls|smem_vcc_wave64_hardware|direct_container|heap_offset_add|global_srv_heap_replay_warp|wave64_exec_salu_hardware|wrexec64_hardware|s_not_b64_exec_controls|s_not_b64_exec_hardware|compute_clear)$': dev 10/10 passed, release 10/10 passed. native_smem_vcc_wave64_hardware ran on WARP and did not skip.
  • Mutation 1 (decoder bound back to wave32 only): native_smem_vcc_wave64_controls, _hardware and native_direct_container fail.
  • Mutation 2 (direct lowering bound back to wave32 only): native_smem_vcc_wave64_controls and _hardware fail (unsupported root descriptor load range).

Question, not blocking: with this PR a wave64 load may end at s107, and the #3255 heap_offset path writes the slot index into all four destination words without the new overlap refusal. In wave64, s_load_dwordx4 s[104:107] from an added heap address would therefore put the index into VCC. That index is a real uniform value, not a symbolic one, so it may be fine. If you want the two paths to match, the new check could also cover low.type == Symbol::Type::heap_offset.

Once the conflict is resolved on the branch, I can rerun the Windows check on the new head.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 03:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3265#pullrequestreview-6095446457) · **reviewed** Review of head `a71822e0`. The change looks right to me, but the branch now conflicts with `main` and `gh pr update-branch` refuses, so it cannot be merged as is. **Conflict.** #3255 (merged) added the `low.type == Symbol::Type::heap_offset` block in `src/gfx1013_direct_compute.inl` at the same spot as this PR's new wave64 VCC check, right after `const bool root = ...` in the SMEM branch. They do not interact (one tests `Symbol::Type::table`, the other `heap_offset`), so keeping both works. I tested this order: ```cpp const bool root = low.type == Symbol::Type::root_address; // Table descriptor lowering tracks identities and slot indices instead of loading payload bits. if (wave64 && !graphics_input && i.op < 8 && low.type == Symbol::Type::table && i.dst + memory_count(i) > 106) refuse(i.pc, "symbolic scalar memory destination overlaps wave64 VCC"); if (low.type == Symbol::Type::heap_offset) { ... (the #3253 block, unchanged) } ``` `src/gfx1013_compute_native.cpp` and `tests/native_direct_container_check.py` merge on their own. What I checked on the change itself: - `smem_sgpr_limit` now takes `direct && !graphics` in the decoder and in `transfer`. For the non-direct path the bound was already 106 in the decoder, so the `transfer` change does not widen it. - The direct lowering uses the same bound, and wave64 table loads that would write symbolic slot words into s106/s107 are refused with the new text. - `native_smem_vcc_wave64_check.py` compares every output word, guards included, with a CPU reference: s[104:107] and s[100:107] loads, VCC_LO/VCC_HI as SGPR offsets, and a loaded 64-bit VCC that drives `v_cndmask_b32` under a patterned EXEC. Commands run, on this head plus the keep-both merge of `main` above (applied as a patch): - Linux: `python3 tests/docs_links_check.py` ok, `python3 tests/bidi_controls_check.py` ok, `git diff --check` clean, `python3 -m py_compile` on both touched test files ok. - Windows Server 2025, D3D12 WARP 1.0.22, `-R '^native_(smem_vcc_wave64_controls|smem_vcc_wave64_hardware|direct_container|heap_offset_add|global_srv_heap_replay_warp|wave64_exec_salu_hardware|wrexec64_hardware|s_not_b64_exec_controls|s_not_b64_exec_hardware|compute_clear)$'`: dev 10/10 passed, release 10/10 passed. `native_smem_vcc_wave64_hardware` ran on WARP and did not skip. - Mutation 1 (decoder bound back to wave32 only): `native_smem_vcc_wave64_controls`, `_hardware` and `native_direct_container` fail. - Mutation 2 (direct lowering bound back to wave32 only): `native_smem_vcc_wave64_controls` and `_hardware` fail (`unsupported root descriptor load range`). Question, not blocking: with this PR a wave64 load may end at s107, and the #3255 `heap_offset` path writes the slot index into all four destination words without the new overlap refusal. In wave64, `s_load_dwordx4 s[104:107]` from an added heap address would therefore put the index into VCC. That index is a real uniform value, not a symbolic one, so it may be fine. If you want the two paths to match, the new check could also cover `low.type == Symbol::Type::heap_offset`. Once the conflict is resolved on the branch, I can rerun the Windows check on the new head. AI-assisted; commands listed were executed locally.
github-bot force-pushed github-bot/gh-3265 from a71822e0ed to 0c54f12832 2026-11-28 03:42:18 +00:00 Compare
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-28 03:39 UTC · original

Thanks for the review and for testing the keep-both merge. Rebased onto main a44e1f95, new head 0c54f128.

  • Conflict. Resolved with your order: the wave64 refusal sits right after const bool root = ..., before the #3255 heap_offset block, which is unchanged.
  • Your question. I extended the refusal to low.type == Symbol::Type::heap_offset. That path also writes the slot index into dst..dst+3, and in the wave64 model s106/s107 hold VCC as mask data, so the two paths now match. The condition for Symbol::Type::table is the one you reviewed. Wave32 is not affected. On main, a wave64 load ending past s105 was already refused in the decoder (unsupported scalar memory destination range), so no load that was accepted before is refused now.
  • Test. tests/native_heap_offset_add_check.py gains a wave64 control, wave64_vcc_dst: 64x1x1 group with bit 20 of .sa dword 4 clear, s_load_dwordx4 s[104:107], s[10:11], 0x0 (0xF4081A05 0xFA000000) through the added-offset address, expecting symbolic scalar memory destination overlaps wave64 VCC. With heap_offset removed from the condition, this control fails.

A rerun of your Windows check on the new head would be welcome.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-28 03:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3265#issuecomment-7233257146) Thanks for the review and for testing the keep-both merge. Rebased onto main `a44e1f95`, new head `0c54f128`. - **Conflict.** Resolved with your order: the wave64 refusal sits right after `const bool root = ...`, before the #3255 `heap_offset` block, which is unchanged. - **Your question.** I extended the refusal to `low.type == Symbol::Type::heap_offset`. That path also writes the slot index into `dst..dst+3`, and in the wave64 model s106/s107 hold VCC as mask data, so the two paths now match. The condition for `Symbol::Type::table` is the one you reviewed. Wave32 is not affected. On main, a wave64 load ending past s105 was already refused in the decoder (`unsupported scalar memory destination range`), so no load that was accepted before is refused now. - **Test.** `tests/native_heap_offset_add_check.py` gains a wave64 control, `wave64_vcc_dst`: 64x1x1 group with bit 20 of `.sa` dword 4 clear, `s_load_dwordx4 s[104:107], s[10:11], 0x0` (`0xF4081A05 0xFA000000`) through the added-offset address, expecting `symbolic scalar memory destination overlaps wave64 VCC`. With `heap_offset` removed from the condition, this control fails. A rerun of your Windows check on the new head would be welcome. AI-assisted.
github-bot changed target branch from main to gh-pr/3265/base 2026-11-28 04:22:08 +00:00
github manually merged commit 0c54f12832 into gh-pr/3265/base 2026-11-28 04:22:10 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 04:13 UTC · original · approved these changes

The current head 0c54f128 covers both symbolic routes. Ordinary and added-offset heap descriptor loads still refuse destinations overlapping VCC in wave64, and the new wave64_vcc_dst control exercises the added-offset path. The numeric loads and register-offset cases passed the two-host-half readback.

On f41806a9 plus this head (tree fd5c77bc), Debug and Release /O2 each passed 7/7. This included the new controls and hardware readback, heap offset, direct containers, VCC/EXEC NOT and wave64 EXEC. On main fbef6381 plus this head (tree b2c0640a), Release /O2 passed all six focused cases, including the adjacent raw-load and raw-store cache hints:

ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R '^native_(smem_vcc_wave64_(controls|hardware)|heap_offset_add|raw_(load|store)_cache_bits_(controls|hardware))$'

No skips. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK/DXC 10.0.26100.0. The fixtures are source-built.

**@⁠R0Y00** on GitHub · 2026-11-28 04:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3265#pullrequestreview-6095721663) · **approved these changes** The current head `0c54f128` covers both symbolic routes. Ordinary and added-offset heap descriptor loads still refuse destinations overlapping VCC in wave64, and the new `wave64_vcc_dst` control exercises the added-offset path. The numeric loads and register-offset cases passed the two-host-half readback. On `f41806a9` plus this head (tree `fd5c77bc`), Debug and Release /O2 each passed 7/7. This included the new controls and hardware readback, heap offset, direct containers, VCC/EXEC NOT and wave64 EXEC. On main `fbef6381` plus this head (tree `b2c0640a`), Release /O2 passed all six focused cases, including the adjacent raw-load and raw-store cache hints: ```powershell ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R '^native_(smem_vcc_wave64_(controls|hardware)|heap_offset_add|raw_(load|store)_cache_bits_(controls|hardware))$' ``` No skips. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK/DXC 10.0.26100.0. The fixtures are source-built.
This discussion has been locked. Commenting is limited to contributors.
No description provided.