Skip to content

Direct DXIL: lower i64 min/max as compare/select - #1946

Open
luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/dxil-i64-ops
Open

luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/dxil-i64-ops

Conversation

@luckyteagirl

@luckyteagirl luckyteagirl commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1679. On the Radeon RX 6800M with Windows driver 30.0.13002.13003, each dx.op.binary.i64 signed or unsigned min/max variant suspended the D3D12 device during pipeline creation (0x887A0005). This lowers those four forms to i64 comparisons and select. The direct-DXIL source hash from #1947 keys the translated cache, so no manual translator-version bump is needed.

What is in it

  • ops.rs: use signed or unsigned i64 comparison and select for IMax, IMin, UMax, and UMin; other binary operations keep their current path.
  • ops_tests.rs: compare both output words against CPU signed and unsigned min/max across 32 lanes, including equal high words with different low words.

Tested

  • Commit 71acf1f073985faa62ae89701ed35e27199bec1c, based on main 6d12f58a229bc73889878a448c64dc3af25eeba0. Windows 11, AMD Radeon RX 6800M, driver 30.0.13002.13003, DXC/DXIL 1.9.2609.5, XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, XCL_DIRECT_DXIL=1.
  • cargo test --locked -p xcl --lib -j 2 gpu::dxil::ops_tests::int64_bit_ops_match_cpu -- --exact --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 SKIPPED.
  • cargo test --locked -p xcl --lib -j 2 gpu::dxil::ops_tests:: -- --test-threads=2 --nocapture: 24 passed, 0 failed, 0 ignored, 0 SKIPPED.
  • cargo build --locked --release -p xcl --bins -j 2: passed.
  • Previous-head evidence is noted separately from the results above. On previous PR head f90626676934293a7c3c35cccd77c06299bce32d, the focused i64 GPU test passed on an RX 6750 XT. An independent RTX 3080 Ti run reported 1,154 passed, 0 failed, 46 ignored across the workspace; an RX 6600 run of main 2898511 plus this change and Shaders: preserve first active lane reads across divergent switches #2192 reported 1,364 passed, 0 failed, 46 ignored. These are not tests of the rebased commit.
  • The previous-head workspace run on this RX 6800M reported 998 passed, 156 failed, 46 ignored; the failures occurred after device suspension. I did not run a same-base full-suite comparison on the RX 6800M or rerun the full suite on the rebased head.
  • Independently, @cindertheblue ran the exact head 71acf1f and its base 6d12f58 on an RX 7600 XT and Ryzen 5 9600X iGPU. No run lost the device. The seed 783 mismatch count went from 32 to 0 on both GPUs. The RX 7600 XT full suite with XCL_DIRECT_DXIL=1 had one extra failure in a_dispatch_with_a_pipeline_still_building_waits_at_the_submit. That test passed 80 of 80 isolated reruns across the two trees and GPUs. Independent report with full counts.

Regression run

Release binaries, same owned title, RX 6800M, 7 seconds.

Main:

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 9 (PresentX 9)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 6930 MB

PR head:

xcl-smoke v1
commit: 71acf1f073985faa62ae89701ed35e27199bec1c
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 9 (PresentX 9)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 6926 MB

Not tested

  • The short title runs did not exercise the changed direct-DXIL lowering; the focused GPU tests above cover that path. I did not test other adapters, other drivers, or longer title sessions on this rebased head.
  • I did not rerun the full workspace suite on the rebased head. The independent report under Tested covers the debug workspace suite on two other AMD GPUs.

AI use

OpenAI Codex (GPT-6.2) implemented the change and tests in the existing commit; Codex refreshed the rebased-head focused tests, release build, smoke comparison, and this report. Codex also checked the independent results and drafted the description update.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Checked on an RTX 3070 (Ampere, driver 616.56, Windows 11, debug build):

  • At b527347, dxil::/bvh:: units pass (121 passed). The gpu_ tests pass with XCL_DIRECT_DXIL=0 and 1 (110 passed each, same as main).
  • For the separate 64-bit arithmetic-shift mismatch you hit at fuzz seed 540: FUZZ_SEED=540 cargo test -p xcl --lib -- debug_seed --ignored on main 80f4819 reports GPU run: 0 mismatching results here (357 instructions, gpu_safe true). It doesn't reproduce on NVIDIA, so it looks like the RX 6800M driver rather than the translator's lowering.

This PR also bumps TRANSLATOR_VERSION 7→8, as #1950 and #1952 do. Whichever merges later needs the next number.

AI-assisted (Claude Code). Synthetic tests only.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@fallow64

Copy link
Copy Markdown

Confirmed on AMD RX 6750 XT, driver 32.0.21045.5002, Windows 11 build 26200, exact head f9062667.

int64_bit_ops_match_cpu: 1 passed, 0 failed, no skips.

Stacked after #1974, this also clears the seed-783 i64 IMax mismatch.

Not tested: full suite or retail title.

AI use: OpenAI Codex (GPT-5) ran and analyzed the test; I reviewed the result.

Thank you!

@thehollowedone

Copy link
Copy Markdown

Independent Windows run on f906266. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC/DXIL 1.8.2502.11, debug.

cargo build --offline --locked --workspace passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1,154 passed, 0 failed, 46 ignored, with 25 runtime skip notices included in Cargo's pass count. The stock i64 GPU test passed.

A separate Direct DXIL fixture loaded both operands at runtime. Across 32 lanes it checked all four signed and unsigned min/max operations, including signed extrema, equal values, and low-word ordering when the high words were equal. DXC validated the shader. Disassembly showed four i64 compare/select pairs and zero i64 min/max intrinsic calls. All 128 full-width GPU results matched Rust. The original intrinsic path also validated and matched all 128 results on the RTX, with four intrinsic calls in its disassembly.

cargo test --offline --locked -p xcl --lib scratch_i64_min_max_variable_operands -- --nocapture --test-threads=1 passed 1/0/0 with zero skips in each arm. This establishes NVIDIA regression coverage. The older AMD driver behavior and retail were outside this check. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote the fixture, ran the tests, and drafted this report.

oni-swr added a commit to oni-swr/xcl that referenced this pull request Nov 25, 2026
AMD's driver returns x | bfrev(x) for Bfrev.i32(trunc(mul i64)) when the
product is the same on every lane. The i64 Bfrev lowering reverses each
32-bit half after a trunc / lshr of the i64 value, so a Bfrev of an i64
product hit it: fuzz seed 817 (xcl-dev#2115) read 0xfe53ffff for 0x4a43fdeb on an
RX 7800 XT. Reduced to Bfrev.i64(mul i64 3, 5).

The halves are now reversed with five shift-and-mask steps. The i64 case
is the only one that goes through trunc of an i64 value; Bfrev.i32 on a
plain i32 is unchanged. The new test fails without the change on the
RX 7800 XT (low word 0xf000000f, expected 0) and passes with it.

Part of xcl-dev#2115. Seed 783 is a separate driver bug (IMax.i64 after an i64
udiv); the compare / select lowering in xcl-dev#1946 fixes it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…1860, xcl-dev#1913, xcl-dev#2192, xcl-dev#1946, xcl-dev#2237

Integrates XG CopyFromSubresource 7-arg ABI (xcl-dev#684), DirectStorage physical-page list re-read (xcl-dev#1405), vkd3d-proton in-place vtable patching with UnadoptGuard composition (xcl-dev#1395), single-back-edge Direct DXIL CFG (xcl-dev#1860), wave64 graphics Direct DXIL guard (xcl-dev#1913), and AMD RDNA2-4 DXIL fuzz fixes (xcl-dev#2192, xcl-dev#1946, xcl-dev#2237).
@thiagocalile

Copy link
Copy Markdown

Independent Windows AMD Radeon RX 6600 (RDNA2, 8 GB VRAM, native wave64) verification of main 2898511 + #1946 (f906266) + #2192 (1d8341a): all 1,364 workspace tests pass with 0 failures (down from 1 failure, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, on unmodified main 2898511).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • Unmodified main (2898511af1c038a2ef809719e9b6f89e5675c422):
    • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 1,362 passed, 1 failed, 46 ignored (11 skipped; failed: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1).
  • Clean local merge of #1946 (f906266) + #2192 (1d8341a) onto main 2898511:
    • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 1,364 passed, 0 failed, 46 ignored (11 skipped).

Regression run (scripts/smoke.ps1 -Seconds 60, release builds, XCL_ADAPTER=radeon)

main (2898511):

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1489)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 11934 MB

main 2898511 + #1946 (f906266) + #2192 (1d8341a):

xcl-smoke v1
commit: 48282949dc959da8eb78351b8f61a6bd80457500
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1453 (PresentX 1453)
presents per 2 s (last 3): 49 0 59
device removals: 0
crashes: 0
peak commit: 18345 MB

Not tested: #1946 and #2192 individually in isolation, NVIDIA/Intel GPUs, Linux/RADV, or world load past the 60 s smoke window.

AI use: Antigravity (Gemini 4 Neon) ran the merge, workspace tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…1946, xcl-dev#1803, xcl-dev#2297, xcl-dev#2320, xcl-dev#2333

Carries forward still-open high-value upstream PRs onto upstream/main (2898511)
+ our updated Wine PR stack (xcl-dev#867, xcl-dev#1395-successor, xcl-dev#871, xcl-dev#877, xcl-dev#1732).
Preserves UnadoptGuard in xcl-dev#2320 KickoffX reset_one.

Assisted-by: Antigravity (Gemini 4 Neon)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…1946, xcl-dev#1803, xcl-dev#2297, xcl-dev#2320, xcl-dev#2333

Carries forward still-open high-value upstream PRs onto upstream/main (2898511)
+ our updated Wine PR stack (xcl-dev#867, xcl-dev#1395-successor, xcl-dev#871, xcl-dev#877, xcl-dev#1732).
Preserves UnadoptGuard in xcl-dev#2320 KickoffX reset_one.

Assisted-by: Antigravity (Gemini 4 Neon)

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No concrete source-level defect found. Signed/unsigned compare predicates and strict-select semantics are correct, Int64Ops is retained, and the path avoids AMD-problematic binary i64 min/max; focused lane/half tests are good. Current head lacks visible Windows build/test and description reports device-loss cascades in full-suite run without same-base comparison. Refresh full GPU/Windows evidence after investigation; equality cases would be a minor additional guard.

@cindertheblue

Copy link
Copy Markdown
Contributor

Same-base full-suite runs of the rebased head 71acf1f against main 6d12f58 on two AMD GPUs, as asked in the review. No device loss in any run, and the PR adds no failure. On the iGPU it removes the one failure main has (seed 783).

Tested

  • AMD Radeon RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.31041.1004, and the Ryzen 5 9600X iGPU (RDNA2, gfx1036), driver 32.0.21045.5002, on the same machine. Windows 11 Home 26200.9974, rustc 1.99.1, DXC 1.8.2502.11 (SDK 10.0.26100), debug. Each tree in its own folder and Cargo target, cargo build --workspace first, no local changes.
  • cargo test --workspace --no-fail-fast -- --test-threads=4, once each:
main 6d12f58 this PR
RX 7600 XT 1422 passed, 1 failed, 46 ignored 1422 passed, 1 failed, 46 ignored
RX 7600 XT, XCL_DIRECT_DXIL=1 1421 passed, 2 failed, 46 ignored 1420 passed, 3 failed, 46 ignored
iGPU 1422 passed, 1 failed, 46 ignored 1423 passed, 0 failed, 46 ignored
iGPU, XCL_DIRECT_DXIL=1 1421 passed, 2 failed, 46 ignored 1422 passed, 1 failed, 46 ignored
  • fuzz_validate_and_gpu_1 stops at seed 722 on the RX 7600 XT on both trees (Shaders: preserve first active lane reads across divergent switches #2192). On the iGPU it stops at seed 783: res[64] ..., CPU 0x7fffffff on main and passes with this PR.
  • With XCL_DIRECT_DXIL=1, offline_compute_pipeline_is_reused_by_a_second_process (Tests: offline compute pipeline test finds the driver blob with XCL_D… #1674) fails on both trees and both GPUs.
  • The RX 7600 XT XCL_DIRECT_DXIL=1 run of this PR also failed a_dispatch_with_a_pipeline_still_building_waits_at_the_submit once (left: 37, right: 421). Run alone 20 times with XCL_DIRECT_DXIL=1 on each GPU and each tree, it passed 80 of 80, so I read it as a timing flake under the full-suite load, not this change.
  • No 0x887A0005 or device-removed lines in any of the eight logs. The same 8 SKIPPED lines in all eight.
  • debug_seed, FUZZ_SEED=783, with and without XCL_DIRECT_DXIL=1: 32 mismatching on main and 0 with this PR, on both GPUs.
  • int64_bit_ops_match_cpu with XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1: passes 3 of 3 on each GPU, and all 24 ops_tests pass on each. With only ops.rs restored from 6d12f58 it also passes on both, so these drivers don't have the RX 6800M pipeline-creation failure, and the test can't tell the two lowerings apart here.

Not tested: a release build, a title or smoke run, the RX 6800M driver 30.0.13002.13003, NVIDIA.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment from their output.

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.

9 participants