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

Merged
RonLogic merged 1 commit from upstream-pr/3060 into main 2026-11-27 13:55:48 +00:00
RonLogic commented 2026-11-27 13:13:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-27T13:13:38Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5527237496 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3060). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-27T13:13:38Z. --- ## 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.
R0Y00 commented 2026-11-27 13:54:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T13:54:11Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6089187535 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3060#pullrequestreview-6089187535). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T13:54:11Z. **Review:** APPROVED --- 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.
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!3060
No description provided.