Skip to content

Direct DXIL: sign-extend i1 to i64 through i32 - #1974

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

luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/dxil-i1-sext

Conversation

@luckyteagirl

@luckyteagirl luckyteagirl commented Nov 25, 2026 •

Copy link
Copy Markdown

On the Radeon RX 6800M with Windows driver 30.0.13002.13003, a direct sext i1 to i64 produces 0x00000000ffffffff for a true bit. The expected value is 0xffffffffffffffff. This changes that cast to two sign extensions through i32. The direct-DXIL source hash from #1947 keys the translated cache, so the rebased change needs no manual translator-version bump. The problem was exposed by direct-DXIL fuzz seed 540 after the separate i64 min/max fix in #1946.

What is in it

  • module.rs: route only SExt from i1 to i64 through i32; leave other casts unchanged.
  • ops_tests.rs: check both 32-bit words of the result and an arithmetic shift for 32 lanes on the GPU.

Tested

  • Exact head 848ac65b9a2061c01f4fc7574ab3a156fce5abc6 on main cbc296ab65a2661a61e3e2da109134bcd5319f60. Windows 11 build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, 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::i1_to_i64_sign_extension_and_shift_match_cpu -- --exact --test-threads=1 --nocapture passed, 1 passed, 0 failed, 0 ignored, no explicit skip.
  • cargo build --locked --workspace -j 2, cargo build --locked --release -p xcl -j 2, and git diff --check origin/main...HEAD passed.
  • cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output completed with 993 passed, 162 failed, 46 ignored across the completed binaries. All 162 named failures were gpu:: tests after the RX 6800M device was suspended (0x887A0005). Nine explicit SKIPPED messages included no GPU/device, unavailable D3D12 debug layer, no reserved cube with mips, and no heap windows. I did not run an equivalent full-suite baseline on this new main commit, so these failures are reported without attributing them to this PR.
  • An earlier isolated seed-540 run on a diagnostic tree combining Direct DXIL: lower i64 min/max as compare/select #1946 and this fix had zero mismatching GPU results, versus 21 mismatches before this fix. That evidence is tied to the earlier tree, not the rebased head.
  • A locally owned title completed paired 7-second scripts/smoke.ps1 runs on the RX 6800M. Each revision showed one frame, with no crash or device removal. Peak process commit was 6,911 MB on main and 6,984 MB on the PR.

Regression run

main:

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

PR head:

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

Not tested

  • The short title runs logged zero draws and used default HLSL/DXC routing, so they do not exercise this direct-DXIL cast. The focused GPU test covers the changed cast path.
  • Other adapters and drivers, longer title sessions, and a full-suite comparison on this new main commit.

AI use

OpenAI Codex (GPT-6, exact variant not exposed in this session) isolated and implemented the fix, rebased it, ran the tests and smoke comparisons, reviewed the logs, and drafted this description.

@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 848ac65b.

i1_to_i64_sign_extension_and_shift_match_cpu: 1 passed, 0 failed, no skips.

Base cbc296a reproducibly fails fuzz seed 540 (7, expected 6); this PR clears seed 540.

Not tested: full suite or retail title.

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

Thank you!

@ettehn

ettehn commented Nov 25, 2026 •

Copy link
Copy Markdown

Two narrow Windows checks on 848ac65b.

  • Module::cast currently calls the type-creating i1() / i64() accessors to test the signature. A module-only regression confirmed that an unrelated sext i32 → i64 interns an unused i1; sext i1 → i16 has the analogous issue with i64. Checking the already-interned type IDs/width instead passed both checks, while the affected cast still emitted the two-step sequence.
  • WARP (Windows 11 26200.9974, DXC/DXIL 1.8.2502.11), four threads with no fixed wave size: the sign-extension and seed-540 arithmetic matched all 16 output words when the input’s low bit was explicitly masked first. A separate validated module containing only trunc i32 → i1 and zext i1 → i32 returned [0, 1, 1, 1] for [0, 1, 2, 0x80000000]; and i32 ..., 1 before truncation gave the expected [0, 1, 0, 0]. There is no sext anywhere in that second module. This is a separate WARP observation; the AMD hardware results above address the original cast issue.

Eight-input WARP control. The raw trunc i32 → i1 also sends nonzero even inputs down the true arm when consumed by a conditional branch. A separate (x & 1) != 0 in the same validated shader returned the correct low bit for all eight inputs. There is no sext in the module. In main 568e7db, I only found emission of the i1-destination truncation in the fuzz generator; the runtime lowering calls go to i32. This is evidence about the software test backend and does not require a runtime change for #1974.

AI use — OpenAI Codex (GPT-6) wrote the local checks and ran them.

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.

4 participants