Skip to content

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

Open
venglov wants to merge 1 commit into
xcl-dev:mainfrom
venglov:codex/compute-driver-cache-samplers
Open

venglov wants to merge 1 commit into
xcl-dev:mainfrom
venglov:codex/compute-driver-cache-samplers

Conversation

@venglov

@venglov venglov commented Nov 24, 2026

Copy link
Copy Markdown

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.

@anes66

anes66 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…in-place vtables

Integrates 16 upstream PRs (ivall#1380, ivall#1383, ivall#1384, ivall#1395, ivall#1398, ivall#1400,
ivall#1404, ivall#1405, ivall#1419, ivall#1420, ivall#1421, ivall#1423, ivall#1424, ivall#1427, ivall#1428, ivall#1429)
on top of the Linux/Proton fork, plus three Proton/vkd3d-proton fixes
caught during verification:
- Recompiler (ivall#1428): flatten IO_GROUP_LIMIT early-return in compute
  shaders so vkd3d-proton v3.1 dxil-spirv accepts the emitted CFG.
- D3D12.X (ivall#1395 + ivall#867): skip UnadoptGuard on in-place-patched vtables
  and restore native vtables in runner::submit_list when a prior test
  adopted the singleton ID3D12Device.
- Tests: match Wine centered default in window_position_modes.

Verified under GE-Proton11-14 (RX 9060 XT / RADV):
- gpu_sparse_vram_descriptors_buffers_and_xmem + gpu_valu_float_and_int
  + window_position_modes: 3 passed, 0 failed
- Broad sweep (present, real, sparse, clamp, dstorage, gpu_valu,
  gpu_typed_buffer): 82 passed, 0 failed, 1 ignored, 0 skipped
- 2.5 min retail title run (XCL_MEM_LIMIT=12G): 3,000+ frames at 30.0
  fps, 6.0-6.1 GB flat committed RAM, 6.4 GB local VRAM, 0 DS failures.
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)
@venglov
venglov force-pushed the codex/compute-driver-cache-samplers branch from 7490d75 to 867d307 Compare November 24, 2026 16:23
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@venglov
venglov marked this pull request as ready for review November 24, 2026 18:18
@raylitebull

Copy link
Copy Markdown
Member

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.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants