Skip to content

Shaders: cache refused shaders and DXC failures by capability (#1412) - #1472

Open
KarolKurzyna wants to merge 1 commit into
xcl-dev:mainfrom
KarolKurzyna:shaders/negative-cache-capability-markers
Open

KarolKurzyna wants to merge 1 commit into
xcl-dev:mainfrom
KarolKurzyna:shaders/negative-cache-capability-markers

Conversation

@KarolKurzyna

@KarolKurzyna KarolKurzyna commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #1412.

What is in it

  • Caches deterministic DXC compilation failures (dxc: ...) in <key>.fail markers alongside <key>.dxil (crates/xcl/src/gpu/recomp/dxc.rs), storing the formatted failure text and a capability digest (XCLFAIL1, package version, XCL_TRANSLATOR_SOURCE_ID, and toolchain_identity()).
    • Subsequent hits replay the exact formatted error into CacheCounters::cached_failure (CacheStats::cached_failures) without incrementing compilations or compilation_failures or triggering CACHED_ONLY deferrals.
    • Transient DXC errors (Compile: ..., DXC: ..., missing DLL, invalid container) are never negative-cached.
  • Caches upstream translator refusals and deterministic DXC refusals in <stem>.fail (XCLTRNF1 + ident, capability digest over ident/stage/sampler_base/windows/split, blob size and hash2) inside translated (crates/xcl/src/gpu/recomp/pso.rs), short-circuiting before re-lowering on subsequent runs while skipping cached_only deferrals (has_missed()) and transient DXC errors.
  • Skips negative markers and deletes any matching .fail file on disk whenever capability-changing or debug env overrides are active (XCL_SAFE_BARRIER, XCL_SPLIT_WAVE64, XCL_WAVE64_SPIN, XCL_NEGATIVE_CACHE, XCL_RECOMP_*, XCL_DEBUG_*), and deletes stale or mismatched markers when a capability digest drifts or a shader later succeeds.
  • Rebased onto main (9039900, PR gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 Direct DXIL + PR Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WINDOWS) #1693): translated::identity() stays wired through identity_with(..., Backend::current(), crate::gpu::dxil::kernel::TRANSLATOR_VERSION), isolating Direct DXIL refusal markers from HLSL ones and invalidating them on TRANSLATOR_VERSION bumps.

Tested

  • Machine / toolchain: Windows 11 26H2 (26300.9974), Intel Core i5-14600K, NVIDIA GeForce RTX 3070 Ti (8192 MiB, driver 621.24 / 32.0.16.2124, SM 6.6, wave32), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), dxcompiler 1.9.2602.17 (21d28f72) / dxil 1.9.2602.17 (Windows SDK 10.0.26100.0).
  • Full workspace test suite (.\scripts\test.ps1) on commit e96f5163ee1e4d6f34bb84bc255c002e334a3bb8: 864 passed, 0 failed, 42 ignored across 20 workspace/integration test runs (unittests src\lib.rs: 815 passed, 0 failed, 22 ignored; GPU tests skipped on this adapter: 2 (no wave64), 1 (no heap windows); zero warnings in modified files), including:
    • gpu::recomp::dxc::cache_tests::dxc_deterministic_failures_are_cached_and_replayed (passed; checks zero DXC calls, flat compilations/compilation_failures, cached_failures == 1, exact compilation_errors string, and cached_only non-deferral)
    • gpu::recomp::dxc::cache_tests::dxc_negative_marker_invalidates_on_capability_change_and_env_override (passed)
    • gpu::recomp::dxc::cache_tests::dxc_transient_failures_are_not_negative_cached (passed)
    • gpu::recomp::pso::shader_cache_tests::translated_refusals_are_cached_and_invalidated_by_capability_digest (passed; checks zero re-lowering on hit, Direct DXIL Backend / TRANSLATOR_VERSION separation, and single-entry invalidation while leaving unrelated markers intact)
    • gpu::recomp::pso::shader_cache_tests::translated_negative_markers_skip_and_delete_under_env_overrides (passed)
    • gpu::recomp::pso::shader_cache_tests::translated_deferred_and_transient_errors_are_not_negative_cached (passed)
    • gpu::recomp::pso::shader_cache_tests::direct_dxil_identity_never_collides_with_hlsl & direct_and_hlsl_disk_entries_are_separate (passed)
  • Release build (cargo build --release -p xcl) succeeded cleanly after commit e96f5163ee1e4d6f34bb84bc255c002e334a3bb8 with zero warnings in modified files.

Regression run

Baseline (main, warm DXIL/driver cache):

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3070 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14606 MB

This branch (e96f5163ee1e4d6f34bb84bc255c002e334a3bb8, warm DXIL/driver cache):

xcl-smoke v1
commit: e96f5163ee1e4d6f34bb84bc255c002e334a3bb8
gpu: NVIDIA GeForce RTX 3070 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14522 MB

