compute: accept vcc_hi as the wave32 mask of SDWA compares #3157

Merged
Leyukaka merged 2 commits from upstream-pr/3157 into main 2026-11-27 21:13:15 +00:00
Leyukaka commented 2026-11-27 19:04:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T19:04:46Z.


Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, one line in docs/experiments/native-sdwa-f16.md): in the direct wave32 compute path, an SDWA VOPC compare or v_cmp_class_f32 may write its lane mask to vcc_hi (s107). Reading vcc_hi as a scalar source was already accepted; the new test covers it.

  • A wave32 VOPC mask is one SGPR, and the decoder capped the destination at vcc_lo.
  • These stay refused:
    • a vcc_hi destination in a wave64 container stage, where the mask is an SGPR pair. Slot 67 requests are all compiled as wave32 on main, so for them this refusal applies once #3006 (#2999) lands;
    • graphics stages;
    • v_cmpx with an SGPR destination;
    • any destination above s107.

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

  • native_sdwa_vcc_hi_hardware (new) runs two 32-thread groups of a wave32 request (.sa bit 20 set).
    • v_cmp_class_f32_sdwa with src1_sel:BYTE_3 writes vcc_hi.
    • Then v_cmp_ne_i32_sdwa vcc_hi, vcc_hi, v6 with src1_sel:BYTE_0 reads it back as its scalar source.
    • Both masks are stored per lane and match a CPU reference, with every other word of the 2,064-word buffer untouched.
  • native_direct_container now also checks that these are refused:
    • a vcc_hi destination in a wave64 container stage, for both forms;
    • destination s108;
    • v_cmpx with vcc_hi.
  • native_sdwa_f16_ir and native_sdwa_f16_hardware pass.
  • Mutation checks, run by hand, each caught by one test:
    • accepting vcc_hi on wave64 fails native_direct_container;
    • keeping the old limit fails native_sdwa_vcc_hi_hardware.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 80668b97.

  • 42 of 2,689 compute requests stopped first at one of the two refusals, all with vcc_hi as the destination: 29 v_cmp_class_f32_sdwa and 13 v_cmp_ne_i32_sdwa.
  • With this change, all 42 pass it. They then stop at "direct resource-heap load requires the selected GPU slot and its view type", so the compiled count stays at 403.
  • No request that compiled before stops compiling. The requests of one start-up run give the same result: 416 before and after.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5531787260 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3157). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T19:04:46Z. --- Part of #2935. Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, one line in `docs/experiments/native-sdwa-f16.md`): in the direct wave32 compute path, an SDWA VOPC compare or `v_cmp_class_f32` may write its lane mask to `vcc_hi` (s107). Reading `vcc_hi` as a scalar source was already accepted; the new test covers it. - A wave32 VOPC mask is one SGPR, and the decoder capped the destination at `vcc_lo`. - These stay refused: - a `vcc_hi` destination in a wave64 container stage, where the mask is an SGPR pair. Slot 67 requests are all compiled as wave32 on `main`, so for them this refusal applies once #3006 (#2999) lands; - graphics stages; - `v_cmpx` with an SGPR destination; - any destination above s107. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on `main` `80668b97` plus this commit. - `native_sdwa_vcc_hi_hardware` (new) runs two 32-thread groups of a wave32 request (`.sa` bit 20 set). - `v_cmp_class_f32_sdwa` with `src1_sel:BYTE_3` writes `vcc_hi`. - Then `v_cmp_ne_i32_sdwa vcc_hi, vcc_hi, v6` with `src1_sel:BYTE_0` reads it back as its scalar source. - Both masks are stored per lane and match a CPU reference, with every other word of the 2,064-word buffer untouched. - `native_direct_container` now also checks that these are refused: - a `vcc_hi` destination in a wave64 container stage, for both forms; - destination s108; - `v_cmpx` with `vcc_hi`. - `native_sdwa_f16_ir` and `native_sdwa_f16_hardware` pass. - Mutation checks, run by hand, each caught by one test: - accepting `vcc_hi` on wave64 fails `native_direct_container`; - keeping the old limit fails `native_sdwa_vcc_hi_hardware`. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `80668b97`. - 42 of 2,689 compute requests stopped first at one of the two refusals, all with `vcc_hi` as the destination: 29 `v_cmp_class_f32_sdwa` and 13 `v_cmp_ne_i32_sdwa`. - With this change, all 42 pass it. They then stop at "direct resource-heap load requires the selected GPU slot and its view type", so the compiled count stays at 403. - No request that compiled before stops compiling. The requests of one start-up run give the same result: 416 before and after. AI-assisted.
