Recompiler: eliminate DXIL bitcode double-copy and intermediate allocations in container assembly #2664
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!2664
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2664"
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?
@Decodere on GitHub · 2026-11-26 05:36 UTC · original
Decodere:fix-dxil-container-single-copy-and-exact-sizing→main· +219 −108 · 1 files · 1 commits · openWhat is in it
Part of #2508
Part of #1833
Eliminates the full-bitcode double allocation/copy and intermediate part/string
Vecallocations during direct-DXIL DXBC container assembly incrates/xcl/src/gpu/dxil/container.rs(+219/-108lines;L76–131hash/md5_blockcompletely untouched for zero conflict with #1878; all public signatures,assert!(bitcode_len % 4 == 0), and emitted container bytes remain 100% identical):program_part(which allocated a24 + bitcode.len()Vec<u8>and copied the entire bitcode before copying it a second time intoout) with a stack-allocatedprogram_header(stage, sm, dxil_version, bitcode_len) -> [u8; 24](retainingassert!(bitcode_len % 4 == 0)).const EMPTY_SIGNATURE: [u8; 8] = [0, 0, 0, 0, 8, 0, 0, 0](removingempty_signature() -> Vec<u8>) and a sharedassemble_container(prefix_parts, stage, sm, bitcode)helper that computes exacttotal, allocatesVec::with_capacity(total)once (debug_assert_eq!(out.len(), total)), writes prefix parts andDXILheader +bitcodedirectly (1x memcpy, zero intermediatebitcode-sizedVec), and signsout[4..20]viahash(&out[20..]).container()andcontainer_with_signatures()to pass stack arrays of borrowed slices (SFI0,ISG1,OSG1, optionalPSG1,PSV0) toassemble_container, removing the duplicated serialization loops and intermediateparts: Vec/features.to_le_bytes().to_vec()heap allocations.psv_part(computingstr_len = (psv.entry.len() + 2).next_multiple_of(4)andexact_len = 68 + res_len + str_len, writing the string table directly intopwith zero temporarystringsVec).signature_partto borrowoffs: Vec<(&str, u32)>(zeroStringclones) and exact-sizep = Vec::with_capacity(8 + 32 * elems.len() + strings.len()).psv_part_full, removing the temporaryall: Vec<&PsvSigElement>allocation by chainingpsv.inputs/outputs/prims, pre-sizingstrings,name_off,idx_off, and allocatingp = Vec::with_capacity(p_len)once.digest_matches_dxc_signed_container,digest_covers_both_tail_layouts, andpsv_matches_dxc_layout_for_compute_with_two_raw_uavsuntouched, and addedparts_and_containers_are_exact_sized_and_match_reference_layoutandprogram_header_rejects_unaligned_bitcode.Tested
rustc 1.100.0, DXC1.9.2609.5 (01b62ad4), release builds.b49be183: exact-capacity check failed withpsv_part=104/160, signature_part=52/64, psv_part_full=76/80(all over-allocated byVec::new()growth).rustc -Oback-to-back comparison of pre-fixprogram_part+parts Vecvs post-fixprogram_header+assemble_container, excluding untouchedhash()):1 MiBbitcode (400iterations):533.0 µs/call->216.0 µs/call(2.47xfaster,-59.5%, eliminating a 1 MiB transient allocation + copy).2 MiBbitcode (200iterations):974.6 µs/call->446.5 µs/call(2.18xfaster,-54.2%, eliminating a 2 MiB transient allocation + copy).XCL_ADAPTER=warp,XCL_WARP=1):cargo test --release -p xcl --lib -- gpu::dxil::container::tests:: --nocapture->5 passed; 0 failed; 0 ignored(0skipped,0.00s).cargo clippy --all-targets:0new warnings incontainer.rs(only the 4 pre-existingchunks_exact/% 4lints on untouchedL82/L111and intentionally keptL139/L281).cargo test --release -p xcl --lib -- gpu::dxil:: --nocapture->186 passed; 0 failed; 3 ignored(5.38s;container::tests::5/0/0with0skipped;1pre-existingwave64skipdispatch_chain_native_wave64_builds_whole).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture:37binaries,1437passed,0failed,47ignored (0compiler warnings incontainer.rs),29pre-existing environment-gatedSKIPPEDlines (none incontainer):21wave64-only GPU tests (no wave64on RTX 4060 32-lane waves)3per-lane wave32 shader tests (refused)3D3D12 debug layer tests (no d3d12SDKLayers.dll/ debug layer unavailable)1heap-window OOM fallback test (no heap windows)1PSO driver-cache measurement test (cannot disable the driver cache)Regression run
Paired 60 s retail smoke (
scripts/smoke.ps1, RTX 4060): both base and HEAD sustained60 60 60presents per 2 s with0device removals and0crashes (1536vs1562total frames,14023 MBvs14009 MBpeak commit).Base (
origin/main):HEAD (
fix-dxil-container-single-copy-and-exact-sizing):Not tested
AI use
Google Antigravity (Gemini 4 Neon) authored the
container.rssingle-copy / exact-sizing refactoring, parity tests, micro-benchmark, and verification runs; verified via failing-first check, WARP and RTX 4060 test suites,cargo clippy --all-targets, full RTX 4060 release workspace tests, and paired 60 s retail smoke runs.@DarkPanda69 on GitHub · 2026-11-26 05:54 UTC · original
Native wave64 run on an AMD RX 9070 XT, plus an RTX 3060: the 2 new tests pass, and nothing else changes in the direct-DXIL GPU suite, so every direct-DXIL container the suite builds still validates and runs with this assembly code.
Head
902a8dcapplied onmainb49be18, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR, card chosen withXCL_ADAPTER:mainOn both cards, the only result changes against
mainare the newparts_and_containers_are_exact_sized_and_match_reference_layoutandprogram_header_rejects_unaligned_bitcode(should panic), both ok, with no new skips. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: cold-cache compilation timings, the D3D12 debug-layer tests (no
d3d12SDKLayers.dllhere either), a title.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@luckyteagirl on GitHub · 2026-11-26 05:44 UTC · original · reviewed
Could the full-PSV fixture compare against known pre-change PSV bytes? The container reference receives
pfullfrompsv_part_full()under test, so the equality check verifies container placement and hashing but cannot catch a same-length PSV serialization change. In an isolated copy of this exact-head module, swappingpsv.info1[0]and[1]in the serializer left the new test passing; an independent expected-byte check rejected the mutation. A golden PSV fixture or standalone reference serialization would support the PR's byte-identical guarantee. This is a test-oracle gap, not evidence that the current serializer emits wrong bytes. Verified with a focused standalone Rust harness at902a8dc966ea7119f9c259701bb6819b1dcaa206; no full workspace or GPU run. AI-assisted review with Codex.@SlopTart on GitHub · 2026-11-26 06:50 UTC · original · edited 2026-11-26 07:01 UTC
Tested on the Linux/Wine lane, full standard env (AMD rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB, Arch kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 Proton, rustc 1.94.0;
d3d12,d3d12core,dxgi,d3d11,d3d10core=n,boverrides, official DXC kit,VKD3D_CONFIG=ignore_shared_fence, threads=2), head902a8dc9, mergeable against mainb49be183:non-gpu suite (
--skip gpu::): 596 passed, 3 failed, 4 ignored, 735 filtered.The failure set is identical to bare main
b49be183measured on the same rig the same day (596 passed, 3 failed): gpu_promoted_uav_clear (our #2490), xma2_source_voice (#2481, vendored-FAudio gate). The third red, the sparse tile video-memory test, is a known batch flake (green solo).Zero delta from this PR; every test it adds passes inside the suite.
Not tested: gpu suite, Windows native.
Correction: an earlier version of this row reported three extra reds; those runs lacked the
d3d12,d3d12core=n,bDLL overrides and hit stub-DLL NOTIMPL artifacts. Re-ran with the standard env, artifacts gone.AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
@Aniseto on GitHub · 2026-11-26 07:38 UTC · original
Ran the DXIL container tests at
902a8dc9:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All five tests pass, including the two new ones (
parts_and_containers_are_exact_sized_and_match_reference_layoutandprogram_header_rejects_unaligned_bitcode). The panic line in the output is the expectedshould paniccase.What this adds: the author tested on an Ampere RTX 4060 in release mode with the same DXC version; this is a Blackwell wave32 part in the debug test profile. The thread has no report from another machine.
Not tested: the release micro-benchmark timings, a paired 60 s smoke run, the full workspace suite, AMD and Intel GPUs, native wave64, Wine, release profile, title data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.