Recompiler: share translated DXIL across repeated pipeline builds #2767
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!2767
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2767"
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?
@kotekompotek on GitHub · 2026-11-26 11:24 UTC · original
kotekompotek:fix/shared-translated-dxil→main· +67 −47 · 5 files · 1 commits · openFixes #2609
console_to_dxil_inhands every callershader.as_ref().clone()— including RAM hits — andCompiledowned its whole DXIL as aVec<u8>, so every repeated pipeline build of one shader allocated and copied its whole translated bytes again. Building a dispatch chain then made another owned copy of the whole code for the fallback PSO.Compiled.dxilis now anArc<Vec<u8>>: the RAM-hit clone bumps a refcount and shares the cached bytes. The same sharing was carried toTwoPass.cs,dispatch_chain::Chain.whole_code(thebuild()parameter takes theArcdirectly, dropping itswhole.to_vec()copy) and the two-pass PS slots (two_pass_ps,ps_dxil). Call sites still see&[u8]/slice semantics throughDeref; the only places that materialise a copy now are genuine producers (to_vec()on a&[u8]pass-through, the disk-cacheCompiledconstruction).What is in it
Compiled.dxil,TwoPass.cs:Vec<u8>->Arc<Vec<u8>>Chain.whole_code+dispatch_chain::buildwholeparameter:Arc<Vec<u8>>— one fewer whole-DXIL copy per chain buildtwo_pass_ps/ps_dxil:Option<Arc<Vec<u8>>>a_ram_hit_clone_shares_the_translated_bytesasserts storage identity (as_ptr) across 8 RAM hits — fails onmain("the RAM hit copied the whole DXIL"), passes hereshader_cache_skips_repeated_translation_and_disk_lookups: its deliberate mutation of the cloneddxilis replaced by anArc::ptr_eqsharing assertion (callers only read the bytes)Tested
GTX 1050, Windows 11, stable-x86_64-pc-windows-msvc.
cargo test -p xcl --lib a_ram_hit_clone_shares_the_translated_bytes— fails onb49be183(storage differs), passes on the headcargo test -p xcl --lib shader_cache_tests— 24 passedcargo test --workspace --no-fail-fast -- --test-threads=4ona173e209— 1432 passed / 4 failed / 47 ignored / 357 SKIPPED. Failures: the 3 known environment ones on this machine (gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark,stale_blob_cannot_bypass_the_offline_pipeline_cap,split_compute_program_prebuilds_and_caches_chain_pieces— GTX 1050 / SM 6.5 limits, failing onb49be183too) plusterminate_manual_completion_port_with_delayed_async_does_not_deadlock, which passes on a quiet rerun (load flake under the parallel release build)cargo build --release -p xclona173e209— cleanRegression run
xcl-smoke v1blocks,scripts/smoke.ps1 -Game "D:\GTA6.Xbox.v1.0.2.1", release build:main
b49be183:head
a173e209:Not tested
GPU-level change in dispatch times (allocation savings are structural; no timing harness run). No behavioural change to emitted bytes, samplers or chains — all read-only consumers.
AI use
Devin (SWE-2 High) located the sites, wrote the change and the test, ran the suite, release build and smoke runs.
@KOLESNiii on GitHub · 2026-11-26 11:42 UTC · original · reviewed
The
Vec<u8>→Arc<Vec<u8>>change looks right to me: every caller I checked only reads the bytes, anddispatch_chain::buildno longer copies the whole code. Two test points inline.Separately, the two smoke blocks aren't comparable: both show 0 frames shown, and
maincrashed with 5419 MB peak commit while the head stopped at 789 MB. That looks like the runs ended at different points, not a saving from this PR. A rerun of both that reaches frames would make the regression run meaningful.Reviewed with Claude Code (Claude Opus 5.5); I checked each point against the PR head.
@ -1787,2 +1787,4 @@owned.samplers.clear();// the clone shares the translated bytes instead of copying them: callers only readassert!(Arc::ptr_eq(&first.dxil, &owned.dxil));assert_eq!(first.dxil[67], 7);@KOLESNiii on GitHub · 2026-11-26 11:42 UTC · original
With
owned.dxil[67] = 99gone, nothing writes to the bytes any more, so this assertion can't fail:first.dxilandowned.dxilare the same allocation (theptr_eqjust above shows it). The test used to check that changing a clone of a cached entry leaves the cache alone. It no longer does.Either drop the assertion, or keep the isolation check on the copy-on-write path:
@ -1792,0 +1795,4 @@/// own bytes: repeated pipeline builds of one shader do not allocate and copy its whole/// DXIL again (#2609). `as_ptr` compares the byte storage, not the `Arc`s.#[test]fn a_ram_hit_clone_shares_the_translated_bytes() {@KOLESNiii on GitHub · 2026-11-26 11:42 UTC · original
The doc comment is about "the clone
console_to_dxil_inhands a caller", but the test never callsconsole_to_dxil_in. It callscached_shaderand then does.as_ref().clone()itself, copying line 172. Ifconsole_to_dxil_ingoes back to a full copy (e.g.Arc::new((*shader.dxil).clone())), this test still passes and #2609 comes back.Could the test go through
console_to_dxil_in, or could the RAM-hit step move into a small helper that bothconsole_to_dxil_inand the test call?@KOLESNiii on GitHub · 2026-11-26 11:44 UTC · original
Smoke run on a second machine (RTX 2070 SUPER, Windows 11, release builds,
scripts/smoke.ps1, 60 s):main
b49be183:head
a173e209:No regression: both render at a steady 60 presents per 2 s with no crashes or device removals. Peak commit is ~1.2 GB lower on the head, which fits the shared DXIL. Only one run each, so read the frame-count and memory differences as indicative, not as measurements.
🤖 Generated with Claude Code
@MatyEjsr on GitHub · 2026-11-26 11:52 UTC · original · edited 2026-11-26 12:30 UTC
Independent SM 6.6 NVIDIA verification and paired 60 s regression run for PR #2767 at head
a173e209151ff299a6a368df2b4e6c6c96f2ae3e(basemainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7), covering the SM 6.6 tests and presenting title run that could not run on the author's GTX 1050.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)(x86_64-pc-windows-msvc), DXC1.9.2602.17(dxcompiler.dll/dxil.dll), debug and release profiles.XCL_SAMPLE_*unset.cargo build --workspace -j 8(debug) andcargo build --release --workspace -j 8(release): both succeeded with 0 errors.cargo test -p xcl --lib shader_cache_tests -- --test-threads=1 --nocapture: 24 passed, 0 failed, 0 ignored, 0 SKIPPED (0.32 s), includinga_ram_hit_clone_shares_the_translated_bytesandshader_cache_skips_repeated_translation_and_disk_lookups.cargo test --workspace -j 8 -- gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark stale_blob_cannot_bypass_the_offline_pipeline_cap split_compute_program_prebuilds_and_caches_chain_pieces terminate_manual_completion_port_with_delayed_async_does_not_deadlock --test-threads=1 --nocapture): 4 passed, 0 failed, 0 ignored, 0 SKIPPED (0.68 s).cargo test --workspace -j 8 --no-fail-fast -- --test-threads=8 --nocapture: 1,411 executed passed, 25 SKIPPED (1,436 reportedokby cargo: 1,310 inxcl --lib, 126 across 35 integration test targets), 0 failed, 47 ignored.SKIPPEDlines across 25 test functions:no wave64(21 lines across 14 tests):dispatch_chain_native_wave64_builds_whole,a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,const_and_null_mask_operands_agree_with_hlsl_on_the_gpu,f16_programs_on_the_gpu(2 wave64 cases),f32_programs_on_the_gpu(6 wave64 cases),f64_programs_on_the_gpu,integer_programs_on_the_gpu(2 wave64 cases),mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware#1426refusals (3 lines insidef16_programs_on_the_gpuandf32_programs_on_the_gpuwave32 cases):V_MUL_F16,V_PK_MUL_F16: VOP3 modifiers,V_CVT_F16_F32no heap windows(1):heap_window_out_of_memory_falls_back_to_the_switch_formthe title under the debug layer (dred: false),the title under the debug layer (dred: true),uploads_start_from_each_subresources_stateCompiled.dxil,TwoPass.cs,dispatch_chain::Chain.whole_code, andtwo_pass_ps/ps_dxilpropagateArc<Vec<u8>>without cloning the underlying byte vector onShaderCacheRAM hits ordispatch_chain::build, whileShaderEntry::bytes()andShaderCache::insert()continue to account forshader.dxil.capacity()viaDeref.Regression run
Paired 60 s
scripts/smoke.ps1runs on a retail title (release build, warm cache):main (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7):PR head (
a173e209151ff299a6a368df2b4e6c6c96f2ae3e):(An initial cold/warming 60 s run on
a173e209151ff299a6a368df2b4e6c6c96f2ae3ealso exited0x0with1078 (PresentX 1078)frames shown,60 60 60presents per 2 s,0device removals,0crashes, and14912 MBpeak commit.)Not tested
d3d12SDKLayers.dllabsent),XCL_HEAP_WINDOWS=1OOM fallback, optionalXCL_SAMPLE_*tests, and isolated allocation microbenchmarks.AI use
scripts/smoke.ps1runs, and drafted this report.@ -1792,0 +1795,4 @@/// own bytes: repeated pipeline builds of one shader do not allocate and copy its whole/// DXIL again (#2609). `as_ptr` compares the byte storage, not the `Arc`s.#[test]fn a_ram_hit_clone_shares_the_translated_bytes() {@ettehn on GitHub · 2026-11-26 12:23 UTC · original
I tried the direct-entry test on Windows 11 (Rust 1.97.1 MSVC, DXC 1.8.2502.11), using the identical test on
a173e209andmainb49be183. The byte comparison passed on both, and the pointer comparison passed on the PR head and failed on main. No GPU dispatch or retail title is needed.This worked inside
shader_cache_tests:Ran
cargo test --locked -p xcl --lib public_translation_entry_shares_ram_hit_storage -- --test-threads=1with a separateXCL_DXIL_CACHEfor each build. For a permanent test, the repo's usual DXC availability guard would let it skip cleanly on machines without DXC.AI-assisted test and verification (OpenAI Codex).
@SzczepanGrela on GitHub · 2026-11-26 12:50 UTC · original
Additional RX 9070 / Wine verification, including the native-wave64 case skipped in the RTX 3090 report.
Tested
a173e209151ff299a6a368df2b4e6c6c96f2ae3e, against mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7with onlya_ram_hit_clone_shares_the_translated_bytesadded insideshader_cache_tests. Main production code was unchanged; no local source changes on the head.8293130ebe370b1+(local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, releasex86_64-pc-windows-gnu.XCL_REQUIRE_GPU=wave64,XCL_NETWORK=0, noXCL_SAMPLE_*. Windows libtest binaries invoked directly through GE-Proton Wine with--nocapture,--exactfor individual cases, and a fresh process per invocation.the RAM hit copied the whole DXIL.gpu::recomp::pso::shader_cache_tests::, both--test-threads=1and4: head 24 passed / 0 failed / 0 ignored. Main plus the new negative-control test: 23 passed / 1 failed / 0 ignored, with only that storage-identity assertion failing.gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: 1/0/0 on each revision, executing the GPU comparison rather than skipping.shaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_cap: 1/0/0 on each revision, includinggpu_word0=42.shaders_e2esynthetic CLI/translation suite: 8/0/0 per revision at both 1 and 4 threads. These are CLI/compilation checks, not full graphics-runtime coverage.Driver-cache control for
split_compute_program_prebuilds_and_caches_chain_pieces:VKD3D_SHADER_CACHE_PATHdirectory: 3/3 passes per revision, including the cached-piece checks.VKD3D_SHADER_CACHE_PATH=0: 3/3 failures per revision atpipelines.reused == 2(actual 0). This result differs with the cache setting on both sides.No skip markers or ignored tests in these runs. Raw summaries, repeated control failures, source inventories and executable hashes were checked after testing.
Not tested
Native Windows, other GPUs, full workspace suite, retail/smoke workloads, full graphics-runtime behavior, peak-memory savings, or performance. No FPS or memory-reduction claim from these synthetic checks.
AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, ran and checked the paired tests and cache-setting controls, and drafted this report. Publication authorized by the account owner.
@Prime1997 on GitHub · 2026-11-26 13:06 UTC · original · reviewed
Good within the reviewed scope; retain for integration. Sharing the cached DXIL through Arc is worth keeping. It avoids cloning the same byte storage for repeated cache retrievals while retaining the existing cache ownership.
PR head
a173e209151ff299a6a368df2b4e6c6c96f2ae3eintegrated locally with current mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. The detached worktree remains at main with the combined changes staged, tree21881fc47d87b88aa3ba04a4fa92f7e776e789f4; it is an uncommitted integration candidate, not a clean PR-head run. Source patch SHA-25663a600b1dbc32d3f8d59ea961cb317141289d9af89e702850105dcd3e0c621b8.Targeted result: 2 passed, 0 failed, 0 ignored, 0 skipped. Each exact filter ran in a fresh process:
gpu::recomp::pso::shader_cache_tests::a_ram_hit_clone_shares_the_translated_bytesgpu::recomp::pso::shader_cache_tests::shader_cache_skips_repeated_translation_and_disk_lookupsBuild:
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Run:<test-exe> <each-exact-filter-above> --exact --test-threads=1 --nocapture. Private executable/target paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug. These selected fixtures did not dispatch GPU work.Not tested: The two focused tests check shared storage and repeated cache lookups. They do not cover eviction, every public translation entry point or peak memory in a title. No whole suite or retail smoke was run for this batch; this is not merge certification.
AI use: Codex (GPT-6) reviewed source, ran the selected tests and verified raw results. Optional temporary Discord for coordinating contributor work, testing and comparing results.
@Decodere on GitHub · 2026-11-26 23:10 UTC · original
Independent desktop NVIDIA verification of PR #2767 at head
a173e209151ff299a6a368df2b4e6c6c96f2ae3e(1commit; exact parent & merge-base:b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
a173e209)cargo test --release -p xcl --lib a_ram_hit_clone_shares_the_translated_bytes -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1336 filtered out× 3 (0.00s,0.00s,0.00s)cargo test --release -p xcl --lib gpu::recomp::pso::28 passed; 0 failed; 1 ignored; 1308 filtered out(0.08s;repeated_pso_shader_compileis#[ignore])cargo test --release -p xcl --lib hle::d3d12x::real::60 passed; 0 failed; 0 ignored; 1277 filtered out(0.39s)cargo test --release -p xcl --lib shaders::10 passed; 0 failed; 0 ignored; 1327 filtered out(0.20s;1test self-skipped at runtime, see below)cargo build --release -p xcl --bin xcl1m 12s, exit0)Note on
shaders:::shaders::tests::pso_measurement_compiles_an_exact_synthetic_recordprintedSKIPPEDat runtime (0x887A002D) because Windows Developer Mode is disabled on this host (required by D3D12 to disable the driver shader cache); the remaining9tests executed and passed.Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):PR #2767 (
a173e209151ff299a6a368df2b4e6c6c96f2ae3e):Runtime log observations (
xcl.log)9222log lines,0[ERROR]/ device-removal / panic lines.19552 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14002 MB committed by the process; video memory 6114 MB local, 4682 MB non-local.Limits of coverage
Arc-backed DXIL buffer sharing on RAM cache hits (a_ram_hit_clone_shares_the_translated_bytes, 3/3) and integration withgpu::recomp::pso::,hle::d3d12x::real::, andshaders::passed cleanly (repeated_pso_shader_compileremained#[ignore];pso_measurement_compiles_an_exact_synthetic_recordself-skipped because Windows Developer Mode is off).title: 29640639(frame-count delta vs. cached parent smoke reflects single-run startup variance, not this PR).AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
@JJAutoCompare on GitHub · 2026-11-27 00:21 UTC · original
Tested:
a173e209151ff299a6a368df2b4e6c6c96f2ae3eon Windows 11 build 26200, Ryzen 7 3800X, Rust 1.100.0 MSVC, debug, DXC 1.9.2602.17. Ranshader_cache_evicts_old_entries_and_skips_oversized_shadersand two syntheticverify_pr2767_probes with--test-threads=1 --nocapture. Three passed, no failures, ignores or skips. The checked-in fixture covers eviction and entry limits. The temporary test-only probes found that a 68-byte DXIL vector reserved at 4,096 bytes exceeded a 4,096-byte budget once the one-byte source was counted. The caller kept the original pointer and bytes after eviction. Two calls throughconsole_meshalso shared the 2,316-byte compute-pass buffer, while the 4,184-byte passthrough bytes matched at distinct addresses.Not tested: GPU execution, driver PSO creation, deferred chain ownership, full suite and retail smoke.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the checks and wrote this report.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.