D3D12.X: separate compute driver blobs by static sampler state #1420

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

@⁠venglov on GitHub · 2026-11-24 15:47 UTC · original
venglov:codex/compute-driver-cache-samplers → main · +44 −16 · 3 files · 1 commits · open

Two translated compute pipelines can have identical DXIL and flags while using different static samplers in their root signatures. The disk cache assigned them the same filename, so either pipeline could overwrite or discard the other pipeline’s blob. This is a follow-up to #744.

What is in it

  • Use the ordered static sampler state in the disk cache key in real.rs and the offline precompiler in shaders.rs.
  • Keep the existing filenames for pipelines without static samplers. Add a cache-key regression test and document the behavior in the README.

Tested

  • Apple Silicon, macOS 27.2, Rust 1.100.0. cargo check --workspace --tests --locked --offline --target x86_64-pc-windows-msvc passed with cross-target SDK headers.
  • DXC 1.9 produced byte-identical DXIL for two synthetic compute shaders with different U address modes. The local Rust cache harness passed 6 tests with the fix (0 failed, 0 ignored). With the old key, 4 passed and 2 reproduced the collision.

Regression run

Pending Windows GPU and retail-title runs for main and this PR’s head.

Not tested

  • Native Windows build and full suite, D3D12 driver cache reuse on a GPU, and the retail-title smoke comparison.

AI use

  • Codex (GPT-6) investigated the collision, wrote the patch and regression test, ran the local checks, and drafted this description.
**@⁠venglov** on GitHub · 2026-11-24 15:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420) `venglov:codex/compute-driver-cache-samplers` → `main` · +44 −16 · 3 files · 1 commits · open Two translated compute pipelines can have identical DXIL and flags while using different static samplers in their root signatures. The disk cache assigned them the same filename, so either pipeline could overwrite or discard the other pipeline’s blob. This is a follow-up to #744. **What is in it** - Use the ordered static sampler state in the disk cache key in `real.rs` and the offline precompiler in `shaders.rs`. - Keep the existing filenames for pipelines without static samplers. Add a cache-key regression test and document the behavior in the README. **Tested** - Apple Silicon, macOS 27.2, Rust 1.100.0. `cargo check --workspace --tests --locked --offline --target x86_64-pc-windows-msvc` passed with cross-target SDK headers. - DXC 1.9 produced byte-identical DXIL for two synthetic compute shaders with different U address modes. The local Rust cache harness passed 6 tests with the fix (0 failed, 0 ignored). With the old key, 4 passed and 2 reproduced the collision. **Regression run** Pending Windows GPU and retail-title runs for main and this PR’s head. **Not tested** - Native Windows build and full suite, D3D12 driver cache reuse on a GPU, and the retail-title smoke comparison. **AI use** - Codex (GPT-6) investigated the collision, wrote the patch and regression test, ran the local checks, and drafted this description.
The same DXIL and pipeline flags can be used with different static samplers in the root signature. Key the runtime and offline driver cache by those samplers so the entries can coexist. Synthetic wrap and clamp shaders produced byte-identical DXIL and reproduced the cache collision.

Assisted-by: Codex (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:19 +00:00
Author
Owner

@⁠anes66 on GitHub · 2026-11-24 16:15 UTC · original · edited 2026-11-24 16:44 UTC

Native Windows/MSVC follow-up for 7490d75a17e950aab1ed49c5155543ba5a3be437, merged onto main b7aa9f3bd212088e0d927439284dc5ed325ce3c7.

Tested integration 873dd8e retains your runtime/test changes. Only README needed a merge resolution: both the DRED note and your cache note are kept. Temporary control instrumentation was removed before the final build and suite.

Tested

  • Windows 10 Pro 19045, RTX 3060 12 GB / NVIDIA 32.0.16.2114, Ryzen 7 9800X3D; Rust 1.100.0 MSVC, SDK DXC 1.9.2602.17, Agility 1.620.2, debug.
  • cargo test --locked -p xcl --lib hle::d3d12x::real::driver_cache::tests -- --test-threads=1 --show-output: 5 passed / 0 failed, including identical_dxil_with_different_static_samplers_uses_separate_files.
  • Negative control: temporarily force name() to use the legacy DXIL/length/flags branch even for nonempty samplers, keeping the new signature. The sampler regression fails on the identical filename 5752dfa9a5b8154b-7-0.pso. This is a legacy-key simulation, not a build of unmodified main.
  • Restored your code, then cargo build --locked --workspace -j 4: passed.
  • cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output: 771 passed / 0 failed / 41 ignored, exit 0. The existing cross-process offline compute-cache GPU test passed. Two native-wave64 skips: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. XCL_SAMPLE_* unset; their counted passes are not title coverage.

Not tested: your head on its old base, release, AMD/Intel/native wave64, title smoke, or actual driver-blob reuse/rendered output for two different nonempty sampler states. The new key regression is a unit test; the existing GPU reuse fixture has no static samplers. This supplies the missing native build/suite check, not the required main/head title regression run.

AI use: Codex (GPT-6; exact variant unavailable) integrated the patch, ran the checks and negative control, and prepared this report. Your feature code was not rewritten.

Rebase check: current head 867d307572af1e5ec5c980902d611a1c3df2be2e has identical files to the tested 873dd8e integration except README bullet order. Rust code and tests are unchanged. I compared the trees; I did not rerun the suite on the new commit.

Combined #759 / #1420 native cache check

83ac24b combines the #759 integration/cache/help fixes (ffc40b3) with #1420's rebased 867d307 on main b7aa9f3. The clean merge initially failed E0061: the journal warmer still supplied two arguments to the new three-argument driver_cache::path. It now passes &compiled.samplers.

A new synthetic native-driver regression goes beyond the filename unit test:

  • two console CS containers differ only in static U addressing (wrap/clamp);
  • both cached DXIL files are byte-identical, while the offline compiler writes two distinct driver blobs;
  • each journal replay must report an actual saved-driver-blob hit and preserve both files byte-for-byte.

The focused test journal_warmer_reuses_offline_blobs_for_distinct_static_samplers passed 1 / 0, no skips. A control that supplied an empty sampler slice to the warmer made the code compile but failed its cache-hit assertion. The corrected caller passed. The shared journal encoder is the existing synthetic fixture, factored for reuse.

Full results on the RTX 3060 / Windows 10 / Rust 1.100.0 / DXC 1.9 / Agility 1.620.2 setup:

  • Build passed.
  • cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=1 --show-output: 780 passed / 0 failed / 41 ignored, exit 0, two native-wave64 skips.
  • The same command with --test-threads=4: 777 / 3 / 41, five explicit skips. Failures were list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu, rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang, and timestamps_outside_unified_memory_land_after_the_queue, at queue creation. Additional no-device skips were the console depth-target test, shader-cache-session fallback test and placed-texture test. The cause of these parallel failures is unresolved; this is not a green default-suite claim.

Samples were unset. The new regression compiles pipelines and checks cache loading; it does not dispatch the sampler shaders or compare rendered output. No retail title smoke, Wine, AMD/Intel, native wave64, or real driver update. #1368 is not part of this integration.

AI use: Codex (GPT-6; exact variant unavailable) prepared the integration and fixture, reproduced the API/caller failures, ran validation and wrote this update.

**@⁠anes66** on GitHub · 2026-11-24 16:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420#issuecomment-7137374987) · edited 2026-11-24 16:44 UTC Native Windows/MSVC follow-up for `7490d75a17e950aab1ed49c5155543ba5a3be437`, merged onto main `b7aa9f3bd212088e0d927439284dc5ed325ce3c7`. [Tested integration 873dd8e](https://github.com/anes66/xcl/commit/873dd8e29680df27b92e4fa31480ed7f4674a67e) retains your runtime/test changes. Only README needed a merge resolution: both the DRED note and your cache note are kept. Temporary control instrumentation was removed before the final build and suite. **Tested** - Windows 10 Pro 19045, RTX 3060 12 GB / NVIDIA 32.0.16.2114, Ryzen 7 9800X3D; Rust 1.100.0 MSVC, SDK DXC 1.9.2602.17, Agility 1.620.2, debug. - `cargo test --locked -p xcl --lib hle::d3d12x::real::driver_cache::tests -- --test-threads=1 --show-output`: **5 passed / 0 failed**, including `identical_dxil_with_different_static_samplers_uses_separate_files`. - Negative control: temporarily force `name()` to use the legacy DXIL/length/flags branch even for nonempty samplers, keeping the new signature. The sampler regression fails on the identical filename `5752dfa9a5b8154b-7-0.pso`. This is a legacy-key simulation, not a build of unmodified main. - Restored your code, then `cargo build --locked --workspace -j 4`: passed. - `cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output`: **771 passed / 0 failed / 41 ignored**, exit 0. The existing cross-process offline compute-cache GPU test passed. Two native-wave64 skips: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. `XCL_SAMPLE_*` unset; their counted passes are not title coverage. **Not tested:** your head on its old base, release, AMD/Intel/native wave64, title smoke, or actual driver-blob reuse/rendered output for two different nonempty sampler states. The new key regression is a unit test; the existing GPU reuse fixture has no static samplers. This supplies the missing native build/suite check, not the required main/head title regression run. **AI use:** Codex (GPT-6; exact variant unavailable) integrated the patch, ran the checks and negative control, and prepared this report. Your feature code was not rewritten. Rebase check: current head `867d307572af1e5ec5c980902d611a1c3df2be2e` has identical files to the tested `873dd8e` integration except README bullet order. Rust code and tests are unchanged. I compared the trees; I did not rerun the suite on the new commit. ### Combined #759 / #1420 native cache check [83ac24b](https://github.com/anes66/xcl/commit/83ac24b6489cf1cfc28aa9ef7586d161bdd39090) combines the #759 integration/cache/help fixes (`ffc40b3`) with #1420's rebased `867d307` on main `b7aa9f3`. The clean merge initially failed E0061: the journal warmer still supplied two arguments to the new three-argument `driver_cache::path`. It now passes `&compiled.samplers`. A new synthetic native-driver regression goes beyond the filename unit test: - two console CS containers differ only in static U addressing (wrap/clamp); - both cached DXIL files are byte-identical, while the offline compiler writes two distinct driver blobs; - each journal replay must report an actual saved-driver-blob hit and preserve both files byte-for-byte. The focused test `journal_warmer_reuses_offline_blobs_for_distinct_static_samplers` passed **1 / 0**, no skips. A control that supplied an empty sampler slice to the warmer made the code compile but failed its cache-hit assertion. The corrected caller passed. The shared journal encoder is the existing synthetic fixture, factored for reuse. **Full results on the RTX 3060 / Windows 10 / Rust 1.100.0 / DXC 1.9 / Agility 1.620.2 setup:** - Build passed. - `cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=1 --show-output`: **780 passed / 0 failed / 41 ignored**, exit 0, two native-wave64 skips. - The same command with `--test-threads=4`: **777 / 3 / 41**, five explicit skips. Failures were `list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu`, `rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang`, and `timestamps_outside_unified_memory_land_after_the_queue`, at queue creation. Additional no-device skips were the console depth-target test, shader-cache-session fallback test and placed-texture test. The cause of these parallel failures is unresolved; this is not a green default-suite claim. Samples were unset. The new regression compiles pipelines and checks cache loading; it does not dispatch the sampler shaders or compare rendered output. No retail title smoke, Wine, AMD/Intel, native wave64, or real driver update. #1368 is not part of this integration. AI use: Codex (GPT-6; exact variant unavailable) prepared the integration and fixture, reproduced the API/caller failures, ran validation and wrote this update.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 17:13 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (b7aa9f3) in README.md — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-24 17:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420#issuecomment-7138863559) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`b7aa9f3`) in `README.md` — needs a rebase before it can be tested.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 02:06 UTC · original

Please rebase #1420\ onto current \main\ to clear the \CONFLICTING\ state (e.g. \README.md), update the \Regression run\ section with a matching \xcl-smoke v1\ pair so \PR description\ passes, and obtain an AMD verification pass on the rebased head.

**@⁠raylitebull** on GitHub · 2026-11-25 02:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420#issuecomment-7150319492) Please rebase \#1420\ onto current \main\ to clear the \CONFLICTING\ state (e.g. \README.md\), update the \Regression run\ section with a matching \xcl-smoke v1\ pair so \PR description\ passes, and obtain an **AMD** verification pass on the rebased head.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:29 UTC · original

Regression run of 867d3075 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 867d307572af1e5ec5c980902d611a1c3df2be2e
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14810 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420#issuecomment-7151965228) Regression run of `867d3075` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 867d307572af1e5ec5c980902d611a1c3df2be2e gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1631 (PresentX 1631) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14810 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠voiceovarian1-max on GitHub · 2026-11-25 08:07 UTC · original

Linux + NVIDIA check of 867d307 on a local stack: a second offline pass reuses every pipeline of the first.

Setup: RTX 4070 Ti 12 GB (NVIDIA 620.73.04), i7-14700K, CachyOS kernel 7.3.5, Proton Experimental's Wine (wine-11.0), vkd3d-proton v3.1 + scripts/linux/vkd3d-proton-xcl.patch. Release, x86_64-pc-windows-gnu. Tree: main 9e3831e + #1315/#1316 + #867 + #871 + #877 + #1321 + #684 + #640 + #605 + #495 + this PR's diff (shaders.rs hunk applied by hand: its context had moved).

xcl shaders shaders.rpf --precompile --pipelines --only cs, restricted by a local name filter to the retail pack's records whose name holds cloth_ (9 compute pipelines), 6 pipeline threads, vkd3d-proton's and NVIDIA's own caches off so that only XCL's blobs can make a second pass fast:

pass time pipelines of 1 s or more
first 52.1 s 9 (6 of them 30–40 s)
second 3.4 s 2 (none over 10 s)

After the first pass 6 of the 9 files carry the sampler suffix (<hash>-<len>-<flags>-<sampler hash>.pso); the other 3 have no static samplers and keep the old name.

I have no clean before/after of the collision itself on this tree: the title's refusals I saw at the time turned out to be the node mask (#1368).

Not tested: the PR's head as a whole, its unit tests, Windows, AMD.

AI use: Claude Code (Claude Fable 5.2) ran the runs and wrote this report; posted with the account owner's approval.

**@⁠voiceovarian1-max** on GitHub · 2026-11-25 08:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420#issuecomment-7156633601) **Linux + NVIDIA check of `867d307` on a local stack: a second offline pass reuses every pipeline of the first.** **Setup:** RTX 4070 Ti 12 GB (NVIDIA 620.73.04), i7-14700K, CachyOS kernel 7.3.5, Proton Experimental's Wine (wine-11.0), vkd3d-proton v3.1 + `scripts/linux/vkd3d-proton-xcl.patch`. Release, `x86_64-pc-windows-gnu`. Tree: `main` `9e3831e` + #1315/#1316 + #867 + #871 + #877 + #1321 + #684 + #640 + #605 + #495 + this PR's diff (`shaders.rs` hunk applied by hand: its context had moved). `xcl shaders shaders.rpf --precompile --pipelines --only cs`, restricted by a local name filter to the retail pack's records whose name holds `cloth_` (9 compute pipelines), 6 pipeline threads, vkd3d-proton's and NVIDIA's own caches off so that only XCL's blobs can make a second pass fast: | pass | time | pipelines of 1 s or more | |---|---|---| | first | 52.1 s | 9 (6 of them 30–40 s) | | second | 3.4 s | 2 (none over 10 s) | After the first pass 6 of the 9 files carry the sampler suffix (`<hash>-<len>-<flags>-<sampler hash>.pso`); the other 3 have no static samplers and keep the old name. I have no clean before/after of the collision itself on this tree: the title's refusals I saw at the time turned out to be the node mask (#1368). **Not tested:** the PR's head as a whole, its unit tests, Windows, AMD. **AI use:** Claude Code (Claude Fable 5.2) ran the runs and wrote this report; posted with the account owner's approval.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 00:26 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 00:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1420#issuecomment-7178762513) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • README.md
  • crates/xcl/src/hle/d3d12x/real.rs
  • crates/xcl/src/shaders.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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