D3D12.X: check shader cache capacity before copying entries #2322
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2332"
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 storrmzz on 2026-11-25T14:57:33Z.
Keep the fallback shader-cache store within its 32 MiB key/value budget before allocating or copying either input. Address the native StoreValue feedback: existing keys return
DXGI_ERROR_ALREADY_EXISTS, without replacing their values or changing capacity accounting.What is in it
Tested
225c039ab26c025944091419dafc900a02b33cc9, unchanged main53e85fb124eae624641e9884517e4f3c4a7d8794.cargo build --workspace --jobs 2: passed on PR.cargo test -p xcl --lib shader_cache_session --jobs 2 -- --test-threads=1 --nocapture: 5 passed, 0 failed, 0 ignored, 0 skipped on PR.b2f681a157028116009dfcc4ef94671c80a960f4produced 2 passed / 2 failed. Both duplicate regressions failed before the fix.cargo test --workspace --no-fail-fast --jobs 2 -- --test-threads=4 --nocapture: PR 2793 passed, 4 failed, 49 ignored; 12 distinct explicit SKIPPED messages; unchanged main 2789 passed, 4 failed, 49 ignored; 12 distinct explicit SKIPPED messages. All 41 Cargo test/doc-test targets completed on each revision. Explicit skips are not GPU coverage.git diff --check: passed.The same four failed tests were reproduced on unchanged main, with the same assertions. The initial parallel main run additionally aborted in the UMA coherent-window restore path (Windows error 487, process exit 130088963); its library target was incomplete. Its other 40 targets finished with 138 passed, 1 failed and 20 ignored; 11 distinct SKIPPED messages were recorded across that partial run. The main counts above come from the subsequent complete repeat, not that partial run. The PR run completed without this abort; this change does not claim to fix it.
Full-suite failures (see paired results above):
gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_formgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipelinetwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsNative D3D12 probe, directly using
D3D12CreateDevice/ID3D12Device9::CreateShaderCacheSession, without XCL hooks: with a 32 MiB MEMORY cache and a 32 MiB DISK cache, a duplicate with a nonempty oversized value returned0x887a0036. With DISK filled until another 1 MiB entry returned0x887a0034, the same-sized duplicate still returned0x887a0036; the original bytes remained readable. A new oversized key returned0x887a0034. This agrees with the Microsoft StoreValue contract. Native MEMORY eviction differs from the fallback's fixed total budget: a failed large new insertion could evict an earlier key. No identical eviction behavior is claimed.Compatibility with #2878
Reviewed #2878 at
1f4cf9ef8b560974f0abc7d07f800af3f61d121c. Both reject duplicate keys. Theirinsertedits overlap and need a textual conflict resolution retaining this PR's capacity error; session-sharing/lifetime changes are not included here.A temporary local combination of this PR with #2878's session-sharing file, resolving the overlap to retain the capacity checks and both sets of tests, passed the same focused
shader_cache_sessioncommand: 6 passed, 0 failed, 0 ignored, 0 skipped. This is an uncommitted integration check, not the published PR or a full integration-suite result; the original PR tree was restored afterward.Explicit SKIPPED messages from the paired full runs
Regression run
Not run: no owned, runnable retail title is available. This PR remains a draft; no
xcl-smokeblocks are fabricated.Not tested
E_INVALIDARG; native measurements above used valid 32 MiB descriptors.AI use
Created with AI assistance from OpenAI Codex (GPT-6).
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T15:30:54Z.
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (--release --locked,--test-threads=2): 144 passed / 3 failed / 1 ignored, same three baseline failures as plainorigin/mainon this rig (rig's known baseline: fuzz seed 1003 of #2115,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed).hle::d3d12x::shader_cache_session::tests::cache_capacity_*(oversized entry rejected, exact-limit accepted then next key rejected, failed replacement preserves previous value, replacements accounted in a full store): all 4 pass on this lane (--exactmodule filter,--test-threads=1), including through the real vkd3d-protonD3D12_GPU_PRIVATE_VIRTUAL_ADDRESSsession path this driver provides.Caveat, one-off: the very first suite run on this head died mid-suite with
radv/amdgpu: The CS has been rejected (-14)andD3D12 device removed: 0x887a0005(test process exit 5, no individual failure recorded, no GPU reset in dmesg). A second full suite run on the same head was fully clean, and this rig has produced the same kernel-side CS reject under heavy host memory pressure (it co-hosts an ~80 GB pinned model server). No crash reproduces; mentioning it only for completeness, evidence leans environmental rather than this change.AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T15:35:23Z.
Independent focused verification of exact PR head
ab861b8196779f65209de31eef1e5f97ee1eb6d8on Windows 11 build 26200, AMD Radeon RX 6800M (driver30.0.13002.13003), Rust 1.99 MSVC, DXC/DXIL 1.9.2609.5.Tested
cargo test --locked -p xcl --lib shader_cache_session::tests:: -- --test-threads=1 --show-output: 5 passed, 0 failed, 0 ignored, 0 explicit skips. The four capacity tests cover an oversized entry, exact-limit insertion, failed replacement preserving the old value, and replacement/shrinking accounting.CreateShaderCacheSession failed on the PC runtime (0x80070057) – using an in-memory session; it checked miss handling, store and exact readback, buffer-too-small behavior, parent-device identity, and delete-on-destroy cleanup. The clean fixture uses the default device, so this run does not identify which adapter it used.XCL_ADAPTER=6800Mchose and printedshader cache test adapter: AMD Radeon RX 6800M; the same five tests passed with 0 failures and 0 explicit skips. I restored the selector change; the PR checkout is clean.I did not reproduce a host cache-session refusal beyond the fixture's deliberately invalid flags, run a full workspace suite, or run a title smoke pair on this PR.
AI use: OpenAI Codex (GPT-6) ran the tests and prepared this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:04:41Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-26T13:30:14Z.
Review: COMMENTED
Good within the targeted test scope; retain for integration. Checks the capacity before copying shader-cache entries, preserves a previous value when replacement cannot fit, and accounts for replacements correctly.
Reviewed PR head
ab861b8196779f65209de31eef1e5f97ee1eb6d8. Tested an isolated, uncommitted merge-tree integration with latest mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, tree2c318f747df7b6edd4d82517db51991d57374d37; this is not a clean PR-head run. Integration source overlay SHA-256:eeeb73b447215fc122aff8186c907d88cc4ba0562448502f1012bd6769c666d5.Measured: 4 passed, 0 failed, 0 ignored, 0 skipped. Exact selected filters, each run in a fresh process:
hle::d3d12x::shader_cache_session::tests::cache_capacity_rejects_an_oversized_entryhle::d3d12x::shader_cache_session::tests::cache_capacity_accepts_exact_limit_and_rejects_another_keyhle::d3d12x::shader_cache_session::tests::cache_capacity_failed_replacement_preserves_the_previous_valuehle::d3d12x::shader_cache_session::tests::cache_capacity_accounts_for_replacements_in_a_full_storeBuild:
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Run each:<test-exe> <exact-filter> --exact --test-threads=1 --nocapture. Private target/executable paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB, Rust 1.100.0 MSVC debug; private temporary/cache paths, two low-priority build jobs, 90-second per-test bound.Scope: Four CPU boundary and replacement-accounting fixtures. No actual title cache workload or whole-process memory bound was measured. No full suite, retail run, sustained memory pressure or performance benefit is established. Passing these fixtures is not merge certification.
AI use: Codex (GPT-6) inspected the changes and fixtures, ran the checks and verified raw receipts. Optional temporary Discord for coordinating contributor work, testing and comparing results.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T16:29:11Z.
Tested on an RTX 5070 (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, using a standalone native D3D12 probe. I opened two simultaneous MEMORY sessions with the same identifier and version. The initial
StoreValuesucceeded. A second store of the same key with different bytes returnedDXGI_ERROR_ALREADY_EXISTS(0x887a0036) both through the original session and through its peer. The peer then read back the original byte. This matches the documentedStoreValuecontract. Microsoft's D3D12 shader-cache specOn the current #2332 head
b2f681a1, the fallback capacity tests expect an existing value to be replaced or shrunk. That expectation conflicts with the native result and with the duplicate-key behavior in #2878. The capacity guard can still be tested on new keys without expecting a live entry to be replaced.Not tested on the #2332 runtime, Wine, AMD or a retail title. OpenAI Codex with GPT-6.2 Sol ran the native probe and prepared the report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:51:00Z.
Triage (#1607) – head
225c039#2878 also changes
Store::insertin shader_cache_session.rs so a duplicate key returns DXGI_ERROR_ALREADY_EXISTS instead of replacing the value, so the two PRs will conflict there. The approaches differ: this PR also returns DXGI_ERROR_CACHE_FULL when the 32 MiB cap is exceeded, while #2878 still returns S_OK and drops the entry, and #2878 additionally shares MEMORY-mode sessions. The HRESULT values (0x887A0034, 0x887A0036) match the DXGI definitions, and the tests cover the exact-limit, oversized and duplicate-in-full-store cases. No other problems found in the diff.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.