Skip to content

shader: emit !llvm.ident in direct DXIL modules for AMD PSO creation - #2932

Merged
MasterDomino merged 1 commit into
R0Y00:cpp-migrationfrom
consolelogkyo:fix/native-dxil-amd-pso-crash
Nov 26, 2026
Merged

MasterDomino merged 1 commit into
R0Y00:cpp-migrationfrom
consolelogkyo:fix/native-dxil-amd-pso-crash

Conversation

@consolelogkyo

Copy link
Copy Markdown
Contributor

Summary

Fixes the 0xC0000005 access violation inside amdxc64.dll during CreateComputePipelineState and CreateGraphicsPipelineState across all direct-DXIL _hardware tests on AMD RDNA 4 (AMD Radeon RX 9070 XT, driver 32.0.32029.2010).

Root cause

Comparing disassembled DXIL modules (dxc.exe -dumpbin) re-assembled and validated through IDxcAssembler::AssembleToContainer and IDxcValidator::Validate isolated the crash to missing !llvm.ident module metadata:

  • Re-assembling DXC's ps_6_6 output passed (rc = 0, debug_errors=0 debug_warnings=0).
  • Re-assembling DxilModule output as-is crashed (0xC0000005), and bumping !dx.valver to 1.8 or 1.9 alone still crashed (0xC0000005).
  • Adding !llvm.ident = !{!<id>} (!{!"x2w"}) alone made the identical DxilModule IR pass (rc = 0, debug_errors=0 debug_warnings=0).

dxc.exe always emits !llvm.ident and IDxcValidator treats it as optional, whereas amdxc64.dll (8.18.10.0514) queries llvm::Module::getNamedMetadata("llvm.ident") and dereferences the returned NamedMDNode* ([rcx + 0x40]) without a null check.

Changes

  • src/dxil_module.h: emit !llvm.ident = !{!<id>} (!{!"x2w"}) in DxilModule::finish_compute (covers cs, vs, gs, and ps).
  • src/gfx1013_pixel.cpp: emit !llvm.ident = !{!0} (!{!"x2w"}) in x2w::direct_gfx1013_constant_pixel.
  • tests/native_dxil_llvm_ident_check.py, tests/cmake/native_dxil_llvm_ident.cmake: verify !llvm.ident across gfx1013-container-cs, gfx1013-container-vs, gfx1013-container-ps, gfx1013-container-rect (vs, gs, ps), and gfx1013-direct-constant-ps with stripped-!llvm.ident negative controls, and draw both direct pixel paths paired with gfx1013-container-vs on WARP and hardware with mutated-output negative controls.
  • docs/experiments/native-dxil-llvm-ident.md: record the A/B isolation and verification notes.

(Leaves the adapter-independent native_wave_request_hardware undecodable-word refusal wrapper untouched per coordination on #2915.)

Verification

  • Host: Windows 11 (10.0.26100), Release preset (MSVC 19.44.35230), Windows SDK 10.0.26100.0 DXC, D3D12 debug layer enabled (0 errors, 0 warnings).
  • Adapters: Microsoft Basic Render Driver (1414:008c, driver 10.0.26100.9818) and AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010).
  • CTest (ctest --preset release --no-tests=error -R "^native_" -E "^native_wave_request_hardware$"): 28/28 passed (plus 1 expected WARP wave-width skip native_comparison_pso_warp), including all seven direct-DXIL _hardware tests (native_scalar_lds_hardware, native_adjacent_srv_hardware, native_mtbuf_hardware, native_indexed_atomic_hardware, native_dpp_mirror_hardware, native_graphics_wqm_hardware, native_graphics_vertex_vcc_join_hardware) plus native_dxil_llvm_ident_{controls,warp,hardware}, docs_links, and bidi_controls.

Refs #2915

AI-assisted.

AMD's user-mode DXIL compiler (`amdxc64.dll` `8.18.10.0514`, driver
`32.0.32029.2010` on Radeon RX 9070 XT) queries
`llvm::Module::getNamedMetadata("llvm.ident")` and dereferences the returned
`NamedMDNode*` (`[rcx + 0x40]`) without a null check during
`CreateComputePipelineState` and `CreateGraphicsPipelineState`. `dxc.exe`
always emits `!llvm.ident`, while `IDxcValidator::Validate` treats it as
optional, so direct DXIL containers from `DxilModule` passed validation, WARP,
and NVIDIA while crashing all seven direct-DXIL `_hardware` tests with
`0xC0000005` on RDNA 4.

- `src/dxil_module.h`: emit `!llvm.ident = !{!<id>}` (`!{!"x2w"}`) in
  `DxilModule::finish_compute`, covering `cs`, `vs`, `gs`, and `ps`.
- `src/gfx1013_pixel.cpp`: emit `!llvm.ident = !{!0}` (`!{!"x2w"}`) in
  `x2w::direct_gfx1013_constant_pixel`.
- `tests/native_dxil_llvm_ident_check.py`,
  `tests/cmake/native_dxil_llvm_ident.cmake`: check `!llvm.ident` across
  `gfx1013-container-cs`, `gfx1013-container-vs`, `gfx1013-container-ps`,
  `gfx1013-container-rect` (`vs`, `gs`, `ps`), and `gfx1013-direct-constant-ps`
  with stripped-`!llvm.ident` negative controls, and draw both direct pixel
  paths on WARP and hardware with mutated-output negative controls.
- `docs/experiments/native-dxil-llvm-ident.md`: record the A/B isolation and
  RX 9070 XT + WARP verification results.

Refs R0Y00#2915

AI-assisted.

@MasterDomino MasterDomino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 22ae168f, on the host where #2915 was first reported.

Environment: Windows 11 build 26300.9974, AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010) and WARP 10.0.26100.9818, MSVC 19.44.35221, release preset, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled.

Change: !llvm.ident = !{!"x2w"} is emitted by DxilModule::finish_compute and by direct_gfx1013_constant_pixel. Those are the only two places under src/ that write DXIL module metadata (git grep 'dx\.version' -- src), so no direct emitter is left without it.

With the PR:

ctest --preset release --no-tests=error -j 4 --timeout 300 -R '^native_' -E '^native_wave_request_hardware$'

31 tests: 30 passed, 1 skipped (77, native_comparison_pso_warp). On the RX 9070 XT, every _hardware test passes:

  • the six from #2915: scalar_lds, adjacent_srv, mtbuf, indexed_atomic, dpp_mirror and graphics_wqm;
  • two that crashed here earlier today: native_pack_b32_f16_hardware (#2917), which ran its GPU readback on AMD for the first time, and native_graphics_vertex_vcc_join_hardware (#2914);
  • native_dxil_llvm_ident_hardware, native_lds, native_buffered_vertex and native_sampled_pixel.

native_wave_request_hardware is excluded because this branch predates #2928. After #2928 it passed here with its GPU half included.

Negative control: I checked out src/dxil_module.h and src/gfx1013_pixel.cpp from 7f951fd3 (no !llvm.ident), rebuilt, and ran the eight direct-DXIL _hardware tests above: 0 of 8 passed. Restoring the two files and rebuilding brings them back. So on this adapter the metadata alone decides it, which agrees with @thepatrickworld's dump (the null read at [rcx+40h] in amdxc64.dll).

Other checks: docs_links_check (32 files, 547 links), bidi_controls_check and git diff --check pass. It merges cleanly on the current cpp-migration, e4523d97, which includes #2928.

.github/workflows/windows.yml does not run for this base. The runs above and the author's are the evidence.

AI-assisted; the commands above were run locally.

@MasterDomino
MasterDomino merged commit e97c5c7 into R0Y00:cpp-migration Nov 26, 2026
JB2WIN added a commit to JB2WIN/Xbox2Windows that referenced this pull request Nov 27, 2026
Resolves the conflicts with R0Y00#2932-R0Y00#2971 (keeps both sides: HeapViewContract next
to the MODE tracking and lane-shape checks; .views handling inside the new
compile_one). The check follows the new --requests output name <key>.cs.cso
from R0Y00#2955, and the notes mention the stand-in's native slot 67 path (R0Y00#2958),
which translates without a heap view contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants