compute: accept VCC destination and VCC/EXEC sources in s_quadmask_b64 #3408

Manually merged
github merged 1 commit from github-bot/gh-3406 into main 2026-11-29 08:45:32 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-11-28 22:31 UTC · original
Ammmae0x:compute/s-quadmask-b64-vcc-exec → main · +216 −2 · 4 files · 1 commits · merged 2026-11-29 08:42 UTC

Change

Accept VCC (s106) as the destination and VCC (s106) / EXEC (s126)
as the 64-bit S0 source in s_quadmask_b64 in the direct C++ compute path
(src/gfx1013_direct_compute.inl), so the standard 64-lane quadmask
operations s_quadmask_b64 sD, exec, s_quadmask_b64 vcc, exec and
s_quadmask_b64 sD, vcc no longer refuse.

  • Destination guard: (i.dst & 1) || (i.dst > 104 && i.dst != 106) — VCC
    accepted alongside aligned SGPR pairs; EXEC (126), M0 (124) and
    odd SGPRs still refused with invalid s_quadmask_b64 destination.
  • Source guard: s0_pair now also accepts s0 == 106 || s0 == 126; the
    handler already reads lo = operand32(i, s0) and hi = operand32(i, s0 + 1)
    before writing i.dst / i.dst + 1, so in-place s_quadmask_b64 vcc, vcc
    is safe with no restructuring. SCC = (out_lo != 0) is unchanged. Odd
    SGPRs (23) and M0 (124) still refused with
    invalid s_quadmask_b64 source.

Refs #3226, #2935

Verification

Commit under test: d578e06ed5851677ad688f0718d208dd192e81c6
(compute: accept VCC destination and VCC/EXEC sources in s_quadmask_b64),
branch compute/s-quadmask-b64-vcc-exec from origin/main 0614f68c.

Linux (this host cannot run Windows CTest, compile_dxil or DXC):

  • Offline harness (/tmp/qm_harness.py, not in the repo): decodes every
    case program with tools/disasm_rdna2.py and cross-checks the reference
    against an independent per-lane brute-force quadmask:
    harness OK: 12 cases x wave32/wave64, references, encodings, SCC priming and s0_pair guard all match
  • Empirical spot-mutations, each killed by the harness and restored cleanly
    (run on copies in /tmp, never in the worktree): M1 all-bits reference,
    M2 dropped EXEC restore, M3 plane 1 storing dst instead of dst + 1,
    M4 SCC primed to the expected value, M5 C++ guard dropping s0 == 106 || s0 == 126 — 5/5 killed. Note: M3 survived the first harness version,
    which checked store offsets but not which register each store reads; the
    harness was strengthened to verify the vmove-to-store mapping, and M3 is
    now killed.
  • /tmp/pe-env/bin/python -B tests/form_coverage_check.py — form coverage checks passed
  • /tmp/pe-env/bin/python -B tests/docs_links_check.py — Checked 160 Markdown files and 682 links.
  • /tmp/pe-env/bin/python -B tests/bidi_controls_check.py — Checked 2582 tracked source, script and build/CI files: no bidirectional controls.
  • py_compile on both touched test files — pass. The guard expression
    compiles clean under g++ -std=c++20 -Wall -Wextra (accepts dst 0/104/106
    and s0 0/104/106/126/125/128/208/255; refuses dst 23/105/124/126/127 and
    s0 23/105/124).

Windows verification is still pending (see the WIN-VERIFY tag below):
cmake --build --preset dev --target compile_dxil native_store_replay and
ctest --preset dev --no-tests=error -R '^(native_s_quadmask_vcc_exec_|native_s_quadmask_)' -V,
including native_s_quadmask_vcc_exec_hardware on a real adapter (exit 77
is a skip, not a pass).

Evidence and follow-up

  • New fixture tests/native_s_quadmask_vcc_exec_check.py (+
    tests/cmake/native_s_quadmask_vcc_exec.cmake): 12 cases in wave64 plus
    the mixed-EXEC and in-place-VCC cases in wave32 — 14 hardware dispatches
    total. EXEC sources (zero, low-only, high-only, mixed, all-ones), VCC
    sources (zero, low-only, high-only, mixed), VCC as destination from
    EXEC and in-place from VCC; each case primes SCC opposite to the
    expected SCC = (out_lo != 0) so the quadmask must write SCC itself, and
    verifies dst + 1 == 0. Negative controls refuse EXEC as destination,
    M0 as destination/source and odd SGPR 23 as destination/source, and
    4 reference mutants (all-bits, ignore-hi, swapped halves, SCC-always-zero)
    each differ from the reference.
  • EXEC may be narrowed by the source pair, so the fixture restores EXEC
    to all ones before the vector stores (as in the s_not_b64 template); in
    wave32 this widens EXEC_HI to all ones, which only enables lanes that do
    not exist.
  • The existing tests/native_s_quadmask_check.py needed no change: it has no
    VCC/EXEC refusal for s_quadmask_b64 (only odd dst/src).
  • The gfx2hlsl text translator still refuses s_quadmask_b64 with these
    operands; that is a separate translator, out of this task's scope.
  • docs/experiments/native-s-quadmask.md documents the new destination and
    sources plus the new test.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

Windows Verification (d578e06e)

  • Environment: Windows build 26100, MSVC 19.50.35727.0, adapter NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.15.9186, XBOX2WINDOWS_ADAPTER=NVIDIA), D3D12 debug layer off, commit d578e06ed5851677ad688f0718d208dd192e81c6.
  • cmake --build --preset dev --target compile_dxil native_store_replay -> exit 0
  • cmake --build --preset release --target compile_dxil native_store_replay -> exit 0
  • ctest --preset dev --no-tests=error -R '^(native_s_quadmask_vcc_exec_|native_s_quadmask_)' --output-on-failure -> 4/4 passed (0 skips)
  • ctest --preset release --no-tests=error -R '^(native_s_quadmask_vcc_exec_|native_s_quadmask_)' --output-on-failure -> 4/4 passed (0 skips)
  • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py -> form coverage checks passed (exit 0)
  • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py -> Self-test passed. Checked 160 Markdown files and 682 links. (exit 0)
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py -> Self-test passed. Checked 2584 tracked source, script and build/CI files: no bidirectional controls. (exit 0)
# dev preset (4/4 passed, 0 skips)
2744: s_quadmask_b32/b64 DXIL verified; odd dst/src refused; all-bits and ignore-hi controls differ
1/4 Test #2744: native_s_quadmask_controls ............   Passed    0.70 sec
2745: s_quadmask_b32/b64: 2048 result/SCC words and 16 guards matched
2/4 Test #2745: native_s_quadmask_hardware ............   Passed    0.55 sec
2746: Wave32 and wave64 compile controls and invalid operand refusals passed; 4 reference mutants differ
3/4 Test #2746: native_s_quadmask_vcc_exec_controls ...   Passed    1.54 sec
2747: wave64 exec_zero: both groups and guards matched
2747: wave64 exec_lo_quad0: both groups and guards matched
2747: wave64 exec_hi_quad8: both groups and guards matched
2747: wave64 exec_mixed: both groups and guards matched
2747: wave64 exec_all: both groups and guards matched
2747: wave64 vcc_zero: both groups and guards matched
2747: wave64 vcc_low_only: both groups and guards matched
2747: wave64 vcc_high_only: both groups and guards matched
2747: wave64 vcc_mixed: both groups and guards matched
2747: wave64 dst_vcc_exec: both groups and guards matched
2747: wave64 dst_vcc_vcc: both groups and guards matched
2747: wave64 dst_vcc_exec_zero: both groups and guards matched
2747: wave32 exec_mixed: both groups and guards matched
2747: wave32 dst_vcc_vcc: both groups and guards matched
4/4 Test #2747: native_s_quadmask_vcc_exec_hardware ...   Passed    3.36 sec
The following tests passed:
	native_s_quadmask_controls
	native_s_quadmask_hardware
	native_s_quadmask_vcc_exec_controls
	native_s_quadmask_vcc_exec_hardware
100% tests passed, 0 tests failed out of 4
Total Test time (real) =   6.27 sec

# release preset (4/4 passed, 0 skips)
2744: s_quadmask_b32/b64 DXIL verified; odd dst/src refused; all-bits and ignore-hi controls differ
1/4 Test #2744: native_s_quadmask_controls ............   Passed    0.30 sec
2745: s_quadmask_b32/b64: 2048 result/SCC words and 16 guards matched
2/4 Test #2745: native_s_quadmask_hardware ............   Passed    0.41 sec
2746: Wave32 and wave64 compile controls and invalid operand refusals passed; 4 reference mutants differ
3/4 Test #2746: native_s_quadmask_vcc_exec_controls ...   Passed    1.30 sec
2747: wave64 exec_zero: both groups and guards matched
2747: wave64 exec_lo_quad0: both groups and guards matched
2747: wave64 exec_hi_quad8: both groups and guards matched
2747: wave64 exec_mixed: both groups and guards matched
2747: wave64 exec_all: both groups and guards matched
2747: wave64 vcc_zero: both groups and guards matched
2747: wave64 vcc_low_only: both groups and guards matched
2747: wave64 vcc_high_only: both groups and guards matched
2747: wave64 vcc_mixed: both groups and guards matched
2747: wave64 dst_vcc_exec: both groups and guards matched
2747: wave64 dst_vcc_vcc: both groups and guards matched
2747: wave64 dst_vcc_exec_zero: both groups and guards matched
2747: wave32 exec_mixed: both groups and guards matched
2747: wave32 dst_vcc_vcc: both groups and guards matched
4/4 Test #2747: native_s_quadmask_vcc_exec_hardware ...   Passed    3.18 sec
The following tests passed:
	native_s_quadmask_controls
	native_s_quadmask_hardware
	native_s_quadmask_vcc_exec_controls
	native_s_quadmask_vcc_exec_hardware