Not tested

  • AMD or Intel GPUs, Linux / Wine, wave64 hardware paths (gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware skipped on this adapter: no wave64), heap-window fallback path (heap_window_out_of_memory_falls_back_to_the_switch_form skipped: no heap windows), and XCL_SAMPLE_* sample-asset tests (not set locally).
  • Multi-boot story-load retail runs reaching live refused programs: the 60 s default smoke window did not encounter translation or DXC refusals (0 failures logged), so two-run refusal replay and capability invalidation are verified by the unit tests above rather than live retail story-loading refusals.

AI use

Implemented, tested, and drafted with Google Antigravity (Gemini 4 Neon); all unit tests, workspace tests, release build, and xcl-smoke runs were executed locally on the hardware listed above.

@pickles976

Copy link
Copy Markdown

Reviewed the diff — this implements #1412's acceptance faithfully, and two choices go beyond the letter of it in the right direction: the master kill switch inside the override list (XCL_NEGATIVE_CACHE presence ⇒ markers off, so the feature is testable in both directions without a rebuild) and the determinism gate (dxc:-prefixed failures only — correctly excludes driver-side rejections, which are capability-dependent and would poison exactly like the class we were trying to avoid). XCLFAIL1/XCLTRNF1 magic + reason-length bound + digest-in-header with miss-then-overwrite recovery is the right file shape; reason replay keeps log-tail comparability.

One edge worth a documented limitation (or a follow-up line in the digest), because negative entries poison asymmetrically where positive entries merely serve a stale variant: the capability digest folds translator-source-id + toolchain + extra flags, but not the device-derived wave decision — split_wave64 comes from the device wave range at PSO time, and laptops with iGPU+dGPU (or users swapping adapters) share one cache directory. Run on the wave64-capable adapter ⇒ a shader refusals-free… precisely: a shader whose refusal depends on the non-split path gets a marker; the same cache on the 32-lane adapter, where the split lowering would translate it fine, is now permanently refused — wrong-in-a-way-the-positive-cache never was (positive staleness costs perf, negative staleness costs content). The positive cache's single-device assumption is pre-existing, so this is not a merge blocker — but either fold a device-capability bit (split-vs-native wave64 is enough; full LUID would overfit to docks/eGPU churn) into both digests, or state the single-adapter-per-cache assumption in the module docs and in the #1412 close note so the next iGPU-laptop "why is everything magenta-refused" report is a grep instead of a mystery.

@KarolKurzyna

Copy link
Copy Markdown
Author

@pickles976 Thanks for the quick review!

One helpful detail already in the diff: in pso.rs, translated::fail_file and translated::capability_digest already include split (split_wave64) alongside ident, stage, sampler_base, and windows (both in the filename ..._{split as u8}.fail and in the XCLTRNF1 capability digest), so a wave64-native adapter and a split-wave64 adapter sharing one cache directory will not poison each other's translator refusal markers.

In dxc.rs, <key>.fail is keyed on the full emitted HLSL src (plus entry, profile, toolchain_identity(), and XCL_TRANSLATOR_SOURCE_ID), so wave-dependent lowering differences already produce different HLSL and separate <key>.fail entries; I agree the single-adapter-per-cache assumption still applies if two adapters somehow produce identical HLSL or share graphics wave knobs, and I am happy to add a short module doc note (or fold a wave-mode bit into dxc.rs as well) if you want that before merge.

@nnonno91

Copy link
Copy Markdown

Independent Windows/AMD test of a56a7c7aeb694ff9645d2f923430c731ded3da7f for #1412.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62), Rust 1.100.0 x86_64-pc-windows-msvc, debug builds. The workspace suite used DXC 1.8.2502.11.
  • cargo build --workspace --locked passed. cargo test --locked -p xcl --lib cache_tests -- --test-threads=4 passed all 27 tests. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output had 776 passed, 0 failed, 41 ignored, and no SKIPPED messages. The bundled test title passed.
  • A temporary integration test called dxc::compile_cached with float4 main() : SV_Target { return xcl_undefined_value; } (main, ps_6_6). Each invocation of cargo test --locked -p xcl --test dxc_refusal_probe -- --exact real_dxc_refusal_probe --nocapture --test-threads=1 started a fresh process. All five passed using a single initially empty XCL_DXIL_CACHE directory.
Run DXC calls Cached failures .fail files after run
DXC 1.8.2502.11, empty cache 1 0 1
DXC 1.8.2502.11, same input 0 1 1
DXC 1.9.2609.5, same input 1 0 2
DXC 1.8.2502.11, XCL_NEGATIVE_CACHE=0 1 0 1
DXC 1.8.2502.11, override unset 1 0 2

The cold and warm 1.8 runs returned identical error text. The override removed the 1.8 marker, and the next run with the override unset recreated it.

Not tested

