Skip to content

Recompiler: saturate packed unsigned dot8 without i64 - #2221

Open
luckyteagirl wants to merge 2 commits into
xcl-dev:mainfrom
luckyteagirl:codex/dot8-clamp-32
Open

luckyteagirl wants to merge 2 commits into
xcl-dev:mainfrom
luckyteagirl:codex/dot8-clamp-32

Conversation

@luckyteagirl

@luckyteagirl luckyteagirl commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1269. This is stacked on #2173: rebased parent commit 5ca41eb retains Normal1919's authorship; this PR's change is 404cde36a101d3502504f679db7e6528b08dc19a. Both commits are rebased onto main 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6 so CI can run. The latest conflicts in crates/xcl/src/gpu/dxil/core_tests.rs and crates/xcl/src/gpu/recomp/tests.rs were test additions; all tests are retained.

On the RX 6800M, the previous clamped v_dot8_u32_u4 direct-DXIL path suspended the device at compute PSO creation, while #2173's unclamped path ran in isolation. The eight unsigned nibble products sum to at most 1,800, so the clamped form can accumulate them in 32 bits and saturate the addition to the accumulator without the old 64-bit sum.

What changed

  • crates/xcl/src/gpu/dxil/lower_wide.rs: use packed dot calls for clamped and unclamped unsigned dot8; for clamped, add the bounded product sum to c and select u32::MAX on unsigned overflow.
  • crates/xcl/src/gpu/recomp/tests.rs: add an isolated clamped GPU regression for zero, exact maximum, and overflow. core_tests.rs expects the clamped form to emit the packed calls.

Tested

  • 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. cargo build --locked --workspace -j 2 and cargo build --locked --release --workspace -j 2 passed on the clean head. git diff --check passed.
  • With XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, cargo test --locked -p xcl --lib -j 2 dot8_u32_u4 -- --test-threads=1 --show-output passed 3/0/0, no skips, for XCL_DIRECT_DXIL=1; the same filter passed 3/0/0, no skips, for XCL_DIRECT_DXIL=0. The GPU fixtures cover native wave64 and wave32; the third test checks emitted DXIL.
  • Full workspace suite, cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output, with XCL_ADAPTER=6800M, XCL_DIRECT_DXIL=1: current main 1a0bbe3 had 1012 passed, 169 failed, 26 ignored in the library; this head had 1013 passed, 172 failed, 26 ignored. Both also failed the same offline_compute_pipeline_is_reused_by_a_second_process integration test. Isolated Cargo targets were used. Three library failure names were added: the parent's dot4_add_u8_packed_matches_cpu and the two dot8 GPU fixtures. All three failed at CreateComputePipelineState after device suspension 0x887A0005, while the dot8 fixtures passed in the focused runs. This broad run is not green on this driver.
  • Before the original code change, the new clamped-only fixture failed at CreateComputePipelineState on this RX 6800M. With local test-only isolation, the old clamped shader failed and DXIL: lower unclamped v_dot8_u32_u4 using Dot4AddU8Packed #2173's unclamped shader passed both wave sizes. Those diagnostic edits were restored before the PR was published.

Regression run

Same owned title, 12 seconds each, default translation mode, separate data/cache directories. Both completed without the external memory guard firing. The title run did not show a dot8 dispatch, so the focused GPU fixture is the direct opcode check.

Main:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 12
exit: 0x0
frames shown: 104 (PresentX 104)
presents per 2 s (last 3): 1 43 60
device removals: 0
crashes: 0
peak commit: 8185 MB

This PR:

xcl-smoke v1
commit: 404cde36a101d3502504f679db7e6528b08dc19a
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 12
exit: 0x0
frames shown: 119 (PresentX 119)
presents per 2 s (last 3): 0 58 60
device removals: 0
crashes: 0
peak commit: 8204 MB

Not tested

  • NVIDIA/other-vendor GPU verification on this rebased head is still requested by the reviewer. Parent DXIL: lower unclamped v_dot8_u32_u4 using Dot4AddU8Packed #2173 had RX 9070 XT, RX 6800M, RTX 3060 and RTX 3060 Ti reports on its earlier head, but they do not verify this new head. No runtime performance benefit is claimed.

