D3D12.X: fall back to an in-memory shader cache session (#1108) #1211
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!1211
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1211/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?
@ksanjeev284 on GitHub · 2026-11-24 13:17 UTC · original
ksanjeev284:pr-1108-shader-cache-session→main· +360 −0 · 3 files · 1 commits · merged 2026-11-24 15:58 UTCWhen
ID3D12Device9::CreateShaderCacheSessionfails on the PC runtime (such as returningE_INVALIDARGorE_NOTIMPLunder vkd3d-proton / GE-Proton, or when a title passes flags the host runtime rejects), titles like the retail RAGE build hit a fatalint3breakpoint immediately after checking theHRESULT. HookCreateShaderCacheSessionon adopted devices so native PC sessions continue to be used whenever they succeed, and fall back to an in-memoryID3D12ShaderCacheSessionimplementation when the host runtime refuses the call.Fixes #1108.
What is in it
crates/xcl/src/hle/d3d12x/shader_cache_session.rs: in-memoryID3D12ShaderCacheSessionCOM object implementingIUnknown/ID3D12Object/ID3D12DeviceChild,GetDevice, two-stepFindValue(DXGI_ERROR_NOT_FOUND, size query,E_NOT_SUFFICIENT_BUFFER, copy-out),StoreValue(capped at 32 MiB per store),SetDeleteOnDestroy,GetDesc, and shared(Identifier, Version)stores forD3D12_SHADER_CACHE_MODE_DISK, plus a GPU unit test exercising the fallback path throughID3D12Device9::CreateShaderCacheSession.crates/xcl/src/hle/d3d12x/real.rs&crates/xcl/src/hle/d3d12x/mod.rs: overrideCreateShaderCacheSessiononKind::Deviceto call the PC method first and fall back toshader_cache_session::create_fallbackon failure with a one-time log entry.Tested
rustc 1.88.0 (6b00bc388 2025-06-23), debug + release.cargo +1.88.0 test -p xcl --lib shader_cache_session: 1 passed, 0 failed (D3D12.X: CreateShaderCacheSession failed on the PC runtime (0x80070057) – using an in-memory session).cargo +1.88.0 test --workspace --no-fail-fast -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched: 740 passed, 1 failed (hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory, pre-existing sandboxVirtualQueryfailure on unmodifiedmain), 41 ignored (SKIPPED GPU tests: 2no wave64).Regression run
main:
PR:
Not tested
#1108reproduces end-to-end (tested on Windows 11 by forcingCreateShaderCacheSessionrejection with unsupported flags in the unit test, plus retail title regression smoke on Windows).AI use
ID3D12ShaderCacheSessionfallback COM table, unit test, and PR description; reviewed and verified locally against the test suite and retail smoke runs.@DavidM1911 on GitHub · 2026-11-24 13:47 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Note: the full
d3d12xlib filter currently aborts with 0xc0000005 on unmodifiedmaintoo (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.@Aniseto on GitHub · 2026-11-24 15:08 UTC · original
Ran the PR's own test at
560216b:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 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.
rejected_create_shader_cache_session_falls_back_to_working_in_memory_sessionpasses here. I ran the test by name for the reason the earlier report gives: the wholed3d12xlib filter aborts with 0xc0000005 on unmodifiedmainon this machine too, so it is not attributable to this PR.This adds a Blackwell part (RTX 5070 Ti, driver 32.0.16.2124) on Windows 11 build 26200 to the RTX 3060 Ti report above.
Not tested: a title run that reaches the fallback (no unpacked title here), RDNA2/RDNA4 and Intel GPUs, Wine, release profile.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the test, wrote this report; the worktree was not modified.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@DavidM1911 on GitHub · 2026-11-26 03:52 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