D3D12.X: cache direct-DXIL mesh shaders, coalesce shader builds, make MS/GS lazy, and cache two-pass/graphics PSO blobs #1836
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!1836
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1836/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?
@raylitebull on GitHub · 2026-11-24 21:37 UTC · original
raylitebull:perf/pso-direct-dxil-speedup→main· +541 −53 · 2 files · 1 commits · merged 2026-11-25 00:04 UTCSpeeds up PSO and direct-DXIL compilation throughput by caching direct-DXIL mesh shaders in
ShaderCache, coalescing concurrent identical shader builds, raisingShaderCache's entry cap to 4096 (bounded by the 64 MiB byte cap), making console MS/GS two-pass translation lazy on first use, and caching two-pass/graphics PSO driver blobs to disk.Part of #1269 and #1673.
What is in it
crates/xcl/src/gpu/recomp/pso.rs: addStage::Meshcaching toShaderCache, raiseSHADER_CACHE_MAX_ENTRIESto 4096 withcompact_lru, add per-ShaderKeyshader_flightcoalescing so concurrent threads share in-flight compilations, skip synchronous compilation whendxc::defer()is active during preload, and addshader_cache_coalesces_concurrent_same_key_compiles.crates/xcl/src/hle/d3d12x/real.rs: maketwo_pass_of/build_mesh_or_gstranslation lazy at first use instead of eagerly blocking preload, and addGRAPHICS_BLOBS(256 MiB bounded) + disk driver-blob caching (graphics_path,keep_graphics_blob,graphics_blob_key) alongsidekeep_compute_blob; hashD3D12_BLEND_DESC,D3D12_RASTERIZER_DESC, andD3D12_DEPTH_STENCIL_DESCfield-by-field (avoiding uninitialized struct padding bytes caught in review by @WebIdentity1), withgraphics_blob_key_tracks_shaders_samplers_and_stateandgraphics_blob_key_ignores_struct_padding_bytes.Tested
10.0.22631.0),rustc 1.99.1 (58cf8f9c3 2026-10-13), release & debug builds, rebased onto689f2db(04f34ce).04f34ce:cargo test -p xcl --lib hle::d3d12x::real::graphics_blob_tests: 2 passed, 0 failed (graphics_blob_key_ignores_struct_padding_bytes+graphics_blob_key_tracks_shaders_samplers_and_state);cargo test -p xcl --lib gpu::recomp::pso::: 14 passed, 0 failed; independent verification on RTX 3080 Ti (@thehollowedone:graphics_blob_key_2/2,shader_cache_coalesces_concurrent_same_key_compiles1/1,e2e3/3D3D12 debug-layer pass).c6c9825:cargo test -p xcl --test e2e -- --test-threads=1: 3 passed, 0 failed (0 D3D12 debug-layer errors), plus a clean RTX 3060 60 sscripts/smoke.ps1pair from @Anon64 (1493/1476frames,0removals/crashes).Regression run
main:
PR:
Not tested
04f34cepast the 60 s smoke window,scripts/smoke.ps1on NVIDIA or Intel GPUs on04f34ce, fullcargo test --workspacerun on04f34ce, wave32-only AMD adapters, and Linux/Wine/vkd3d-proton.AI use
github-bot referenced this pull request2026-11-26 05:10:45 +00:00
@Anon64 on GitHub · 2026-11-24 21:52 UTC · original
Regression run for this PR: head
c6c9825, based onmainc4d37be. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, back to back with themainrun.main
c4d37be:this PR:
No device removals or crashes; 101 % of main's frames, 90 % of its peak commit.
Not tested: the whole suite; world loading with this PR; whether the title reaches all of the changed code in these 60 s (default settings, so the direct DXIL path is off).
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@WebIdentity1 on GitHub · 2026-11-24 21:55 UTC · original
I found a deterministic cache-key miss on exact head
c6c98255682406235fe20b9503968fb004d3bc4a.graphics_blob_keyhashes the rawD3D12_DEPTH_STENCIL_DESCbytes. On Windows x64 that struct has two padding bytes betweenStencilWriteMaskandFrontFace; they are not D3D12 state. Two descriptors with identical fields but different padding generated different keys, so the same graphics PSO can get different in-memory/disk cache names.I added a 20-line synthetic regression that sets only those two padding bytes differently and checks the descriptors' semantic fields are equal. On unchanged #1836 + test, Windows returned 0 passed / 1 failed / 0 ignored as expected (key hashes
17135582160965048857vs18380725938958333703, same 4-byte shader inputs). Replacing the raw depth-stencil hash with field-by-field hashing made that regression and your existinggraphics_blob_key_tracks_shaders_samplers_and_statetest pass: 2/0/0. Changing a real depth field still changes the key.I also ran a matched desktop-session RTX 3090 full workspace pair,
cargo build --locked --workspacethencargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output, after refreshing source timestamps for the shared Cargo target. Both builds exited 0. Across 20 targets, control (your head + regression) was 960 passed / 2 failed / 43 ignored; local fix was 961 passed / 1 failed / 43 ignored; 25 explicit skips each. The only remaining failure on the fix is the existinggpu_clamp_and_omod_per_instructionfailure, which also failed on control. All 303 tracked Windows source files matched their SHA-256 manifests before and after, and there was no timeout or candidate-only failure.This verifies cache-key identity and the broader synthetic suite; it does not measure a cold/warm graphics PSO driver hit, compilation-time improvement, or retail rendering. The PR author still needs the required exact-head smoke after integrating any runtime change. I have kept the patch local for your PR rather than opening a competing one.
One-file patch (34 insertions, 1 deletion)
@raylitebull on GitHub · 2026-11-24 22:19 UTC · original
@WebIdentity1 Thank you for catching that! You're completely right —
D3D12_DEPTH_STENCIL_DESC(andD3D12_BLEND_DESC::RenderTargettoo) contains compiler padding bytes that aren't part of D3D12 state.Updated
#1836in04f34ce(rebased onto689f2db):feed_podcalls ingraphics_blob_key(crates/xcl/src/hle/d3d12x/real.rs) with explicit field-by-field hashing acrossD3D12_DEPTH_STENCIL_DESC,D3D12_BLEND_DESC, andD3D12_RASTERIZER_DESC.graphics_blob_key_ignores_struct_padding_bytes(poisoningDepthStencilStateandBlendStatewith0xAAvs0x55before setting identical fields) —graphics_blob_tests(2 passed, 0 failed) andgpu::recomp::pso::(14 passed, 0 failed) pass.scripts/smoke.ps1regression pair on04f34cevs689f2db.@eizispark on GitHub · 2026-11-24 22:49 UTC · original
Hardware test report — commit
04f34ceVerified
04f34ce6d8722e8fcf27567e9ca4f421411b6196(rebased ontomain689f2db477c3c062cf162649781640ef8a977c18, clean merge): pass (0new failures vsmain689f2db).Tested
32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64 (stable-x86_64-pc-windows-msvc,rustc 1.100.0 (0ef1bc386 2026-11-09)), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads:975 passed, 2 failed, 45 ignored(8 skipped), vsmain689f2db972 passed, 2 failed, 45 ignored(8 skipped) on this adapter:--skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads) and the 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) are pre-existing onmain689f2db(#1679) on RDNA4;0new failures8 skipped: 6gpu::recomp::lower_dxil::testsf16/f32 direct-DXIL per-lane cases refused where#1426semantics differ from the console's;shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode required,0x887A002D);heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsgpu::recomp::pso::shader_cache_tests::shader_cache_coalesces_concurrent_same_key_compiles,hle::d3d12x::real::graphics_blob_tests(graphics_blob_key_tracks_shaders_samplers_and_state,graphics_blob_key_ignores_struct_padding_bytes),test_title_runs_and_game_folder_is_untouched, and native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) all passedRegression run (
scripts/smoke.ps1, 60 s, warm shader/driver cache)main(689f2db477c3c062cf162649781640ef8a977c18):PR (
04f34ce6d8722e8fcf27567e9ca4f421411b6196):Not tested
AI use
@grahamster2 on GitHub · 2026-11-24 23:03 UTC · original
Test report for c6c9825 on NVIDIA.
Tested
1d027e5(one CI-only commit after your basec4d37be).cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4: 961 passed, 0 failed, 43 ignored. main: 959 passed, 0 failed, 43 ignored. Same 22 SKIPPED lines on both (no wave64/refused/no heap windows).scripts/smoke.ps1, 60 s, same title:main:
PR:
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_WAIT_MS=50. The first run of each build had its own empty driver-blob cache and the NVIDIA DXCache cleared. The second run reused that build's cache.0xc0000005null write) at 148 s. This PR ended in device removed 0x887a0007 at 136.8 s, then a title crash at a different address. Main, #1834 and #1835 all ended in the same title crash, not a device removal.VCRUNTIME140.dll(memcpy read at 0xc804f6000) at 58 s, before the world loaded. Run B: device removed 0x887a0006 at 128 s, like main.Not tested
AI use
@raylitebull on GitHub · 2026-11-24 23:40 UTC · original
@grahamster2 Thank you for running the 180 s RTX 3080 checks on
c6c9825. We audited04f34ce(ShaderCache/shader_flightincrates/xcl/src/gpu/recomp/pso.rsandown_graphics/own_stream/graphics_blob_keyincrates/xcl/src/hle/d3d12x/real.rs) regarding the 58 sVCRUNTIME140.dllaccess violation (read at 0xc804f6000):0xc804f6000(0xc_xxxx_xxxx) is inside the guest title's own CPU virtual address range, which#1836's shader/PSO caching code never reads ormemcpys (own_graphicsandown_streamonly copy ownedD3D12_INPUT_ELEMENT_DESC,SemanticName, and subobject slices out of D3D12 PSO descriptors, andgraphics_blob_keyhashes fields in safe Rust).c6c9825commit tested there predates04f34ce, which replaced rawfeed_podstruct hashing with field-by-field hashing to fix the struct-padding cache-key bug (and passedgpu::recomp::pso::14/14,graphics_blob_tests2/2, RTX 3080 Tie2e3/3, and RX 9070 XT 60 s smoke).@Eterst on GitHub · 2026-11-24 23:58 UTC · original
Test report: the graphics driver blobs on a 32-lane NVIDIA card, retail title, world load
Tree:
main689f2db+ this PR (04f34ce, applied cleanly) + #684, #1273, #1741 and local diagnostics (dispatch markers, logging). This is not the PR's head on its own.XCL_DIRECT_DXIL=1, compute pipelines precompiled beforehand.Hardware: NVIDIA GeForce RTX 4070 SUPER 12 GB (driver 616.92, 32-lane waves), Ryzen 7 5700X, 32 GB RAM, Windows 10 22H2 (19045), release build.
Tests:
cargo test --release -p xcl --lib -- graphics_blob shader_cache gpu::recomp::pso:: culprit: 21 passed, 0 failed, 1 ignored.Runs (same title, same scripted input, 420 s each, the same tree with and without this PR):
driver blob absent;dxil\drivergrew from 825 to 866 filesdriver blob suppliedWithout the PR the title's recording thread waited in
bind::execute_indirect→pso_async::resolve_waitfor these graphics pipelines and presented nothing from a few seconds into its world load to the end of the run. With the PR's blobs on disk that wait was gone in the second run: frames went on after the point where the runs without it had stopped. That run later ended in an unrelated GPU timeout (a device removal during a compute pass), which this PR does not touch.Not tested: the PR's head alone, AMD, the HLSL path for compute (
XCL_DIRECT_DXILunset), Wine.AI use: Claude Code (Claude Opus 5.5) ran the builds, the tests and the runs, read the logs and wrote this report.
@thehollowedone on GitHub · 2026-11-24 22:23 UTC · original · edited 2026-11-25 00:11 UTC
Independent Windows check of 04f34ce on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC, debug.
cargo build --offline --locked --workspacesucceeded.cargo test --offline --locked -p xcl --lib graphics_blob_key_ -- --nocapture --test-threads=1: 2 passed, including the padding regression.cargo test --offline --locked -p xcl --lib shader_cache_coalesces_concurrent_same_key_compiles -- --nocapture --test-threads=1: 1 passed.cargo test --offline --locked -p xcl --test e2e -- --nocapture --test-threads=1: 3 passed, including the bundled title's D3D12 debug-layer draw. The tests reported zero skips.This run covered synthetic inputs. Retail world load and persistent cache hit rate were outside its scope.
AI-assisted. Codex (GPT-6 family, exact variant unavailable) ran the tests and drafted this report.
Graphics cache accounting follow-up on
80f4819Two workers can both miss the same graphics PSO key before either acquires the insertion lock. I ran the original locked insertion with two synthetic results for one key. The map retained one 3-byte blob while the budget charged 5 bytes. That extra charge can cause later cache entries to be refused before the 256 MiB budget is actually used. The compute version is already tracked in #826. Graphics insertion on main
A graphics-only local patch charges the bytes only when the key is vacant under the insertion lock. The new regression preserved the first blob and charged it once. Windows 11 build 26300, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC and DXC 1.8.2502.11. The offline locked release workspace build passed.
cargo test --offline --locked --release -p xcl --lib <filter> -- --nocapture --test-threads=1passed forgraphics_blob_tests(3/3),compute_blob_tests(1/1), anddriver_cache::tests(4/4). The release--test e2etarget passed 3/3, including the D3D12 debug-layer draw. These are synthetic checks. Retail impact has not been measured.AI-assisted. Codex (GPT-6 family, exact variant unavailable) prepared the local patch, ran the tests, and drafted this update.
@DavidM1911 on GitHub · 2026-11-25 01:03 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@DavidM1911 on GitHub · 2026-11-26 06:28 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin