Skip to content

DXIL: lower unclamped v_dot8_u32_u4 using Dot4AddU8Packed - #2173

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
O5-7:dxil/dot8-u32-u4-packed
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
O5-7:dxil/dot8-u32-u4-packed

Conversation

@O5-7

@O5-7 O5-7 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Lower unclamped RDNA2 v_dot8_u32_u4 in the direct DXIL translator using two SM 6.4+ dx.op.dot4AddPacked.i32 (Dot4AddU8Packed, opcode 164) intrinsics instead of unpacking all 8 nibbles into 8 scalar shifts, 16 masks, 8 multiplies, and 8 adds.

Each 32-bit operand is split into two packed byte quads: even nibbles (x & 0x0F0F_0F0F) and odd nibbles ((x >> 4) & 0x0F0F_0F0F), then accumulated with dot4_add_u8_packed(dot4_add_u8_packed(c, a_lo, b_lo), a_hi, b_hi) (mod $2^{32}$). Clamped v_dot8_u32_u4 remains on the 64-bit saturating dot_n path because Dot4AddU8Packed wraps modulo $2^{32}$.

Part of #1269

What is in it

  • crates/xcl/src/gpu/dxil/ops.rs: add Shader::dot4_add_u8_packed(acc, a, b) emitting dx.op.dot4AddPacked.i32(i32 164, acc, a, b).
  • crates/xcl/src/gpu/dxil/shader.rs: register opcode 164 => ReadNone in dxc_fn_attrs.
  • crates/xcl/src/gpu/dxil/lower_wide.rs: lower unclamped v_dot8_u32_u4 via two chained dot4_add_u8_packed calls; keep clamp == true on dot_n.
  • crates/xcl/src/gpu/dxil/ops_tests.rs: add dot4_add_u8_packed_matches_cpu testing the intrinsic on GPU including wrapping $u32$ overflow (dx_op_attrs_match_dxc also verifies dxc_fn_attrs(164)).
  • crates/xcl/src/gpu/dxil/core_tests.rs: add dot8_u32_u4_unclamped_lowers_to_dot4_add_u8_packed verifying DXIL validation and disassembly (2 dx.op.dot4AddPacked.i32(i32 164, calls for unclamped, none for clamped).
  • crates/xcl/src/gpu/recomp/tests.rs: add gpu_v_dot8_u32_u4_edge_cases testing 16 edge cases (even/odd nibbles, 0x0F / 0xF0 isolation, u32::MAX exact threshold and wrapping overflow vs clamped saturation) against CPU reference.
  • Synthetic compute shader measurement (1 and 64 unclamped V_DOT8_U32_U4 instructions, wave32): n = 1 drops 2464 → 2336 bytes (-128 bytes); n = 64 drops 3564 → 3460 bytes (-104 bytes).

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 5080 (driver 32.0.15.9579, wave32), AMD Ryzen 7 9700X, Windows 11 Pro 10.0.26100, rustc 1.100.0, DXC 1.8.2502.11 (XCL_DXC_DIR=D:\Windows Kits\10\bin\10.0.26100.0\x64), debug & release builds.
  • cargo test --workspace -- --test-threads=4: 1157 passed, 0 failed, 46 ignored (24 SKIPPED hardware-capability / policy checks: native wave64 unavailable on RTX 5080 and rejected direct-path f16 arithmetic), including dot4_add_u8_packed_matches_cpu, dx_op_attrs_match_dxc, dot8_u32_u4_unclamped_lowers_to_dot4_add_u8_packed, and gpu_v_dot8_u32_u4_edge_cases.
  • XCL_DIRECT_DXIL=1 targeted GPU parity runs on RTX 5080 (gpu_v_dot8_u32_u4_edge_cases, gpu_clamp_and_omod_per_instruction): both passed.

Regression run
main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1686 (PresentX 1686)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14083 MB

PR:

xcl-smoke v1
commit: 7648fe125ec7926d4ef48a318f8f328c119a5595
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1679 (PresentX 1679)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13622 MB

Not tested

  • Native wave64 GPU execution (skipped automatically on wave32-only RTX 5080 hardware).
  • Running the title with XCL_DIRECT_DXIL=1 in the smoke.ps1 launch (because on unmerged main without PR VFS: exempt xcl.exe and host tool dirs from console drive mounts #2101, D:\Windows Kits\... in XCL_DXC_DIR is intercepted by the {game} D-drive VFS mount inside the host process; XCL_DIRECT_DXIL=1 was verified in unit/GPU tests).

AI use

  • Antigravity (Gemini 4 Neon): added Shader::dot4_add_u8_packed (opcode 164), lowered unclamped v_dot8_u32_u4 to two Dot4AddU8Packed calls, wrote the unit/disassembly/GPU parity tests, and ran the test suite and scripts/smoke.ps1 regression checks.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@DarkPanda69

DarkPanda69 commented Nov 25, 2026 •

Copy link
Copy Markdown

Update for head 7648fe1: same result. Applied on main 50a9fde, gpu_v_dot8_u32_u4_edge_cases passes on the RX 9070 XT (native wave64) and the RTX 3060. Whole gpu:: filter: RX 9070 XT 650 passed, 3 failed; RTX 3060 652 passed, 1 failed. All failures are on main without this PR: a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier on both cards (since #2074's merge, noted there), and on the RX 9070 XT the #2115 fuzz seeds.


Tested: gpu_v_dot8_u32_u4_edge_cases passes on AMD with native 64-lane waves (the case the PR lists as untested), and on an RTX 3060.

Head 07addfb applied on main 568e7db, debug, cargo test -p xcl --lib -- gpu:: --test-threads=4 with XCL_ADAPTER set to each card.
Not tested: a title with XCL_DIRECT_DXIL=1.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent native Windows RX 6800M check of exact PR head 07addfbf6046c4f857ae194c2b7601ef98bd6085 (parent cbc296ab65a2661a61e3e2da109134bcd5319f60). The final worktree is clean; all diagnostic test edits were restored.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M, driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Debug tests with XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64; focused cargo test --locked -p xcl --lib -j 2 <filter> -- --test-threads=1 --show-output runs.

Exact PR head: gpu_v_dot8_u32_u4_edge_cases with XCL_DIRECT_DXIL=0 passed 1/0/0, no skip. With XCL_DIRECT_DXIL=1 it failed 0/1/0 twice at CreateComputePipelineState with device suspension 0x887A0005, before any edge-case output comparison. dot4_add_u8_packed_matches_cpu passed 1/0/0 on the GPU; dot8_u32_u4_unclamped_lowers_to_dot4_add_u8_packed passed 1/0/0 (DXIL validation/disassembly).

Test-only isolation: The fixture normally tries native wave64 first. Forcing its wave list to wave32 only still failed at CreateComputePipelineState (0/1/0). Keeping the new test but restoring only lower_wide.rs from the parent (the old scalar lowering for unclamped dot8) also failed 0/1/0 in the original combined fixture. This does not show a regression caused by the new lowering.

I then kept the PR lowering and locally split the fixture's two instructions. Unclamped-only passed 1/0/0, no skip, across the test's 16 edge-case triples and both wave64 and wave32. Clamped-only failed 0/1/0 at CreateComputePipelineState before comparison. Those local fixture changes were not committed. On this card/driver the combined test's failure is associated with its existing clamped path, while the new unclamped path ran successfully in isolation.

Scope: Focused debug-build synthetic tests only. I did not run the full workspace suite, a paired retail-title smoke, or driver PSO timing. This report does not establish the cause of the clamped-path device suspension.

AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows tests and local controls, checked the logs, restored the clean PR head, and drafted this report. No game data was used.

@raylitebull

Copy link
Copy Markdown
Member

07addfb has dual-vendor verification (RX 9070 XT + RX 6800M + RTX 3060 + RTX 3060 Ti), and now conflicts in tests.rs against recent main merges.

Please rebase onto main so CI can run and get this ready to merge.

@O5-7
O5-7 force-pushed the dxil/dot8-u32-u4-packed branch from 07addfb to 139e000 Compare November 25, 2026 11:47

@O5-7 O5-7 left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raylitebull Rebased onto main (1a0bbe3, after #2180 landed) to resolve the trailing conflicts in crates/xcl/src/gpu/recomp/tests.rs and crates/xcl/src/gpu/dxil/core_tests.rs (now at 6243e73), and re-verified dot8 / dot4_add_u8_packed (both default and XCL_DIRECT_DXIL=1) plus cargo test --workspace -- --test-threads=4 (1184 passed, 0 failed, 26 ignored in --lib, all integration suites green). Ready for CI / merge.

@O5-7
O5-7 force-pushed the dxil/dot8-u32-u4-packed branch from 139e000 to 6243e73 Compare November 25, 2026 11:58
@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 6243e733 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: 6243e733f3015402e8ce6ce631121d95ee80bb8a
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14590 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

Add Shader::dot4_add_u8_packed (dx.op.dot4AddPacked, opcode 164) and
lower unclamped v_dot8_u32_u4 by splitting even and odd 4-bit nibbles
into two packed byte quads and chaining two Dot4AddU8Packed calls.
Leave clamped v_dot8_u32_u4 on the 64-bit saturating dot_n path.

Part of xcl-dev#1269

Assisted-by: Antigravity (Gemini 4 Neon)
@O5-7
O5-7 force-pushed the dxil/dot8-u32-u4-packed branch from 6243e73 to 7648fe1 Compare November 25, 2026 16:42
@raylitebull
raylitebull merged commit 569f0fc into xcl-dev:main Nov 25, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants