Repository navigation
shader: emit !llvm.ident in direct DXIL modules for AMD PSO creation - #2932
MasterDomino merged 1 commit into
Conversation
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
left a comment
There was a problem hiding this comment.
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_mirrorandgraphics_wqm; - two that crashed here earlier today:
native_pack_b32_f16_hardware(#2917), which ran its GPU readback on AMD for the first time, andnative_graphics_vertex_vcc_join_hardware(#2914); native_dxil_llvm_ident_hardware,native_lds,native_buffered_vertexandnative_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.
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>
Summary
Fixes the
0xC0000005access violation insideamdxc64.dllduringCreateComputePipelineStateandCreateGraphicsPipelineStateacross all direct-DXIL_hardwaretests on AMD RDNA 4 (AMD Radeon RX 9070 XT, driver32.0.32029.2010).Root cause
Comparing disassembled DXIL modules (
dxc.exe -dumpbin) re-assembled and validated throughIDxcAssembler::AssembleToContainerandIDxcValidator::Validateisolated the crash to missing!llvm.identmodule metadata:ps_6_6output passed (rc = 0,debug_errors=0 debug_warnings=0).DxilModuleoutput as-is crashed (0xC0000005), and bumping!dx.valverto1.8or1.9alone still crashed (0xC0000005).!llvm.ident = !{!<id>}(!{!"x2w"}) alone made the identicalDxilModuleIR pass (rc = 0,debug_errors=0 debug_warnings=0).dxc.exealways emits!llvm.identandIDxcValidatortreats it as optional, whereasamdxc64.dll(8.18.10.0514) queriesllvm::Module::getNamedMetadata("llvm.ident")and dereferences the returnedNamedMDNode*([rcx + 0x40]) without a null check.Changes
src/dxil_module.h: emit!llvm.ident = !{!<id>}(!{!"x2w"}) inDxilModule::finish_compute(coverscs,vs,gs, andps).src/gfx1013_pixel.cpp: emit!llvm.ident = !{!0}(!{!"x2w"}) inx2w::direct_gfx1013_constant_pixel.tests/native_dxil_llvm_ident_check.py,tests/cmake/native_dxil_llvm_ident.cmake: verify!llvm.identacrossgfx1013-container-cs,gfx1013-container-vs,gfx1013-container-ps,gfx1013-container-rect(vs,gs,ps), andgfx1013-direct-constant-pswith stripped-!llvm.identnegative controls, and draw both direct pixel paths paired withgfx1013-container-vson 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_hardwareundecodable-word refusal wrapper untouched per coordination on #2915.)Verification
10.0.26100), Release preset (MSVC 19.44.35230), Windows SDK10.0.26100.0DXC, D3D12 debug layer enabled (0errors,0warnings).Microsoft Basic Render Driver(1414:008c, driver10.0.26100.9818) andAMD Radeon RX 9070 XT(1002:7550, driver32.0.32029.2010).ctest --preset release --no-tests=error -R "^native_" -E "^native_wave_request_hardware$"): 28/28 passed (plus 1 expected WARP wave-width skipnative_comparison_pso_warp), including all seven direct-DXIL_hardwaretests (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) plusnative_dxil_llvm_ident_{controls,warp,hardware},docs_links, andbidi_controls.Refs #2915
AI-assisted.