D3D12.X: share fallback memory shader cache sessions #2878
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2878"
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?
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-26T20:43:48Z.
Fallback D3D12 MEMORY shader-cache sessions with the same identifier and version previously used separate stores. A second live session could not find a value written by the first. Share the store while any matching session remains alive, then discard it after the last session closes, matching the native behavior measured on this machine.
What is in it
crates/xcl/src/hle/d3d12x/shader_cache_session.rs: share matching memory-session stores, serialize creation and last-session cleanup, reject duplicate stores without replacing existing bytes, and test lifetime, isolation and duplicate handling.Tested
c1a8ecc7, a local native-D3D12 versus fallback probe: before the fix, a live second fallback session returnedDXGI_ERROR_NOT_FOUNDwhere native returned the 13-byte value. After the fix, both returned the value and a fresh session after the final release missed it. An earlySetDeleteOnDestroydid not prevent the live peer reading the value. One post-fix parity run passed; this probe is not included in the PR.1f4cf9ef, both focused fallback tests passed with zero skips. The original session and a second live session each receivedDXGI_ERROR_ALREADY_EXISTSwhen trying to replace a key. The surviving session read the original bytes.0x887a0036on duplicateStoreValue, and the peer read back the original byte. This is also relevant to the replacement assumptions in the independently proposed capacity fix. Native results on #2332cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4: head1f4cf9efhad 1,442 passed, 5 failed, 47 ignored. Base8b957bechad 1,441 passed, 5 failed, 47 ignored. Each logged 26 GPU skips (21 wave64, three unsupported per-lane forms, one driver-cache option, one heap-windows feature).Regression run
The same game image and requested 60-second duration were used with clean release builds, separate empty data and shader cache directories, and networking disabled. Both processes exited during startup with zero presents. The retail regression gate remains outstanding and the PR remains a draft.
Main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-26T21:13:51Z.
Ran the shader-cache session tests at
c1a8ecc7(draft PR) on an NVIDIA Blackwell desktop part: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.
Both tests pass:
memory_sessions_share_entries_until_the_last_releaseandrejected_create_shader_cache_session_falls_back_to_working_in_memory_session. They are CPU-side tests of the fallback store and do not open a D3D12 device. The author ran the same two tests on an RTX 5070 (driver 616.92, DXC 1.8.2502.11); this adds a desktop RTX 5070 Ti on driver 32.0.16.2124 with DXC 1.9.2609.5. I did not repeat the author's native-vs-fallback probe or the full-suite comparison.Not tested: the native D3D12 comparison probe, the full workspace suite and its known failures, a paired smoke run, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game 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.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T06:29:07Z.
Review: COMMENTED
Could the shared MEMORY store reject duplicate keys before modifying the value? Native
ID3D12ShaderCacheSession::StoreValuespecifiesDXGI_ERROR_ALREADY_EXISTSfor an existing key. The fallback already overwrote same-session duplicates, but sharing the store makes a second live session able to replace the first session's cached bytes.I compiled the exact parent and PR fallback modules into a Windows CPU harness and opened two same-ID MEMORY sessions in each. A stored byte A in the first session, then a store of B under the same key in the second, gave
S_OKfor the second store on both revisions. Reading through the first session returned A on the parent and B on the PR head. The native API contract calls for rejection of the duplicate and preservation of A in the shared cache. The harness used no native D3D12 device.Shared-store lookup · Insertion · D3D12 shader cache contract
AI-assisted review (GPT-6.2 Sol).
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T19:03:37Z.
Addressed the duplicate-key review in
1f4cf9ef. The fallback checks for an existing key while holding the shared store mutex and returnsDXGI_ERROR_ALREADY_EXISTSbefore changing the bytes or the store's size accounting.The lifetime regression now tries to replace the first value both through its original session and through a second live session with the same ID and version. Both calls returned the expected HRESULT. After the first session closed, the second still read the original six bytes. The two focused shader-cache tests passed on Windows/Ryzen 7 5700X3D with no skips, including the device-backed forced-fallback path. This revision has focused test coverage only; the draft is still awaiting the required clean retail smoke comparison.
AI assistance: OpenAI Codex (GPT-6) implemented and tested the correction.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T16:03:12Z.
The duplicate-key review is addressed in
1f4cf9ef. The focused tests passed there, including writes from a second live session, and the matched local suites had the same failure set.The outstanding item is the runtime regression check. Our paired smoke attempts both stopped during title startup before the first present. If someone has a title that renders on current main, could you run
scripts/smoke.ps1on clean main and this draft's clean head using the same title, GPU and run duration, and share both generatedxcl-smokeblocks here? A compatible title is enough for the regression check, even if it never opens a fallback memory shader-cache session.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:06:45Z.
Triage (#1607) – head
1f4cf9eThe first commit, sharing MEMORY-mode fallback stores between live sessions with the same identifier and version, is not in any other PR or on main.
The second commit (
1f4cf9ef, Store::insert returning DXGI_ERROR_ALREADY_EXISTS without replacing the value) makes the same duplicate-key change as #2332, which was opened first. #2332 also returns DXGI_ERROR_CACHE_FULL, where this PR still returns S_OK and drops the entry. Agree with #2332 on which PR keeps that part, and drop it from the other.The second commit's subject has no area prefix ('D3D12.X: ...').
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.