AI use

OpenAI Codex (GPT-6; exact variant not exposed in this session) investigated the RX 6800M failure, wrote the 32-bit clamp and regression test, rebased both commits while preserving the parent author's attribution, ran the native Windows builds, GPU tests, workspace comparison and guarded smoke run, and drafted this description. No game data was committed.

@luckyteagirl
luckyteagirl marked this pull request as ready for review November 25, 2026 10:19
@raylitebull

Copy link
Copy Markdown
Member

4830018 currently conflicts in tests.rs against recent main merges. Please rebase onto main (and add dual-vendor GPU test runs on the rebased head) before CI runs.

O5-7 and others added 2 commits November 25, 2026 03:52
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)
The unsigned four-bit dot products total at most 1800. The clamped path can accumulate that bounded sum with Dot4AddU8Packed and saturate c + sum using a 32-bit carry check. This avoids the old wide-sum DXIL that suspends the RX 6800M device in the focused GPU fixture. Add an isolated clamped overflow regression alongside the existing combined edge cases.
@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Test report: AMD Radeon RX 7800 XT (RDNA3, native wave64) for head 404cde36a101d3502504f679db7e6528b08dc19a.

Setup: RX 7800 XT, driver 32.0.31035.1003, Windows 11 Pro 10.0.26200, rustc/cargo 1.100.0, debug build, DXC 1.9.0.5512 (dxc on PATH). Detached checkout of the PR head, which includes ea088a5. I did not merge it with current main. I read the diff before running it.

Targeted (cargo test -p xcl --lib -- dot --nocapture --test-threads=1, XCL_DIRECT_DXIL unset): 6 passed, 0 failed, 0 ignored.

  • dxil::core_tests::dot8_u32_u4_lowers_to_dot4_add_u8_packed
  • dxil::ops_tests::dot4_add_u8_packed_matches_cpu
  • recomp::tests::gpu_v_dot8_u32_u4_edge_cases
  • recomp::tests::gpu_v_dot8_u32_u4_clamped_overflow
  • recomp::tests::gpu_packed_math_dots_movrel
  • one unrelated resolver test matched by the filter

I also ran -- dot8 with XCL_DIRECT_DXIL=1: 3 passed, 0 failed (the two gpu_v_dot8_u32_u4_* tests plus the DXIL lowering test).

Full suite (cargo test --workspace --no-fail-fast -- --test-threads=4, env unset): 1253 passed, 1 failed, 46 ignored.

  • The failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, the known RDNA3 failure on main. The PR does not touch it.
  • 7 SKIPPED lines: 6 in lower_dxil::tests (f16 / f32 conversion programs refused) and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). These are not coverage.

Not tested: retail title or scripts/smoke.ps1, NVIDIA, Intel, Wine/vkd3d, this PR merged with current main.

AI use: this report was run and written by Claude Code (Claude Sonnet 5.5). I read the diff but did not change any code.

@DarkPanda69

Copy link
Copy Markdown

NVIDIA run on this rebased head (requested by the reviewer), plus AMD with native wave64: both new tests pass on both cards.

Head 404cde3 applied on main 379725a, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4:

Not tested: other NVIDIA generations, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@jennydeth

Copy link
Copy Markdown

NVIDIA run on this head (requested in Not tested).

Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head 404cde3.

Result: cargo test --workspace -- --test-threads=4: 1254 passed, 0 failed, 46 ignored. The dot8 tests pass: dot8_u32_u4_lowers_to_dot4_add_u8_packed, gpu_v_dot8_u32_u4_clamped_overflow, gpu_v_dot8_u32_u4_edge_cases. SKIPPED: 18 GPU tests for no wave64 (expected on this card).

One note, likely unrelated to this PR: the first full run aborted in hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels with misaligned pointer dereference: address must be a multiple of 0x8 but is 0x74100001 (windows-core interface.rs:41, STATUS_STACK_BUFFER_OVERRUN). It did not reproduce in three title_textures reruns or in the full rerun above.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants