Recompiler: assemble and sign DXIL from LLVM IR text #1373
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1373
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1373/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Sr-0w on GitHub · 2026-11-24 15:20 UTC · original
Sr-0w:recomp-assemble-ir→main· +109 −0 · 2 files · 2 commits · closed without mergingPart of #1269 (direct DXIL backend).
dxcompiler.dll'sIDxcAssembler::AssembleToContainerparses its input with LLVM'sparseIR, so it takes a DXIL module as LLVM IR text (or bitcode) and builds the container from the module'sdx.*metadata;dxil.dll'sIDxcValidatorwithDxcValidatorFlags_InPlaceEditthen validates and signs it. Neither DXC's HLSL front end nor its optimiser runs.Measured (RX 7800 XT, DXC 1.9.2602.17), one retail compute program of ≈21 000 instructions:
dxc::compile(-O1)-Fclisting, 8.6 MB) throughdxc::assembleSo a backend that writes the IR itself needs no bitcode writer and no container writer of its own. It still has to write clean SSA, since no optimiser runs after it.
What is in it
crates/xcl/src/gpu/recomp/dxc.rs:pub fn assemble(ir: &str) -> Result<Vec<u8>, String>—IDxcUtils::CreateBlob→IDxcAssembler::AssembleToContainer→IDxcValidator::Validate(in place: signs), errors from either as text. Not called by the runtime yet.crates/xcl/src/gpu/recomp/tests.rs:ir_text_assembles_signs_and_runs— a hand-written CS of the ABI root signature (mem[i] = 3 i + 1throughu2) is assembled, run on the GPU and its output checked; a module with a use before its definition comes back as a validation error, not a container.One thing learned on the way, written in the function's comment: without an
!llvm.identthe container validates, but the AMD driver faults inCreateComputePipelineState.Tested
cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored; no SKIPPED tests.ir_text_assembles_signs_and_runspasses (GPU output checked).Regression run
main:PR head:
Not tested
AI use
🤖 Generated with Claude Code
@ivall on GitHub · 2026-11-24 15:27 UTC · original
Tested
3485cbfon an AMD RDNA4 GPU, Windows, DXC 1.8.2502.11 (the Windows SDK's). The path works and the time is confirmed. One change is needed before this can go in: the new test fails with a DXC older than 1.9.1. The test needs DXC 1.9.
cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 751 passed, 1 failed, 41 ignored, no SKIPPED. The failure isir_text_assembles_signs_and_runs(tests.rs:7640):The module's
!dx.valveris{1, 9}. With{1, 6}, and with{1, 8}, the test passes here, GPU output included. SM 6.6 needs no more than 1.6, so please use!2 = !{i32 1, i32 6}. A backend on top of this should write 1.6 as well, so that any DXC that can sign SM 6.6 accepts it.2. Time. Four retail compute programs (native wave64, 4 memory windows; the HLSL through
dxc::compileat its own level, then DXC's listing of that DXIL throughdxc::assemble, three times each; a local release build):The container that comes back has the same listing as DXC's (comment lines aside) and the same size in KB in all four. As you say, the IR was already optimised here, so this is what the assembler costs, not what a backend will cost in all.
3. Smaller points
!llvm.ident: confirmed on RDNA4. Without it, the module is assembled and signed, then the test process ends with0xc0000005. A comment is easy to miss for whoever writes the emitter; please haveassemblereturn an error for a module without one, with a line in the test."Validation failed.\n\0");compile_heretrims it.errorsbuilds a slice from the error buffer without looking at its size: if an empty buffer ever comes with a null pointer,from_raw_partsis undefined behaviour.Not tested: a title run (nothing calls
assembleyet), NVIDIA, the driver's time (the DXIL is the same), other DXC releases.AI use: Claude Code (Claude Opus 5.5) ran the tests and measurements and wrote this.
@futurepro62 on GitHub · 2026-11-24 15:26 UTC · original · edited 2026-11-24 15:28 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
3485cbf(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.ir_text_assembles_signs_and_runs.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
@t4l03 on GitHub · 2026-11-24 15:29 UTC · original
Additional NVIDIA test, plus an IR round trip for one large compute shader
Tested clean head
3485cbfde5578cd139fcbf77437459d007227051on an RTX 4070 Ti (Ada), Windows 11 build 26300, driver 617.14, DXC and validator 1.9.2609.5. WithXCL_ADAPTER=nvidiaandXCL_REQUIRE_GPU=mesh,cargo test --locked -p xcl --lib -j 4 ir_text_assembles_signs_and_runs -- --nocapturecompleted with 1 passed, 0 failed, 0 ignored, no skip. This includes the GPU output and invalid-IR checks.I also called the unchanged
dxc::assemblefrom a scratch executable on 11,375,976 bytes of already lowered LLVM IR text from the ActivateRays experiment. Assembly and signing took 0.261 s and produced 2,786,924 bytes of DXIL, accepted bydxv.exe. Disassembly kept the same counts before and after: 6,418 explicit block labels, 44,484 SSA definitions, 2,078 phis and 536 switches. The subsequent D3D12 pipeline attempt, with a fresh XCL cache and the same root signature and static samplers, reached a 75-second time cap at 4.05 GiB peak private commit. The assembly timing starts with ready IR. NVIDIA's global disk cache remained enabled.Not tested: the older 1.8 validator, full suite on this PR, or dispatch output of the retail shader.
AI use: Codex (
gpt-6.2-sol) ran the tests and wrote this report.@thehollowedone on GitHub · 2026-11-24 15:40 UTC · original
Confirmed ivall’s validator-version finding on an RTX 3080 Ti (621.35), Windows 11 build 26300, with Windows SDK DXC and DXIL validator 1.8.2502.11.
ir_text_assembles_signs_and_runsbecause the fixture requires validator 1.9.!dx.valverto 1.6 gives 1 passed, 0 skipped. All 64 GPU readbacks matched.cargo test --offline --locked -p xcl --lib ir_text_assembles_signs_and_runs -- --nocapture --test-threads=1. Focused synthetic test only.AI-assisted. Codex (GPT-6 family, exact variant unavailable) ran the comparison and drafted this report.
@ArturoWolff on GitHub · 2026-11-24 15:33 UTC · original · edited 2026-11-24 15:55 UTC
RTX 4060 / Proton: the original and reassembled split-wave shader produced the same GPU output, including reads across waves. Tested the real
dxc::assembleat3485cbfde5578cd139fcbf77437459d007227051on a generated 2,048-round compute kernel (four memory windows, wave64 split over wave32). The input to the assembler was DXC’s unedited listing of the original DXIL. The executable bitcode was not byte-identical after reassembly (62,916 → 62,856 bytes). Both signed containers passed a separatedxil.dllvalidation before dispatch. Each 6,400-byte readback matched the CPU reference: 768 local values, 768 values exchanged via LDS, 64 untouched prefix words.Fresh processes, balanced order. Producing the listing from the original container was a separate 8.7 ms disassembly. The assembler timing starts after lowering and optimization; it does not estimate end-to-end direct-backend speed. One PSO attempt per arm is not a driver benchmark.
Tested: Linux, Ryzen 5 5600, RTX 4060, NVIDIA 620.73.04, GE-Proton11-14, vkd3d-proton
4522cc1a8b1347f+. Both loaded DLLs were 1.9.2609.5; listing declared DXIL 1.6, validator 1.9,cs_6_6. Offline Windows-target release library, private probe: one disassembly, four HLSL compiles, four assemblies, two dispatch/readbacks; 11 passed, 0 failed/ignored/skipped. Not tested: validator 1.8, full suite, retail title, or direct RDNA-to-IR lowering.AI use: Hermes Agent, gpt-6.2-astra (fixture, execution, verification and report).
Bitcode follow-up (same two outputs, no new dispatch):
llvm-bcanalyzer --dumpfound one function with 44 basic blocks in both. All 10,458 decodedINST_*records matched in order, including operands. Within the function block the only remaining decoded-record differences after ignoring abbreviation IDs were three metadata attachments: their kind IDs were renumbered but resolved to the samellvm.loopanddx.controlflow.hintsnames. The different bitcode hashes alone therefore do not show different instructions here. This is not a whole-module or driver-ISA equivalence claim.Linux downstream check (same fixture and stack): Two fresh
pso_readback --exact --nocapture --test-threads=1dispatches withVKD3D_SHADER_DUMP_PATHset: 2 passed, 0 failed/ignored/skipped. Each dumped DXIL matched its input byte for byte; both 6,400-byte GPU readbacks matched the expected result. Both SPIR-V modules were 263,892 bytes and passedspirv-val --target-env vulkan1.3.spirv-dis --raw-iddiffered only in the input filename inOpString; afterspirv-opt --strip-debugthe binaries compared identical withcmp. On this shader, reassembly changed DXIL bytes but not the SPIR-V instructions submitted through vkd3d-proton. Not a driver-ISA comparison or a timing result.@DavidM1911 on GitHub · 2026-11-24 16:41 UTC · original
Test report — RTX 3060 Ti (Windows 11), DXC dxcompiler 1.8.2502.11, branch merged with current
main(b7aa9f3):cargo test -p xcl --lib -- --test-threads=1: 1 failure (722 passed, 1 failed, 21 ignored):The LLVM IR → DXIL path emits module metadata with validator version 1.9, but the DXC in the Windows SDK (1.8.2502.11) only accepts ≤1.8 — the emitted IR probably needs
llvm.ident/module-flag metadata pinned, or the assemble step needs to strip/override the version flag before validation.@Sr-0w on GitHub · 2026-11-24 18:17 UTC · original
042d3a6"Tests: the IR assemble test skips without dxil.dll": the same fix as9a24907on the per-lane branch, for the gap @justrhoto found on #1269. A stock Windows SDK'sbin\<ver>\x64hasdxcompiler.dllwithoutdxil.dll, soir_text_assembles_signs_and_runspanicked withno dxil.dll to sign withinstead of skipping.Checked (RX 7800 XT, release):
XCL_DXC_DIRset to a folder holding only the SDK'sdxcompiler.dll, it printsSKIPPED gpu::recomp::tests::ir_text_assembles_signs_and_runs: no dxil.dll;cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored.AI use: Claude Code (Claude Opus 5.5) made the commit, ran the tests and wrote this comment.
@Toons29 on GitHub · 2026-11-25 03:26 UTC · original
Regression run of
042d3a62on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@JJAutoCompare on GitHub · 2026-11-25 06:57 UTC · original
Tested
PR #1373 was open at 042d3a62c51645c96c86a9789b4790fc6cef2492 before and after testing. The existing checkout was clean and detached at that SHA. No equivalent same-head Arc A770 result was found in the PR description, eight discussion entries, review submissions, or 173 comments on GPU issue #42.
STOR-WINLAB, Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0 on stable-x86_64-pc-windows-msvc. The fixture logged dxcompiler and dxil 1.9.2609.5 from the configured XCL_DXC_DIR.
Not tested
Other DXC/validator versions, adapters, extra IR inputs, large-shader round trips, upstream or retail data, and the workspace suite.
AI use
T3 Code / Codex (gpt-6.2-sol) verified the commit and deduplication, ran the stock fixture, and wrote the report.
Evidence in this directory includes environment.log, dedup.log, cargo.stdout.log, cargo.stderr.log and cargo.exit.txt. The retry directory contains fixture.command.txt, fixture.stdout.log, fixture.stderr.log, fixture.exit.txt, wrapper.stdout.log, wrapper.stderr.log, wrapper.exit.txt, both checkout checks, and slot-release.log.
@Prime1997 on GitHub · 2026-11-26 01:09 UTC · original
Closing because main already has this change, from
9b8db83f("Recompiler: assemble and sign a DXIL module from LLVM IR text").crates/xcl/src/gpu/recomp/dxil/assemble.rson main hasassemble(ir: &str), which takes the same CreateBlob, AssembleToContainer and in-place IDxcValidator signing path with the same!llvm.identnote. Itsir_text_assembles_signs_and_runstest matches this one, uses!dx.valver 1.6, and skips when dxil.dll is missing (6bdef802).Compared at head
1b08dfaeagainst main08db802. Reviewed with Claude Code (Claude Opus 5.5); I checked the comparison before closing.@DavidM1911 on GitHub · 2026-11-26 05:03 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Pull request closed