100% tests passed, 0 tests failed out of 4
Total Test time (real) =   5.30 sec
**@⁠Ammmae0x** on GitHub · 2026-11-28 22:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3406) `Ammmae0x:compute/s-quadmask-b64-vcc-exec` → `main` · +216 −2 · 4 files · 1 commits · merged 2026-11-29 08:42 UTC ## Change Accept `VCC` (`s106`) as the destination and `VCC` (`s106`) / `EXEC` (`s126`) as the 64-bit `S0` source in `s_quadmask_b64` in the direct C++ compute path (`src/gfx1013_direct_compute.inl`), so the standard 64-lane quadmask operations `s_quadmask_b64 sD, exec`, `s_quadmask_b64 vcc, exec` and `s_quadmask_b64 sD, vcc` no longer refuse. - Destination guard: `(i.dst & 1) || (i.dst > 104 && i.dst != 106)` — `VCC` accepted alongside aligned SGPR pairs; `EXEC` (`126`), `M0` (`124`) and odd SGPRs still refused with `invalid s_quadmask_b64 destination`. - Source guard: `s0_pair` now also accepts `s0 == 106 || s0 == 126`; the handler already reads `lo = operand32(i, s0)` and `hi = operand32(i, s0 + 1)` before writing `i.dst` / `i.dst + 1`, so in-place `s_quadmask_b64 vcc, vcc` is safe with no restructuring. `SCC = (out_lo != 0)` is unchanged. Odd SGPRs (`23`) and `M0` (`124`) still refused with `invalid s_quadmask_b64 source`. Refs #3226, #2935 ## Verification Commit under test: `d578e06ed5851677ad688f0718d208dd192e81c6` (`compute: accept VCC destination and VCC/EXEC sources in s_quadmask_b64`), branch `compute/s-quadmask-b64-vcc-exec` from `origin/main` `0614f68c`. Linux (this host cannot run Windows CTest, `compile_dxil` or DXC): - Offline harness (`/tmp/qm_harness.py`, not in the repo): decodes every case program with `tools/disasm_rdna2.py` and cross-checks the reference against an independent per-lane brute-force quadmask: `harness OK: 12 cases x wave32/wave64, references, encodings, SCC priming and s0_pair guard all match` - Empirical spot-mutations, each killed by the harness and restored cleanly (run on copies in `/tmp`, never in the worktree): M1 all-bits reference, M2 dropped EXEC restore, M3 plane 1 storing `dst` instead of `dst + 1`, M4 SCC primed to the expected value, M5 C++ guard dropping `s0 == 106 || s0 == 126` — 5/5 killed. Note: M3 survived the first harness version, which checked store offsets but not which register each store reads; the harness was strengthened to verify the vmove-to-store mapping, and M3 is now killed. - `/tmp/pe-env/bin/python -B tests/form_coverage_check.py` — `form coverage checks passed` - `/tmp/pe-env/bin/python -B tests/docs_links_check.py` — `Checked 160 Markdown files and 682 links.` - `/tmp/pe-env/bin/python -B tests/bidi_controls_check.py` — `Checked 2582 tracked source, script and build/CI files: no bidirectional controls.` - `py_compile` on both touched test files — pass. The guard expression compiles clean under `g++ -std=c++20 -Wall -Wextra` (accepts dst 0/104/106 and s0 0/104/106/126/125/128/208/255; refuses dst 23/105/124/126/127 and s0 23/105/124). Windows verification is still pending (see the `WIN-VERIFY` tag below): `cmake --build --preset dev --target compile_dxil native_store_replay` and `ctest --preset dev --no-tests=error -R '^(native_s_quadmask_vcc_exec_|native_s_quadmask_)' -V`, including `native_s_quadmask_vcc_exec_hardware` on a real adapter (exit 77 is a skip, not a pass). ## Evidence and follow-up - New fixture `tests/native_s_quadmask_vcc_exec_check.py` (+ `tests/cmake/native_s_quadmask_vcc_exec.cmake`): 12 cases in wave64 plus the mixed-EXEC and in-place-VCC cases in wave32 — 14 hardware dispatches total. `EXEC` sources (zero, low-only, high-only, mixed, all-ones), `VCC` sources (zero, low-only, high-only, mixed), `VCC` as destination from `EXEC` and in-place from `VCC`; each case primes SCC opposite to the expected `SCC = (out_lo != 0)` so the quadmask must write SCC itself, and verifies `dst + 1 == 0`. Negative controls refuse `EXEC` as destination, `M0` as destination/source and odd SGPR `23` as destination/source, and 4 reference mutants (all-bits, ignore-hi, swapped halves, SCC-always-zero) each differ from the reference. - `EXEC` may be narrowed by the source pair, so the fixture restores `EXEC` to all ones before the vector stores (as in the `s_not_b64` template); in wave32 this widens `EXEC_HI` to all ones, which only enables lanes that do not exist. - The existing `tests/native_s_quadmask_check.py` needed no change: it has no VCC/EXEC refusal for `s_quadmask_b64` (only odd dst/src). - The `gfx2hlsl` text translator still refuses `s_quadmask_b64` with these operands; that is a separate translator, out of this task's scope. - `docs/experiments/native-s-quadmask.md` documents the new destination and sources plus the new test. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted. ### Windows Verification (`d578e06e`) - **Environment:** Windows build `26100`, MSVC 19.50.35727.0, adapter `NVIDIA GeForce RTX 4050 Laptop GPU` (driver `32.0.15.9186`, `XBOX2WINDOWS_ADAPTER=NVIDIA`), D3D12 debug layer off, commit `d578e06ed5851677ad688f0718d208dd192e81c6`. - `cmake --build --preset dev --target compile_dxil native_store_replay` -> exit `0` - `cmake --build --preset release --target compile_dxil native_store_replay` -> exit `0` - `ctest --preset dev --no-tests=error -R '^(native_s_quadmask_vcc_exec_|native_s_quadmask_)' --output-on-failure` -> `4/4` passed (`0` skips) - `ctest --preset release --no-tests=error -R '^(native_s_quadmask_vcc_exec_|native_s_quadmask_)' --output-on-failure` -> `4/4` passed (`0` skips) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit `0`) - `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py` -> `Self-test passed. Checked 160 Markdown files and 682 links.` (exit `0`) - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py` -> `Self-test passed. Checked 2584 tracked source, script and build/CI files: no bidirectional controls.` (exit `0`) ```text # dev preset (4/4 passed, 0 skips) 2744: s_quadmask_b32/b64 DXIL verified; odd dst/src refused; all-bits and ignore-hi controls differ 1/4 Test #2744: native_s_quadmask_controls ............ Passed 0.70 sec 2745: s_quadmask_b32/b64: 2048 result/SCC words and 16 guards matched 2/4 Test #2745: native_s_quadmask_hardware ............ Passed 0.55 sec 2746: Wave32 and wave64 compile controls and invalid operand refusals passed; 4 reference mutants differ 3/4 Test #2746: native_s_quadmask_vcc_exec_controls ... Passed 1.54 sec 2747: wave64 exec_zero: both groups and guards matched 2747: wave64 exec_lo_quad0: both groups and guards matched 2747: wave64 exec_hi_quad8: both groups and guards matched 2747: wave64 exec_mixed: both groups and guards matched 2747: wave64 exec_all: both groups and guards matched 2747: wave64 vcc_zero: both groups and guards matched 2747: wave64 vcc_low_only: both groups and guards matched 2747: wave64 vcc_high_only: both groups and guards matched 2747: wave64 vcc_mixed: both groups and guards matched 2747: wave64 dst_vcc_exec: both groups and guards matched 2747: wave64 dst_vcc_vcc: both groups and guards matched 2747: wave64 dst_vcc_exec_zero: both groups and guards matched 2747: wave32 exec_mixed: both groups and guards matched 2747: wave32 dst_vcc_vcc: both groups and guards matched 4/4 Test #2747: native_s_quadmask_vcc_exec_hardware ... Passed 3.36 sec The following tests passed: native_s_quadmask_controls native_s_quadmask_hardware native_s_quadmask_vcc_exec_controls native_s_quadmask_vcc_exec_hardware 100% tests passed, 0 tests failed out of 4 Total Test time (real) = 6.27 sec # release preset (4/4 passed, 0 skips) 2744: s_quadmask_b32/b64 DXIL verified; odd dst/src refused; all-bits and ignore-hi controls differ 1/4 Test #2744: native_s_quadmask_controls ............ Passed 0.30 sec 2745: s_quadmask_b32/b64: 2048 result/SCC words and 16 guards matched 2/4 Test #2745: native_s_quadmask_hardware ............ Passed 0.41 sec 2746: Wave32 and wave64 compile controls and invalid operand refusals passed; 4 reference mutants differ 3/4 Test #2746: native_s_quadmask_vcc_exec_controls ... Passed 1.30 sec 2747: wave64 exec_zero: both groups and guards matched 2747: wave64 exec_lo_quad0: both groups and guards matched 2747: wave64 exec_hi_quad8: both groups and guards matched 2747: wave64 exec_mixed: both groups and guards matched 2747: wave64 exec_all: both groups and guards matched 2747: wave64 vcc_zero: both groups and guards matched 2747: wave64 vcc_low_only: both groups and guards matched 2747: wave64 vcc_high_only: both groups and guards matched 2747: wave64 vcc_mixed: both groups and guards matched 2747: wave64 dst_vcc_exec: both groups and guards matched 2747: wave64 dst_vcc_vcc: both groups and guards matched 2747: wave64 dst_vcc_exec_zero: both groups and guards matched 2747: wave32 exec_mixed: both groups and guards matched 2747: wave32 dst_vcc_vcc: both groups and guards matched 4/4 Test #2747: native_s_quadmask_vcc_exec_hardware ... Passed 3.18 sec The following tests passed: native_s_quadmask_controls native_s_quadmask_hardware native_s_quadmask_vcc_exec_controls native_s_quadmask_vcc_exec_hardware 100% tests passed, 0 tests failed out of 4 Total Test time (real) = 5.30 sec ``` <!-- WIN-VERIFY: passed | sha=d578e06ed5851677ad688f0718d208dd192e81c6 -->
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 22:35:19 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 03:48 UTC · original · approved these changes

Reviewed d578e06e by reading the diff; nothing built or run here. Approve.

  • src/gfx1013_direct_compute.inl:3683: VCC (106) is accepted as the s_quadmask_b64 destination. :3686: VCC or EXEC (126) is accepted as the 64-bit S0 pair. The high word comes from operand32(i, s0 + 1) at :3693 (107/127, accepted at :180-184). lo and hi are read at :3690-3693, before the writes at :3697-3698, so in-place vcc, vcc is safe. EXEC as destination, m0 and odd registers stay refused. The handler body is otherwise unchanged (tools/disasm_rdna2.py:210, docs/experiments.md:8310).
  • On main (212d4b5f) the only tests asserting these two refusal messages are the odd dst/src cases at tests/native_s_quadmask_check.py:100-101, still refused. The gfx2hlsl quadmask refusals belong to a separate translator.
  • Not covered: the 4 "reference mutants" (tests/native_s_quadmask_vcc_exec_check.py:147-155) mutate the Python reference, not the C++. A wrong high word for VCC/EXEC would be caught only by _hardware; _controls checks compilation and the 5 refusals.
  • CI: neither new test runs on this PR, since the pr preset filter (CMakePresets.json:51) has no native_s_quadmask_*. The non-PR job runs the dev preset with -E '_hardware$' (.github/workflows/windows.yml:498), so the _hardware evidence is the author's run reported in the description.
  • Nit: the added ctest -R '^native_s_quadmask_vcc_exec_' line in docs/experiments/native-s-quadmask.md is redundant; -R '^native_s_quadmask_' already matches the new tests.