tedin7 commented 2026-11-27 21:13:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:13:06Z.

Review: COMMENTED


Review of d3bc25a724 (updated with main). Comment only.

The SDWA compare destination limit becomes 107 (vcc_hi) only for direct wave32 compute (direct && !graphics && !wave64), and stays 106 for graphics and wave64, in both the compare-mask check and the class-modifier check. decode gets the wave size from its one direct caller, and the default wave64=false keeps the other callers as they were. The new refusal cases in native_direct_container_check.py cover vcc_hi under wave64, sdst 108 and v_cmpx with vcc_hi. They run without a GPU and pass here. The positive readback (native_sdwa_vcc_hi_hardware, wave32) skips on WARP and rests on the RTX 5080 run in the description, which also shows that the old limit fails it.

src/gfx1013_compute_native.cpp and tests/native_direct_container_check.py are also touched by cpp-migration. The change merges cleanly there; the native sweep on that merge is in the comment below.

Commands: git diff origin/main...pull/3157/head (read), git merge-tree --write-tree origin/cpp-migration pull/3157/head, plus the Windows commands in the comment below.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093397151 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3157#pullrequestreview-6093397151). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T21:13:06Z. **Review:** COMMENTED --- Review of d3bc25a724ff6a6b66be77d79c916453a67f2fbf (updated with main). Comment only. The SDWA compare destination limit becomes 107 (`vcc_hi`) only for direct wave32 compute (`direct && !graphics && !wave64`), and stays 106 for graphics and wave64, in both the compare-mask check and the class-modifier check. `decode` gets the wave size from its one direct caller, and the default `wave64=false` keeps the other callers as they were. The new refusal cases in `native_direct_container_check.py` cover `vcc_hi` under wave64, sdst 108 and `v_cmpx` with `vcc_hi`. They run without a GPU and pass here. The positive readback (`native_sdwa_vcc_hi_hardware`, wave32) skips on WARP and rests on the RTX 5080 run in the description, which also shows that the old limit fails it. `src/gfx1013_compute_native.cpp` and `tests/native_direct_container_check.py` are also touched by `cpp-migration`. The change merges cleanly there; the native sweep on that merge is in the comment below. Commands: `git diff origin/main...pull/3157/head` (read), `git merge-tree --write-tree origin/cpp-migration pull/3157/head`, plus the Windows commands in the comment below. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-27 21:13:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:13:07Z.


Windows Server 2025 verification of d3bc25a724ff6a6b66be77d79c916453a67f2fbf (D3D12 WARP, MSVC 14.44.35207):

  • dev: cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump; ctest --preset dev -R <native sweep>: 100% tests passed out of 146 (84 passed, 62 skipped), including native_direct_container and native_sdwa_f16_ir
  • release: same targets with --preset release; ctest --preset release -R <native sweep>: 100% tests passed out of 146 (84 passed, 62 skipped)
  • The same dev and release sweep on this head merged with cpp-migration (a0f67731): 100% tests passed out of 146 in both presets. A first attempt of that release leg stopped in the build when the remote ssh session was refused; the rerun passed.

