Skip to content

Recompiler: an enormous program's HLSL fallback follows the direct translator in the translated cache - #3230

Closed
CharlyRien wants to merge 1 commit into
xcl-dev:mainfrom
CharlyRien:pr/enormous-fallback-retry
Closed

CharlyRien wants to merge 1 commit into
xcl-dev:mainfrom
CharlyRien:pr/enormous-fallback-retry

Conversation

@CharlyRien

@CharlyRien CharlyRien commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Update: #3243 (merged on main after this PR's base 7db2f39) makes direct DXIL the default. With it, the enormous-program route is skipped and the cache identity already follows the direct translator, so the trap described here remains only with XCL_DIRECT_DXIL=0. This PR has not been rebased onto it yet; it still merges without conflict.

A compute program whose HLSL DXC would compile unoptimised (pso::enormous, over 8 MiB of HLSL) goes to the direct DXIL translator, even without XCL_DIRECT_DXIL. What that translator makes is kept in the translated cache under rerouted_identity, which follows the direct translator's version and sources. When the direct translator fails on such a program, its HLSL fallback was kept under the HLSL path's identity instead, and that identity does not follow the direct translator.

translated::cached_rerouted looks under the HLSL path's identity first. So once a build has stored such a fallback, every later build is served that fallback, even one whose direct translator can now translate the program. The program is never tried again.

This PR keeps that fallback under rerouted_identity too. A new direct translator version then misses it and translates the program again.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs:
    • compile_console_shader: when the enormous-program route's direct translation fails, the HLSL result it falls back to is marked as following the direct translator (the bool that already sends the direct translator's own output to rerouted_identity).
    • Doc comments of compile_console_shader and translated::cached say so; the cache-hit note reads "direct DXIL (its HLSL is enormous), or its HLSL fallback".
  • Kept where they were: programs the HLSL path takes for any other reason, and everything under XCL_DIRECT_DXIL (whose identity already carries the direct translator's version).
  • Test shader_cache_tests::an_enormous_programs_fallback_is_retried_by_a_new_direct_translator:
    • the fallback is a hit for the same direct translator version;
    • a new version misses it and keeps its own DXIL;
    • an old-style entry under the HLSL path's identity is still served to a new version (the case this PR stops creating).
  • +53 / −7 in one file, about 35 of the added lines the test. pso.rs is one of PREPARATION_LAYOUT_SOURCES, so XCL_PIPELINE_LAYOUT_ID changes, as with any edit of pso.rs. The translator identity (XCL_TRANSLATOR_SOURCE_ID) does not change.

Why (what we hit)

  • Measured (posted on Recompiler: preserve compute prologue dominance in direct DXIL #3154, comment): one enormous compute program of the retail title. On main e429936c the direct translator failed on it, and main stored its 9,370,880-byte HLSL fallback. A build of Recompiler: preserve compute prologue dominance in direct DXIL #3154 translates that program directly (1,214,602 bytes). Its first run, on a copy of the cache from the main run, was served main's fallback, unchanged.
  • Read: in cached_rerouted the HLSL path's identity is looked up first, then rerouted_identity. Only the direct translator's own output was stored under rerouted_identity.
  • Deduced: swapping the lookup order alone would not help. A new direct translator has a new rerouted_identity, which misses, and the lookup then still finds the old fallback under the HLSL path's identity. The fallback itself has to follow the direct translator.

Tested

  • Head on main 7db2f39 (it merges with main 227d2cb without conflict; not tested there). RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631, Rust 1.100.0, release tests (cargo test --release -p xcl --lib), XCL_REQUIRE_GPU=mesh.
  • gpu::recomp::pso::shader_cache_tests::: 31 passed, 0 failed, the new test and the two existing rerouted-cache tests (rerouted_disk_entries_follow_the_direct_translator, ..._follow_compact_nesting_policy) among them.
  • The build has the same 18 compiler warnings as main 7db2f39 (no new one).

Regression run
Not run yet: no scripts/smoke.ps1 pair (main and this head) has been made for this PR, so there is no xcl-smoke block. That is why it stays a draft. The change only decides under which identity a fallback is stored, for enormous compute programs whose direct translation fails.

Not tested

  • A title run with this change, and the Recompiler: preserve compute prologue dominance in direct DXIL #3154 program through this exact path (a unit test cannot hold an 8 MiB HLSL program and a failing direct translation; the test drives cached_rerouted with the flag compile_console_shader now sets).
  • Entries stored before this change stay under the HLSL path's identity and are still served: such a fallback goes away only when its file is removed or the cache is new. Bumping TRANSLATION_GLUE_REVISION would clear them, but also every other translation, so this PR does not.
  • AMD and Intel GPUs (nothing here is GPU-specific).
  • Recompiler: validate DXIL containers and split pieces in translated cache #2540 also edits cached_rerouted (container validation); the two should merge without overlap, not checked.

AI use

🤖 Generated with Claude Code

…anslator in the translated cache

A compute program whose HLSL DXC would compile unoptimised (`pso::enormous`) goes to the
direct DXIL translator, and what that translator makes is kept on disk under
`rerouted_identity`, which follows the translator's version and sources. When the direct
translator fails on such a program, its HLSL fallback was kept under the HLSL path's
identity, which does not. `translated::cached_rerouted` looks under that identity first,
so every later build, with a direct translator that can now translate the program, was
served the old fallback and never tried again.

compile_console_shader now says that fallback follows the direct translator too: it is
kept under `rerouted_identity`, and a new direct translator version misses it and
translates the program again. Programs the HLSL path takes for other reasons, and
everything with XCL_DIRECT_DXIL (whose identity already has the direct translator's
version), are kept where they were.

Entries a build without this stored stay under the HLSL path's identity and are still
served: such a fallback goes only when its file is removed or the cache is new.

Test: an_enormous_programs_fallback_is_retried_by_a_new_direct_translator (the fallback
is a hit for the same direct translator, missed by a new one, which keeps its own DXIL;
an old entry under the HLSL path's identity is still served).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Nov 28, 2026
@CharlyRien

Copy link
Copy Markdown
Contributor Author

The red "Build and test" on 4835af9 is 4 tests outside this PR: shaders::pipeline_library::tests::{builder_deduplicates_names_and_atomically_replaces_output, graphics_pipeline_round_trips_through_serialized_library, mesh_pipeline_round_trips_through_serialized_library} and shaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable. The first fails on an entry count (3 against 2); the other three then fail on the poisoned lock.

This PR only changes gpu/recomp/pso.rs (the translated cache). The same 4 tests passed on #3231 and #3232, opened from the same main 7db2f39 at the same time. This looks like the shared library-builder state that #3221 and #3183 address (and #3180 lists). We cannot rerun the job from here.

AI use: Claude Code with Claude Opus 5.5 read the CI log and wrote this.

@CharlyRien

Copy link
Copy Markdown
Contributor Author

Closing: since #3243 made direct DXIL the default, the enormous-program route this PR fixes is only reached with XCL_DIRECT_DXIL=0, so the trap no longer affects the default path. Happy to reopen if the HLSL-only route matters to someone.

AI use: closed with Claude Code (Claude Opus 5.5), decided by me.

@CharlyRien CharlyRien closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant