D3D12.X: check shader cache capacity before copying entries #2332

Open
github-bot wants to merge 1 commit from github-bot/gh-2332 into main AGit
Owner

@⁠storrmzz on GitHub · 2026-11-25 14:57 UTC · original
storrmzz:shaders/cache-capacity-check → main · +88 −13 · 2 files · 1 commits · draft

The fallback shader cache copied keys and values before checking its 32 MiB limit, then reported S_OK even when it discarded the entry. Reject oversized inputs before copying, check remaining capacity under the store lock, and return DXGI_ERROR_CACHE_FULL without losing a previous value.

What is in it

  • Capacity checks in shader_cache_session.rs, four regression tests, and README documentation. This affects the fallback used when the host refuses CreateShaderCacheSession.
  • No measured world-loading benefit or claim to fix a retail-title issue.

Tested

  • Head ab861b8196779f65209de31eef1e5f97ee1eb6d8, base 06c9f5505f63f10c5ec49ef932d75b2c28177324. Windows 11 Pro build 26300, Ryzen 7 8840HS, Radeon 780M (driver 32.0.31033.3), rustc 1.100.0 MSVC, debug.
  • cargo build --locked --workspace --jobs 2: passed.
  • cargo test --locked --workspace --no-fail-fast --jobs 2 -- --test-threads=4: 1268 passed, 1 failed, 46 ignored. All four new tests and the existing fallback-session GPU test pass. The failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722), reproduced on unchanged main before the rebase too.
  • Three regression tests were first run against unchanged production code: all failed because StoreValue returned S_OK instead of DXGI_ERROR_CACHE_FULL, then passed with the fix. The fourth checks accounting while replacing and shrinking entries at capacity.
  • A separate local integration branch at ab2ff4dc8d82e524ac5230dc58c2fcdc2989766a, additionally carrying upstream PRs #2192, #1946 and #2237, builds and passes the full command above: 1271 passed, 0 failed, 46 ignored. Those commits are NOT included in this PR.
  • Both final full runs report 10 SKIPPED events: six unsupported direct-DXIL f16/conversion cases, a driver-cache benchmark requiring Developer Mode, two debug-layer tests and a heap-window test. These are not coverage. git diff --check passes.

Regression run
Not run: no unpacked retail title is available. The required main/head smoke pair is still needed before merge.

Not tested
Retail titles, Wine/vkd3d-proton, other GPUs, ignored tests and optional XCL_SAMPLE_* inputs (unset). No measured peak-memory or world-load improvement. The PR branch's complete suite is not green until the independent shader failure is resolved upstream.

AI use
This PR was created with AI assistance from OpenAI Codex (gpt-6-astra).

**@⁠storrmzz** on GitHub · 2026-11-25 14:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2332) `storrmzz:shaders/cache-capacity-check` → `main` · +88 −13 · 2 files · 1 commits · draft The fallback shader cache copied keys and values before checking its 32 MiB limit, then reported S_OK even when it discarded the entry. Reject oversized inputs before copying, check remaining capacity under the store lock, and return DXGI_ERROR_CACHE_FULL without losing a previous value. **What is in it** - Capacity checks in `shader_cache_session.rs`, four regression tests, and README documentation. This affects the fallback used when the host refuses CreateShaderCacheSession. - No measured world-loading benefit or claim to fix a retail-title issue. **Tested** - Head `ab861b8196779f65209de31eef1e5f97ee1eb6d8`, base `06c9f5505f63f10c5ec49ef932d75b2c28177324`. Windows 11 Pro build 26300, Ryzen 7 8840HS, Radeon 780M (driver 32.0.31033.3), rustc 1.100.0 MSVC, debug. - `cargo build --locked --workspace --jobs 2`: passed. - `cargo test --locked --workspace --no-fail-fast --jobs 2 -- --test-threads=4`: 1268 passed, 1 failed, 46 ignored. All four new tests and the existing fallback-session GPU test pass. The failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722), reproduced on unchanged main before the rebase too. - Three regression tests were first run against unchanged production code: all failed because StoreValue returned S_OK instead of DXGI_ERROR_CACHE_FULL, then passed with the fix. The fourth checks accounting while replacing and shrinking entries at capacity. - A separate local integration branch at `ab2ff4dc8d82e524ac5230dc58c2fcdc2989766a`, additionally carrying upstream PRs #2192, #1946 and #2237, builds and passes the full command above: 1271 passed, 0 failed, 46 ignored. Those commits are NOT included in this PR. - Both final full runs report 10 SKIPPED events: six unsupported direct-DXIL f16/conversion cases, a driver-cache benchmark requiring Developer Mode, two debug-layer tests and a heap-window test. These are not coverage. `git diff --check` passes. **Regression run** Not run: no unpacked retail title is available. The required main/head smoke pair is still needed before merge. **Not tested** Retail titles, Wine/vkd3d-proton, other GPUs, ignored tests and optional XCL_SAMPLE_* inputs (unset). No measured peak-memory or world-load improvement. The PR branch's complete suite is not green until the independent shader failure is resolved upstream. **AI use** This PR was created with AI assistance from OpenAI Codex (gpt-6-astra).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:27:49 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 15:30 UTC · original

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 target x86_64-pc-windows-gnu run 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 plain origin/main on 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).
  • The four new tests 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 (--exact module filter, --test-threads=1), including through the real vkd3d-proton D3D12_GPU_PRIVATE_VIRTUAL_ADDRESS session 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) and D3D12 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.

**@⁠SlopTart** on GitHub · 2026-11-25 15:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7166961238) **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 target `x86_64-pc-windows-gnu` run 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 plain `origin/main` on 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`). - The four new tests `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 (`--exact` module filter, `--test-threads=1`), including through the real vkd3d-proton `D3D12_GPU_PRIVATE_VIRTUAL_ADDRESS` session 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)` and `D3D12 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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 15:35 UTC · original

Independent focused verification of exact PR head ab861b8196779f65209de31eef1e5f97ee1eb6d8 on Windows 11 build 26200, AMD Radeon RX 6800M (driver 30.0.13002.13003), Rust 1.99 MSVC, DXC/DXIL 1.9.2609.5.

Tested

  • Clean checkout: 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.
  • The fifth test used a D3D12 device and logged 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.
  • Local test-only selector change: XCL_ADAPTER=6800M chose and printed shader 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.

**@⁠luckyteagirl** on GitHub · 2026-11-25 15:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7167075742) Independent focused verification of exact PR head `ab861b8196779f65209de31eef1e5f97ee1eb6d8` on Windows 11 build 26200, AMD Radeon RX 6800M (driver `30.0.13002.13003`), Rust 1.99 MSVC, DXC/DXIL 1.9.2609.5. **Tested** - Clean checkout: `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. - The fifth test used a D3D12 device and logged `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. - Local test-only selector change: `XCL_ADAPTER=6800M` chose and printed `shader 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 18:04 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-25 18:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7170406259) 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!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2332/head:github-bot/gh-2332'
git switch 'github-bot/gh-2332'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2332'
git switch 'github-bot/gh-2332'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2332'
git switch 'github-bot/gh-2332'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2332'
git switch 'main'
git merge --squash 'github-bot/gh-2332'
git switch 'main'
git merge --ff-only 'github-bot/gh-2332'
git switch 'main'
git merge 'github-bot/gh-2332'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.