Skip to content

Shaders: cache translator refusals and DXC compile failures by capability - #1474

Open
AlpPesen wants to merge 1 commit into
xcl-dev:mainfrom
AlpPesen:perf/cache-shader-refusals
Open

AlpPesen wants to merge 1 commit into
xcl-dev:mainfrom
AlpPesen:perf/cache-shader-refusals

Conversation

@AlpPesen

@AlpPesen AlpPesen commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1412.

Repeated boots re-attempt the same deterministic translator refusals and DXC compile errors on every run because only successful .dxil / translated blobs are persisted on disk.

What is in it

  • Persist capability-keyed negative cache markers (.err) for deterministic translator refusals in crates/xcl/src/gpu/recomp/pso.rs (translated::cached_in and translated::cached_rerouted, keyed by capability/source/rerouted identity so any translator, DXC, wave-mode, or direct-DXIL update invalidates them).
  • Persist deterministic DXC compile errors (: dxc: ) in crates/xcl/src/gpu/recomp/dxc.rs while keeping transient failures (OOM 0x8007000E, missing/old dxcompiler.dll, cached_only deferrals, invalid DXIL containers) uncached and retryable.
  • Add unit tests in pso.rs and dxc.rs covering capability invalidation, cached_only deferral isolation, and transient vs deterministic DXC error handling.

Tested

  • Hardware: Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, RDNA2, driver 32.0.21045.29003), Windows 11 Pro build 26300, rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib gpu::recomp::pso: 21 passed, 0 failed, 1 ignored, 0 skipped.
  • cargo test -p xcl --lib gpu::recomp::dxc: 16 passed, 0 failed, 0 ignored, 0 skipped.
  • Previously verified across RTX 5070 Ti, RTX 5070 Laptop, RTX 3070, RTX 3060 Ti, and RDNA2 iGPU before rebasing onto 426a5a7.

Not tested

  • Linux/Wine or NVIDIA GPUs after rebase onto 426a5a7.

Regression run

xcl-smoke v1
commit: 426a5a745db4d5e4b037449ede0b70cb342f5192
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1492 (PresentX 1492)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14971 MB
xcl-smoke v1
commit: 7f97ba3369a56f12c5344f0d9c85fda8629f1fbf
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1500 (PresentX 1500)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15006 MB

AI use

  • Antigravity (Gemini 4 Neon): implemented the capability-keyed negative cache and unit tests, addressed review feedback on transient DXC errors, rebased onto 426a5a7 (including cached_rerouted), ran the tests and paired scripts/smoke.ps1 runs, and drafted this PR description.

@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 451ae68 (on its base b7aa9f3). Passes on both GPUs.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4, run alone: 772 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • An earlier run, done while another suite was using the machine, failed only fine_timer_makes_short_sleeps_short (Sleep(1) took 6.71 ms), a timing check this PR doesn't touch. It passed when run alone.
  • The new tests ran and passed on both GPUs: dxc_compile_failure_is_cached_and_skips_recompilation, translated_cache_caches_refusals_by_capability_identity.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon): 772 passed, 0 failed, 41 ignored, nothing skipped.

Note

Not tested

  • A release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@GonZiin GonZiin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translated-shader cache can persist a transient DXC error and prevent a retry. The lower DXIL cache excludes a failed compiler invocation such as Compile: … (0x8007000E). The outer translated::cached_in receives the formatted error, treats it as cacheable and writes an .err marker. The next call for that shader returns the saved error before calling the translator or compiler.

Tested

  • Windows 11 Pro build 26300, Ryzen 7 7800X3D, Rust 1.100.0 MSVC, debug. I ran cargo test -p xcl --lib review_a_transient_dxc_error_allows_retry -- --nocapture with one temporary probe appended to pso.rs in an isolated checkout. The probe injects the formatted DXC out-of-memory error on the first call and supplies a successful compile result on the second.
  • Base b7aa9f3bd212088e0d927439284dc5ed325ce3c7 retried once and returned the successful result. Head 451ae68ed5e1493b663a65064cb4b6976efdd097 returned the original error with zero retry calls.

The outer cache should persist deterministic translator refusals and let the lower cache handle compiler errors, or carry retryability through the result type. This would keep transient or invalid-output errors retryable even after the outer cache sees them.

Not tested

Real system memory exhaustion, GPU behavior and retail titles. The probe injected the error at the translated-cache boundary.

AI use