Retail-title smoke runs, startup performance, and cross-process replay of translator refusals. The five-process probe exercised the DXC path.

AI use

OpenAI Codex (GPT-6 family, exact variant unavailable) wrote and ran the temporary probe and drafted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@KarolKurzyna
KarolKurzyna force-pushed the shaders/negative-cache-capability-markers branch from a56a7c7 to e96f516 Compare November 24, 2026 19:52
@KarolKurzyna

Copy link
Copy Markdown
Author

Rebased onto main (9039900, #1426 Direct DXIL + #1693) — new head is e96f516.

@DavidM1911 Thank you for verifying on RTX 3060 Ti!

Direct DXIL interop on e96f516

  • Preserved gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's translated::identity_with(..., Backend::current(), crate::gpu::dxil::kernel::TRANSLATOR_VERSION) inside translated::identity() (crates/xcl/src/gpu/recomp/pso.rs), so XCL_DIRECT_DXIL refusal markers stay isolated from HLSL entries and invalidate whenever TRANSLATOR_VERSION bumps.
  • Added Direct DXIL Backend / TRANSLATOR_VERSION isolation assertions to translated_refusals_are_cached_and_invalidated_by_capability_digest.

Re-verified on e96f516 (RTX 3070 Ti, DXC 1.9.2602.17)

  • .\scripts\test.ps1: 864 passed, 0 failed, 42 ignored across 20 runs (unittests src\lib.rs: 815 passed, 0 failed, 22 ignored; GPU tests skipped on this adapter: 2 (no wave64), 1 (no heap windows)).
  • Release build (cargo build --release -p xcl) + 60 s scripts/smoke.ps1: exit: 0x0, 1630 frames (PresentX 1630), 60 60 60, 0 device removals/crashes, 14522 MB peak commit.

@speed-y

speed-y commented Nov 24, 2026

Copy link
Copy Markdown

Independent Windows/NVIDIA verification of head e96f516 (A18 / #1412).

Tested

  • RTX 5080 (driver 621.24), Windows 10.0.26200, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); unit tests debug, smoke release.
  • Negative-cache unit tests (8): all passed (dxc_deterministic_failures_are_cached_and_replayed, dxc_negative_marker_invalidates_on_capability_change_and_env_override, dxc_transient_failures_are_not_negative_cached, translated_refusals_are_cached_and_invalidated_by_capability_digest, translated_negative_markers_skip_and_delete_under_env_overrides, translated_deferred_and_transient_errors_are_not_negative_cached, direct_dxil_identity_never_collides_with_hlsl, direct_and_hlsl_disk_entries_are_separate).
  • .\scripts\test.ps1: 864 passed, 0 failed, 42 ignored; SKIPPED GPU: 2 (no wave64), 1 (no heap windows).

Regression run (warm not required; single 60 s smoke of this head)

xcl-smoke v1
commit: e96f5163ee1e4d6f34bb84bc255c002e334a3bb8
gpu: NVIDIA GeForce RTX 5080
title: GTAVI.exe
seconds: 60
exit: 0x0
frames shown: 1577 (PresentX 1577)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15631 MB

Not tested

AI use

  • Cursor (Composer): fetched the branch, ran the tests and smoke, drafted this report.

…v#1412)

Deterministic DXC failures and upstream translator refusals are
currently re-run from scratch on every boot, even though `report.json`
logs the exact same refusal set across launches.

Add capability-keyed negative cache markers across both layers without
poisoning caches across recompiler/DXC fixes or debug overrides:

- `dxc.rs`: write `<key>.fail` (`XCLFAIL1` + capability digest of version,
  `XCL_TRANSLATOR_SOURCE_ID`, and DXC toolchain) only on deterministic
  DXC refusals (`"dxc: ..."`), replay exact error strings via
  `CacheCounters::cached_failure` (`cached_failures`), and skip DXC and
  `CACHED_ONLY` deferrals on hit without bumping `compilations`.
- `pso.rs`: write `<stem>.fail` (`XCLTRNF1` + `ident`, capability digest
  covering stage/sampler_base/windows/split, blob len + hash2) in
  `translated` for deterministic upstream translator and DXC refusals,
  skipping transient errors and `cached_only` deferrals.
- Skip and delete stale/mismatched markers whenever capability-changing
  or debug env overrides are active (`XCL_SAFE_BARRIER`, `XCL_SPLIT_WAVE64`,
  `XCL_WAVE64_SPIN`, `XCL_NEGATIVE_CACHE`, `XCL_RECOMP_*`, `XCL_DEBUG_*`).

Fixes xcl-dev#1412.

Assisted-by: Google Antigravity (Gemini 4 Neon)
@KarolKurzyna
KarolKurzyna force-pushed the shaders/negative-cache-capability-markers branch from b970224 to 899c509 Compare November 25, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache refused programs and failed compiles — boot pays for the same refusals every run; markers must be capability-keyed

6 participants