shader: lower packed byte dot products in direct compute #3060

Manually merged
github merged 1 commit from github-bot/gh-3060 into gh-pr/3060/base 2026-11-27 13:59:48 +00:00 AGit
Owner

@⁠RonLogic on GitHub · 2026-11-27 13:13 UTC · original
RonLogic:shader/native-packed-dot4 → main · +199 −8 · 4 files · 1 commits · merged 2026-11-27 13:55 UTC

Change

Refs #2935. Add the gfx1013 VOP3P v_dot4_i32_i8 and v_dot4_u32_u8 instructions to the direct C++ compute path. On fca7c35b, the source-built request is refused as direct ALU operand modifiers at the first dot instruction.

Emit the matching signed or unsigned DXIL packed dot. The ordinary form accumulates with 32-bit wrapping. For clamp, compute the dot with a zero accumulator, then saturate the addition of the guest accumulator. The packed product fits in 32 bits by itself. The clamp path shares the existing halfword multiply-add overflow handling. The canonical VOP3P selectors and zero negation fields are required.

PR #3031 works on the separate HLSL frontend. Its existing conflict in tools/startup/gfx2hlsl.py also occurs against clean main; this branch does not edit that file.

Verification

Tested 7a28de14cf520d548c3481e310932b301518268e on 801f4c3b with Windows 11 build 26300.10075, MSVC 19.52, SDK 10.0.26100 and DXC 1.9.2602.17.

$env:XBOX2WINDOWS_ADAPTER = 'RTX 4070'
$tests = '^(native_(packed_dot4|int16_ternary|perm_lerp|dxil_llvm_ident|absdiff)_.+|compute_store_aot_dot_u_(warp|hardware)|startup_gfx2hlsl_v_dot8_(controls|warp|hardware))$'
foreach ($preset in 'dev', 'release') {
    cmake --build --preset $preset --target compile_dxil native_store_replay offscreen_check
    ctest --preset $preset --no-tests=error -j 1 -R $tests -V
}
  • Debug: 16/16 passed. Release: 16/16 passed. No registered tests skipped.
  • Native RTX 4070 (32.0.16.2124, SM 6.6 / wave32, debug layer off): both the full and sparse EXEC dispatches matched 2,048 result words and 16 guards. The no-clamp replay matched the wrapping reference and differed at 192 words from the clamped reference. Five noncanonical encodings were refused.
  • WARP (10.0.26100.10068, debug layer on for adjacent HLSL fixtures): the related shader checks passed. This WARP adapter exposes 4-lane waves, so the native wave32 replay is inapplicable.
  • python -B tests/docs_links_check.py, python -B tests/bidi_controls_check.py, and git diff --check passed.

Evidence and follow-up

The fixture is generated from synthetic guest instructions under the repository license. It covers signed overflow in both directions, unsigned carry, inputs at the saturation bounds, wraparound, and inactive lanes. The experiment notes cite the AMD ISA and Microsoft DXIL definitions. Native readback on AMD remains unverified.

Checklist

  • One reviewable behavior.
  • Test commands, results and capability limits recorded.
  • Baseline refusal and wrong-output control checked.
  • Experiment notes updated.
  • Diff checked for game files, dumps, distribution links and secrets.

I used Codex to prepare the change and ran verification locally.

**@⁠RonLogic** on GitHub · 2026-11-27 13:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3060) `RonLogic:shader/native-packed-dot4` → `main` · +199 −8 · 4 files · 1 commits · merged 2026-11-27 13:55 UTC ## Change Refs #2935. Add the gfx1013 VOP3P `v_dot4_i32_i8` and `v_dot4_u32_u8` instructions to the direct C++ compute path. On `fca7c35b`, the source-built request is refused as `direct ALU operand modifiers` at the first dot instruction. Emit the matching signed or unsigned DXIL packed dot. The ordinary form accumulates with 32-bit wrapping. For `clamp`, compute the dot with a zero accumulator, then saturate the addition of the guest accumulator. The packed product fits in 32 bits by itself. The clamp path shares the existing halfword multiply-add overflow handling. The canonical VOP3P selectors and zero negation fields are required. PR #3031 works on the separate HLSL frontend. Its existing conflict in `tools/startup/gfx2hlsl.py` also occurs against clean `main`; this branch does not edit that file. ## Verification Tested `7a28de14cf520d548c3481e310932b301518268e` on `801f4c3b` with Windows 11 build 26300.10075, MSVC 19.52, SDK 10.0.26100 and DXC 1.9.2602.17. ```powershell $env:XBOX2WINDOWS_ADAPTER = 'RTX 4070' $tests = '^(native_(packed_dot4|int16_ternary|perm_lerp|dxil_llvm_ident|absdiff)_.+|compute_store_aot_dot_u_(warp|hardware)|startup_gfx2hlsl_v_dot8_(controls|warp|hardware))$' foreach ($preset in 'dev', 'release') { cmake --build --preset $preset --target compile_dxil native_store_replay offscreen_check ctest --preset $preset --no-tests=error -j 1 -R $tests -V } ``` - **Debug: 16/16 passed. Release: 16/16 passed.** No registered tests skipped. - **Native RTX 4070** (`32.0.16.2124`, SM 6.6 / wave32, debug layer off): both the full and sparse EXEC dispatches matched 2,048 result words and 16 guards. The no-clamp replay matched the wrapping reference and differed at 192 words from the clamped reference. Five noncanonical encodings were refused. - **WARP** (`10.0.26100.10068`, debug layer on for adjacent HLSL fixtures): the related shader checks passed. This WARP adapter exposes 4-lane waves, so the native wave32 replay is inapplicable. - `python -B tests/docs_links_check.py`, `python -B tests/bidi_controls_check.py`, and `git diff --check` passed. ## Evidence and follow-up The fixture is generated from synthetic guest instructions under the repository license. It covers signed overflow in both directions, unsigned carry, inputs at the saturation bounds, wraparound, and inactive lanes. The experiment notes cite the AMD ISA and Microsoft DXIL definitions. Native readback on AMD remains unverified. ## Checklist - [x] One reviewable behavior. - [x] Test commands, results and capability limits recorded. - [x] Baseline refusal and wrong-output control checked. - [x] Experiment notes updated. - [x] Diff checked for game files, dumps, distribution links and secrets. I used Codex to prepare the change and ran verification locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:22:34 +00:00
github-bot changed target branch from main to gh-pr/3060/base 2026-11-27 13:59:47 +00:00
github manually merged commit 7a28de14cf into gh-pr/3060/base 2026-11-27 13:59:48 +00:00
Author
Owner

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

Independent review of the exact head integrated over main 36d2cbeb and #2871 (tree 810cde3b931940b7fd7d7514db693802b3e89427). The byte dot alone fits into 32 bits. The unclamped path uses the packed DXIL dot with the guest accumulator, and the clamp path saturates only the final addition. The extracted saturation helper preserves the existing halfword MAD behavior.

Built compile_dxil native_store_replay. Debug and Release /O2 each passed 10/10 with zero skips using ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_(packed_dot4|int16_ternary|perm_lerp|absdiff)_.+|native_dxil_llvm_ident_controls|startup_gfx2hlsl_v_dot8_controls)$'. Full and sparse EXEC each matched 2,048 result words and 16 guards. The malformed modifier and wrapping controls passed. Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK DXC 10.0.26100, replay debug layer off. Native replay needs wave32 and has no WARP case; the PR author reports the adjacent HLSL WARP runs.

**@⁠R0Y00** on GitHub · 2026-11-27 13:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3060#pullrequestreview-6089187535) · **approved these changes** Independent review of the exact head integrated over `main` `36d2cbeb` and #2871 (tree `810cde3b931940b7fd7d7514db693802b3e89427`). The byte dot alone fits into 32 bits. The unclamped path uses the packed DXIL dot with the guest accumulator, and the clamp path saturates only the final addition. The extracted saturation helper preserves the existing halfword MAD behavior. Built `compile_dxil native_store_replay`. Debug and Release `/O2` each passed 10/10 with zero skips using `ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_(packed_dot4|int16_ternary|perm_lerp|absdiff)_.+|native_dxil_llvm_ident_controls|startup_gfx2hlsl_v_dot8_controls)$'`. Full and sparse EXEC each matched 2,048 result words and 16 guards. The malformed modifier and wrapping controls passed. Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK DXC 10.0.26100, replay debug layer off. Native replay needs wave32 and has no WARP case; the PR author reports the adjacent HLSL WARP runs.
This discussion has been locked. Commenting is limited to contributors.
No description provided.