Codex (gpt-6.2-sol) reviewed the error path, wrote and ran the probe, and drafted this review.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Duplicate note: #1472 (opened two minutes earlier) also fixes #1412, in the same two files (dxc.rs, pso.rs). It has a review and an AMD Windows test on its head (a56a7c7). The two use different on-disk markers: .err with XCLDXCE1 there, .fail with XCLFAIL1 here. A cache directory would then hold one or the other depending on which lands, so it is worth choosing before either merges. Comparison only: I haven't run either.

AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this.

@AlpPesen

Copy link
Copy Markdown
Contributor Author

Thanks @GonZiin for the catch! Updated ranslated::is_cacheable_error in 3db920c so errors formatted by the lower DXIL cache (DXIL cache ...) are only cached when DXC itself deterministically rejected the HLSL (: dxc: ), keeping transient failures like Compile: ... (0x8007000E) or invalid-container outputs retryable. Added unit test coverage for both cases in ranslated_cache_caches_refusals_by_capability_identity and reran scripts/smoke.ps1 on 3db920c.

@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!

@kais7654

Copy link
Copy Markdown

Ran on the PR's head (3db920c): RTX 5070 Laptop (Blackwell, driver 616.87),
Windows 11 26H2, rustc 1.100.0.

cargo build --workspace: ok
cargo test -p xcl --lib gpu::recomp: 191 passed, 0 failed, 18 ignored
(includes shader_cache_retries_failed_and_deferred_compiles and the dxc cache
statistics tests)

One design question: every raw error from compile() that starts with "dxc: " is
treated as deterministic and cached for the toolchain identity's lifetime. Are
all "dxc: " failures really deterministic? An out-of-memory inside DXC
mid-compile would produce the same prefix and then be cached until the DXC
version changes, so a transient failure would never be retried. Does something
exclude those (or should only defined refusal classes be cached)?

Not tested: the runtime effect across repeated boots (no retail pack here),
and no Windows-path check of the .err invalidation on a DXC upgrade.
AI use: my local Mistral Vibe agent fetched the branch, ran the build/tests
above and drafted this comment; I checked the diff.

kacper-serewis pushed a commit to kacper-serewis/xcl that referenced this pull request Nov 24, 2026
…lity

Adapt Alp Pesen's xcl-dev#1474 to staging 7209e87.
Preserve direct backend and adapter identities. Carry typed failures across
translation, compilation and caching. Persist only deterministic refusals.
Ignore legacy rejection markers. Bypass caches for shader diagnostic overrides.

Original-commit: 3db920c
Assisted-by: Antigravity (Gemini 4 Neon)
Assisted-by: Codex (gpt-6.2-astra)
@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Test report at the current head 3db920c: RTX 3070 (Ampere, driver 616.56), Windows 11, debug.

  • cargo test -p xcl --lib -- --test-threads=4: 723 passed, 1 failed, 21 ignored. The failure is hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime (no samples played within its fixed wait while the machine was loaded). This PR doesn't touch XAudio2; Tests: the XAudio2 voice tests wait 30 s for playback and skip a slow audio device (#1487) #1600 gives those voice tests a longer wait.
  • XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram: 98 passed, 0 failed.

(This PR is in duplicate group D7 with #1472 in #1607.)

AI-assisted (Claude Code). Synthetic tests only.

@AlpPesen
AlpPesen force-pushed the perf/cache-shader-refusals branch from 3db920c to ad4fbe5 Compare November 25, 2026 11:07
…lity

Persist deterministic negative cache markers (.err) alongside positive shader cache entries so repeated boots do not re-lower refused programs or re-invoke DXC on deterministically failing HLSL:

- dxc.rs: cache deterministic DXC compiler rejections (raw error starting with 'dxc: ') in {key:016x}.err (keyed by crate version, DXC toolchain identity, profile, entry, and HLSL source). Subsequent runs return the identical error text with zero DXC invocations. Transient/missing-DLL errors and cached_only deferrals are never cached.
- pso.rs: cache translator refusals and compile errors in translated/v2/{ident:016x}/...err (keyed by XCL_TRANSLATOR_SOURCE_ID, DXC toolchain identity, blob hashes/length, stage, sampler_base, windows, and split_wave64). Updating translator sources, DXC DLLs, or wave mode automatically invalidates prior markers; debug/capability env overrides bypass the cache via cache_allowed.

Fixes xcl-dev#1412.

Assisted-by: Antigravity (Gemini 4 Neon)
@AlpPesen
AlpPesen force-pushed the perf/cache-shader-refusals branch from ad4fbe5 to 7f97ba3 Compare November 25, 2026 11:34
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

7 participants