Skip to content

dxil: emit MSAA textureLoad before getDimensions to avoid amdxc64 crash - #1900

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
raylitebull:fix/amd-msaa-and-driver-crashes
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
raylitebull:fix/amd-msaa-and-driver-crashes

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Fixes the amdxc64.dll null-pointer dereference (0xc0000005 at +0x85f80f on amdxc64.dll 32.0.32015.2008) during CreateComputePipelineState on dynamically indexed descriptor-heap Texture2DMS / Texture2DMSArray shaders introduced in #1679 (gpu_direct_msaa_image_loads).

Follow-up to #1679.

What is in it

  • Root cause: AMD's DXIL compiler dereferences null during CreateComputePipelineState when dx.op.getDimensions precedes dx.op.textureLoad on a dynamically indexed descriptor-heap Texture2DMS / Texture2DMSArray inside the same basic block (reproduced even on DXC 1.8 HLSL, with nonUniformIndex=false, WaveSize(32), or separate createHandleFromHeap/annotateHandle calls; does not crash when textureLoad precedes getDimensions in the same block, when they are in different blocks, or when the heap index is constant).
  • crates/xcl/src/gpu/dxil/lower_image.rs (mimg_msaa): emit all texture_load_sample calls before get_dimensions(tex.handle, None) inside each guarded format branch (+6/-2, zero extra blocks or branches).
  • crates/xcl/src/gpu/dxil/msaa_tests.rs: add CPU DXIL disassembly regression test direct_msaa_loads_precede_get_dimensions verifying dx.op.textureLoad precedes dx.op.getDimensions in every generated MSAA load basic block.

Tested

  • Hardware & toolchain: AMD Radeon RX 9070 XT (16191 MiB VRAM, RDNA4, native wave64, driver amdxc64.dll 32.0.32015.2008), Windows 11 x64 (10.0.22631.0), rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased onto 689f2db.
  • cargo test -p xcl --lib gpu::dxil::msaa_tests -- --ignored --include-ignored (live RX 9070 XT GPU + CPU): 5 passed, 0 failed (0.15 s), including gpu_direct_msaa_image_loads (previously 0xc0000005), msaa_texture_ops_run, and direct_msaa_loads_precede_get_dimensions.
  • cargo check --workspace --tests: passed.

Regression run
main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: AMD Radeon RX 9070 XT
title: 29e814f5
seconds: 60
exit: 0x0
frames shown: 1597 (PresentX 1597)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20713 MB

PR:

xcl-smoke v1
commit: 425b86920b43d26a670cc0090787fc946976bce3
gpu: AMD Radeon RX 9070 XT
title: 29e814f5
seconds: 60
exit: 0x0
frames shown: 1609 (PresentX 1609)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20315 MB

Not tested

  • scripts/smoke.ps1 with XCL_DIRECT_DXIL=1 enabled, full cargo test --workspace run on 425b869, NVIDIA and Intel GPUs, wave32-only adapters, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity (Claude Opus 4.6) assisted with GPU bisection, root-cause diagnosis, implementation, and test verification; the author reviewed the diff and results.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit 425b869

Verified 425b86920b43d26a670cc0090787fc946976bce3 (rebased onto main 689f2db477c3c062cf162649781640ef8a977c18, clean merge): pass — confirms the #1679 0xc0000005 (amdxc64.dll) crash in gpu_direct_msaa_image_loads is resolved on RX 9070 XT.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke
  • Unfiltered cargo test --workspace --no-fail-fast -- --test-threads=4 (no --skip needed): 974 passed, 2 failed, 45 ignored (8 skipped), running to completion without crashing xcl --lib:
    • All 5/5 gpu::dxil::msaa_tests passed on RX 9070 XT (gpu_direct_msaa_image_loads, msaa_texture_ops_run, render_target_sample_ops_validate, direct_msaa_store_is_rejected, direct_msaa_loads_precede_get_dimensions)
    • Only the 2 pre-existing main 689f2db fuzz tests failed (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3); 0 new failures
    • 8 skipped: 6 gpu::recomp::lower_dxil::tests f16/f32 direct-DXIL per-lane cases refused where #1426 semantics differ from the console's; shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required, 0x887A002D); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • Native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) passed

Regression run (scripts/smoke.ps1, 60 s, warm shader/driver cache)
main (689f2db477c3c062cf162649781640ef8a977c18):

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (425b86920b43d26a670cc0090787fc946976bce3):

xcl-smoke v1
commit: 425b86920b43d26a670cc0090787fc946976bce3
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14857 MB

Not tested

  • NVIDIA/Intel GPUs, Wine/vkd3d-proton, gameplay past the menus

AI use

  • Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

NVIDIA counterpart to the RX 9070 XT run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 425b869 on main 689f2db. The reordering doesn't change the result on NVIDIA. Tests matching msaa, including direct_msaa_loads_precede_get_dimensions and gpu_direct_msaa_image_loads: 6 passed, 0 failed, with and without XCL_DIRECT_DXIL=1.

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

@raylitebull
raylitebull merged commit 20cf130 into xcl-dev:main Nov 24, 2026
2 of 3 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
Brings main to parity with upstream/main (20cf130):
- xcl-dev#1900: DXIL emits MSAA textureLoad before getDimensions to avoid amdxc64 crash

Assisted-by: Antigravity (Gemini 4)
bmjask added a commit to bmjask/xcl that referenced this pull request Nov 24, 2026
Keeps xcl-dev#1900's ordering: the sample count is read in its own block and the
clamped loads start a new block, so no textureLoad follows getDimensions in
one basic block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
anoyarou pushed a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
…-dev#1947)

The translated cache's identity covers the HLSL path's sources
(XCL_TRANSLATOR_SOURCE_ID), but of gpu/dxil only TRANSLATOR_VERSION,
which is bumped by hand. Two changes that bump it to the same number,
or one that does not bump it (xcl-dev#1900), leave containers of the old
translator in use.

build.rs hashes every .rs file of gpu/dxil but the *tests.rs ones into
XCL_DIRECT_DXIL_SOURCE_ID, which only the direct entries' identity
includes (and the per-lane entries', which extend it). The HLSL path's
entries keep theirs, as with bfb8133 for the per-lane sources. The
directory is listed rather than named file by file, so that a new file
is not left out. TRANSLATOR_VERSION stays, for changes of pso.rs's
direct_compute / direct_graphics; edits of gpu/dxil no longer need it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
Pulls in xcl-dev#1836 (graphics and two-pass PSO disk cache + lazy MS/GS + shader build coalescing), xcl-dev#1930 (DXIL CSE across discard), xcl-dev#1900, xcl-dev#1005, xcl-dev#1053, xcl-dev#1864, xcl-dev#1866, xcl-dev#1869, xcl-dev#1876, and xcl-dev#1898 while keeping our RDNA4 MSAA clamp (xcl-dev#1908), wave64 graphics Direct DXIL guard (xcl-dev#1913), atomic writable-range tracking, static-sampler cache keys, and 4M-group indirect dispatch clamp.
raylitebull pushed a commit that referenced this pull request Nov 25, 2026
The translated cache's identity covers the HLSL path's sources
(XCL_TRANSLATOR_SOURCE_ID), but of gpu/dxil only TRANSLATOR_VERSION,
which is bumped by hand. Two changes that bump it to the same number,
or one that does not bump it (#1900), leave containers of the old
translator in use.

build.rs hashes every .rs file of gpu/dxil but the *tests.rs ones into
XCL_DIRECT_DXIL_SOURCE_ID, which only the direct entries' identity
includes (and the per-lane entries', which extend it). The HLSL path's
entries keep theirs, as with bfb8133 for the per-lane sources. The
directory is listed rather than named file by file, so that a new file
is not left out. TRANSLATOR_VERSION stays, for changes of pso.rs's
direct_compute / direct_graphics; edits of gpu/dxil no longer need it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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