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

Merged
consolelogkyo merged 1 commit from upstream-pr/2932 into cpp-migration 2026-11-26 21:59:23 +00:00
consolelogkyo commented 2026-11-26 21:50:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by consolelogkyo on 2026-11-26T21:50:43Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5517627003 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2932). Originally posted by [consolelogkyo](https://github.com/consolelogkyo) on 2026-11-26T21:50:43Z. --- ## 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.
MasterDomino commented 2026-11-26 21:59:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T21:59:21Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6080930241 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2932#pullrequestreview-6080930241). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T21:59:21Z. **Review:** APPROVED --- 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:** ```powershell 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2932
No description provided.