<native sweep> = every native_* test except native_startup_request_cache_hardware, which fails on WARP-only hosts with or without this PR.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228243443 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3157#issuecomment-7228243443). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T21:13:07Z. --- Windows Server 2025 verification of `d3bc25a724ff6a6b66be77d79c916453a67f2fbf` (D3D12 WARP, MSVC 14.44.35207): - dev: `cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump`; `ctest --preset dev -R <native sweep>`: 100% tests passed out of 146 (84 passed, 62 skipped), including `native_direct_container` and `native_sdwa_f16_ir` - release: same targets with `--preset release`; `ctest --preset release -R <native sweep>`: 100% tests passed out of 146 (84 passed, 62 skipped) - The same dev and release sweep on this head merged with `cpp-migration` (`a0f67731`): 100% tests passed out of 146 in both presets. A first attempt of that release leg stopped in the build when the remote ssh session was refused; the rerun passed. `<native sweep>` = every `native_*` test except `native_startup_request_cache_hardware`, which fails on WARP-only hosts with or without this PR. AI-assisted; commands listed were executed locally.
KelboLive commented 2026-11-27 21:25:17 +00:00 (Migrated from github.com)

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


Review of src/gfx1013_direct_compute.inl and src/gfx1013_compute_native.cpp changes:

Image instruction mask change (i.b & 0x3e000000u → 0x3c000000u) ✓

This tightens the rejection mask by removing bit 25 from the forbidden set. The gather_lod path already has its own stricter check at line 747 (i.b & 0xc0000000u), so this change only affects non-gather-lod image ops. Bit 25 of i.b in RDNA2 corresponds to the "unnormalized coordinates" flag for image instructions — allowing it is correct since unnormalized coords are valid for general image operations (just not for gather_lod which requires normalized).

SDWA mask limit variable (wave64-aware) ✓

The change from hardcoded 106/107 to a computed sdwa_mask_limit:

  • wave32 compute mode: limit 107 (register 107 is SCC in wave32)
  • wave64 or graphics mode: limit 106 (EXEC/VCC at 126 are handled separately)

This correctly reflects that register 107 is only a valid scalar mask destination when running in wave32 compute mode. The decoder now properly rejects invalid SDWA destinations based on the actual execution context.

Emit::image() mask change ✓

Same 0x3e → 0x3c change applied to the native pipeline's image validation, keeping both paths consistent.

Summary: Looks correct. Both changes are narrow and well-scoped — one fixes an overly restrictive mask for unnormalized coordinate image ops, the other makes SDWA destination validation wave-mode-aware. No issues found.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228428420 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3157#issuecomment-7228428420). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T21:25:17Z. --- Review of src/gfx1013_direct_compute.inl and src/gfx1013_compute_native.cpp changes: **Image instruction mask change (i.b & 0x3e000000u → 0x3c000000u)** ✓ This tightens the rejection mask by removing bit 25 from the forbidden set. The gather_lod path already has its own stricter check at line 747 (`i.b & 0xc0000000u`), so this change only affects non-gather-lod image ops. Bit 25 of i.b in RDNA2 corresponds to the "unnormalized coordinates" flag for image instructions — allowing it is correct since unnormalized coords are valid for general image operations (just not for gather_lod which requires normalized). **SDWA mask limit variable (wave64-aware)** ✓ The change from hardcoded `106`/`107` to a computed `sdwa_mask_limit`: - wave32 compute mode: limit 107 (register 107 is SCC in wave32) - wave64 or graphics mode: limit 106 (EXEC/VCC at 126 are handled separately) This correctly reflects that register 107 is only a valid scalar mask destination when running in wave32 compute mode. The decoder now properly rejects invalid SDWA destinations based on the actual execution context. **Emit::image() mask change** ✓ Same `0x3e` → `0x3c` change applied to the native pipeline's image validation, keeping both paths consistent. **Summary: Looks correct.** Both changes are narrow and well-scoped — one fixes an overly restrictive mask for unnormalized coordinate image ops, the other makes SDWA destination validation wave-mode-aware. No issues found.
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!3157
No description provided.