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

Open
storrmzz wants to merge 1 commit from upstream-pr/2332 into main
storrmzz commented 2026-11-25 14:57:33 +00:00 (Migrated from github.com)

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

  • Borrow inputs until duplicate and overflow-safe capacity checks pass. Duplicate detection, capacity accounting and insertion run under the same store lock; no replacement/shrinking path remains.
  • Regression tests for oversized new entries, exact capacity, duplicate values and duplicates in a full fallback store; README behavior updated.
  • The previous early size rejection now follows duplicate detection, matching the native measurements below. Scope remains capacity guarding, not cache session lifetime or eviction policy.

Tested

  • Windows 11 Pro build 26300, AMD Radeon 780M driver 32.0.31033.3, Ryzen 7 8840HS, Rust 1.100.0 MSVC, debug builds.
  • PR 225c039ab26c025944091419dafc900a02b33cc9, unchanged main 53e85fb124eae624641e9884517e4f3c4a7d8794.
  • 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.
  • Red check: the corrected four capacity tests on prior head b2f681a157028116009dfcc4ef94671c80a960f4 produced 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_form
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1
  • hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline
  • two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs

Native 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 returned 0x887a0036. With DISK filled until another 1 MiB entry returned 0x887a0034, the same-sized duplicate still returned 0x887a0036; the original bytes remained readable. A new oversized key returned 0x887a0034. 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. Their insert edits 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_session command: 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
  • gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
  • gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
  • gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
  • gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
  • gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
  • gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
  • heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)
  • shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): Die Anwendung hat einen Vorgang angefordert, der von einer nicht vorhandenen oder nicht übereinstimmenden SDK-Komponente abhängig ist. (0x887A002D)
  • the title under the debug layer (dred: false): no d3d12SDKLayers.dll
  • the title under the debug layer (dred: true): no d3d12SDKLayers.dll
  • uploads_start_from_each_subresources_state: no D3D12 debug layer (Die Anwendung hat einen Vorgang angefordert, der von einer nicht vorhandenen oder nicht übereinstimmenden SDK-Komponente abhängig ist. (0x887A002D))

Regression run
Not run: no owned, runnable retail title is available. This PR remains a draft; no xcl-smoke blocks are fabricated.

Not tested

  • Retail-title startup, rendered frames, performance or memory-use improvements; no retail compatibility or FPS claim.
  • NVIDIA, Wine/vkd3d-proton, or a full integration suite with #2878.
  • Broader native argument-validation parity: native rejects zero-length values; the fallback's existing zero-length acceptance is outside this capacity fix and remains unchanged. An explicit 1 KiB native MEMORY descriptor was rejected with E_INVALIDARG; native measurements above used valid 32 MiB descriptors.

AI use
Created with AI assistance from OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ivall/xcl:issue:5493772214 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332). Originally posted by [storrmzz](https://github.com/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](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7258940600): existing keys return `DXGI_ERROR_ALREADY_EXISTS`, without replacing their values or changing capacity accounting. **What is in it** - Borrow inputs until duplicate and overflow-safe capacity checks pass. Duplicate detection, capacity accounting and insertion run under the same store lock; no replacement/shrinking path remains. - Regression tests for oversized new entries, exact capacity, duplicate values and duplicates in a full fallback store; README behavior updated. - The previous early size rejection now follows duplicate detection, matching the native measurements below. Scope remains capacity guarding, not cache session lifetime or eviction policy. **Tested** - Windows 11 Pro build 26300, AMD Radeon 780M driver 32.0.31033.3, Ryzen 7 8840HS, Rust 1.100.0 MSVC, debug builds. - PR `225c039ab26c025944091419dafc900a02b33cc9`, unchanged main `53e85fb124eae624641e9884517e4f3c4a7d8794`. - `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. - Red check: the corrected four capacity tests on prior head `b2f681a157028116009dfcc4ef94671c80a960f4` produced 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_form` - `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` - `hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline` - `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` Native 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 returned `0x887a0036`. With DISK filled until another 1 MiB entry returned `0x887a0034`, the same-sized duplicate still returned `0x887a0036`; the original bytes remained readable. A new oversized key returned `0x887a0034`. This agrees with the [Microsoft StoreValue contract](https://microsoft.github.io/DirectX-Specs/d3d/ShaderCache.html#id3d12shadercachesession). 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. Their `insert` edits 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_session` command: **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. <details> <summary>Explicit SKIPPED messages from the paired full runs</summary> - gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)) - gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)) - gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)) - gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)) - gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)) - gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)) - heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows - hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1) - shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): Die Anwendung hat einen Vorgang angefordert, der von einer nicht vorhandenen oder nicht übereinstimmenden SDK-Komponente abhängig ist. (0x887A002D) - the title under the debug layer (dred: false): no d3d12SDKLayers.dll - the title under the debug layer (dred: true): no d3d12SDKLayers.dll - uploads_start_from_each_subresources_state: no D3D12 debug layer (Die Anwendung hat einen Vorgang angefordert, der von einer nicht vorhandenen oder nicht übereinstimmenden SDK-Komponente abhängig ist. (0x887A002D)) </details> **Regression run** Not run: no owned, runnable retail title is available. This PR remains a draft; no `xcl-smoke` blocks are fabricated. **Not tested** - Retail-title startup, rendered frames, performance or memory-use improvements; no retail compatibility or FPS claim. - NVIDIA, Wine/vkd3d-proton, or a full integration suite with #2878. - Broader native argument-validation parity: native rejects zero-length values; the fallback's existing zero-length acceptance is outside this capacity fix and remains unchanged. An explicit 1 KiB native MEMORY descriptor was rejected with `E_INVALIDARG`; native measurements above used valid 32 MiB descriptors. **AI use** Created with AI assistance from OpenAI Codex (GPT-6).
SlopTart commented 2026-11-25 16:12:13 +00:00 (Migrated from github.com)

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 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.

<!-- greyfinch-sync:ivall/xcl:comment:7166961238 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7166961238). Originally posted by [SlopTart](https://github.com/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 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.
luckyteagirl commented 2026-11-25 16:12:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T15:35:23Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7167075742 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7167075742). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T15:35:23Z. --- 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.
DavidM1911 commented 2026-11-25 18:04:50 +00:00 (Migrated from github.com)

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!

<!-- greyfinch-sync:ivall/xcl:comment:7170406259 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7170406259). Originally posted by [DavidM1911](https://github.com/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!
Prime1997 commented 2026-11-26 13:30:14 +00:00 (Migrated from github.com)

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 main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, tree 2c318f747df7b6edd4d82517db51991d57374d37; 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_entry
  • hle::d3d12x::shader_cache_session::tests::cache_capacity_accepts_exact_limit_and_rejects_another_key
  • hle::d3d12x::shader_cache_session::tests::cache_capacity_failed_replacement_preserves_the_previous_value
  • hle::d3d12x::shader_cache_session::tests::cache_capacity_accounts_for_replacements_in_a_full_store

Build: 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.

<!-- greyfinch-sync:ivall/xcl:review:6074976737 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332#pullrequestreview-6074976737). Originally posted by [Prime1997](https://github.com/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 main `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`, tree `2c318f747df7b6edd4d82517db51991d57374d37`; 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_entry` - `hle::d3d12x::shader_cache_session::tests::cache_capacity_accepts_exact_limit_and_rejects_another_key` - `hle::d3d12x::shader_cache_session::tests::cache_capacity_failed_replacement_preserves_the_previous_value` - `hle::d3d12x::shader_cache_session::tests::cache_capacity_accounts_for_replacements_in_a_full_store` Build: `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](https://discord.gg/gK3y7WRRY) for coordinating contributor work, testing and comparing results.
andrewDoing commented 2026-11-29 16:29:11 +00:00 (Migrated from github.com)

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 StoreValue succeeded. A second store of the same key with different bytes returned DXGI_ERROR_ALREADY_EXISTS (0x887a0036) both through the original session and through its peer. The peer then read back the original byte. This matches the documented StoreValue contract. Microsoft's D3D12 shader-cache spec

On 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.

<!-- greyfinch-sync:ivall/xcl:comment:7258940600 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7258940600). Originally posted by [andrewDoing](https://github.com/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 `StoreValue` succeeded. A second store of the same key with different bytes returned `DXGI_ERROR_ALREADY_EXISTS` (`0x887a0036`) both through the original session and through its peer. The peer then read back the original byte. This matches the documented `StoreValue` contract. [Microsoft's D3D12 shader-cache spec](https://microsoft.github.io/DirectX-Specs/d3d/ShaderCache.html#id3d12shadercachesession) On 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.
Foniass commented 2026-12-01 07:51:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:51:00Z.


Triage (#1607) – head 225c039

#2878 also changes Store::insert in 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.

<!-- greyfinch-sync:ivall/xcl:comment:7304557610 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2332#issuecomment-7304557610). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:51:00Z. --- **Triage (#1607)** – head 225c039 #2878 also changes `Store::insert` in 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2332:upstream-pr/2332'
git switch 'upstream-pr/2332'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2332'
git switch 'upstream-pr/2332'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2332'
git switch 'upstream-pr/2332'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2332'
git switch 'main'
git merge --squash 'upstream-pr/2332'
git switch 'main'
git merge --ff-only 'upstream-pr/2332'
git switch 'main'
git merge 'upstream-pr/2332'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2322
No description provided.