**@⁠Leyukaka** on GitHub · 2026-11-29 03:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3406#pullrequestreview-6101292666) · **approved these changes** Reviewed `d578e06e` by reading the diff; nothing built or run here. Approve. - `src/gfx1013_direct_compute.inl:3683`: VCC (106) is accepted as the `s_quadmask_b64` destination. `:3686`: VCC or EXEC (126) is accepted as the 64-bit `S0` pair. The high word comes from `operand32(i, s0 + 1)` at `:3693` (107/127, accepted at `:180-184`). `lo` and `hi` are read at `:3690-3693`, before the writes at `:3697-3698`, so in-place `vcc, vcc` is safe. EXEC as destination, `m0` and odd registers stay refused. The handler body is otherwise unchanged (`tools/disasm_rdna2.py:210`, `docs/experiments.md:8310`). - On `main` (212d4b5f) the only tests asserting these two refusal messages are the odd dst/src cases at `tests/native_s_quadmask_check.py:100-101`, still refused. The `gfx2hlsl` quadmask refusals belong to a separate translator. - Not covered: the 4 "reference mutants" (`tests/native_s_quadmask_vcc_exec_check.py:147-155`) mutate the Python reference, not the C++. A wrong high word for VCC/EXEC would be caught only by `_hardware`; `_controls` checks compilation and the 5 refusals. - CI: neither new test runs on this PR, since the `pr` preset filter (`CMakePresets.json:51`) has no `native_s_quadmask_*`. The non-PR job runs the `dev` preset with `-E '_hardware$'` (`.github/workflows/windows.yml:498`), so the `_hardware` evidence is the author's run reported in the description. - Nit: the added `ctest -R '^native_s_quadmask_vcc_exec_'` line in `docs/experiments/native-s-quadmask.md` is redundant; `-R '^native_s_quadmask_'` already matches the new tests.
github manually merged commit 64fc71c54d into main 2026-11-29 08:45:32 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.