Recompiler: the translated cache keys on the HLSL emitter's switches #2317

Closed
vakaobr wants to merge 1 commit from upstream-pr/2327 into main
vakaobr commented 2026-11-25 14:35:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T14:35:21Z.


Addresses #1409, like #1413, which came first. Correction to what this said before: only XCL_SAFE_BARRIER has the bug. XCL_WAVE64_SPIN, XCL_X64_ALL_MASKS and XCL_RECOMP_NO_STRUCTURED are already in cache_allowed on main, which turns the memory and the disk cache off whenever one of them is set, so they never reuse a stale translation and the tags this adds for them never take effect.

XCL_SAFE_BARRIER=0 changes the HLSL emitted for s_barrier, but neither cache_allowed nor the cache identity knows it, so a run with it can load a translation cached without it, and the other way round. #1413 adds it to cache_allowed (no cache while it is set), the same way main handles the other three. This keys the disk cache on it instead (translated::identity() gets a tag when it is set), so a run with it set is still cached. That only matters where the barrier switch is a mode people run in rather than a debug switch, as on the Mac branch from #258, where the native barrier is the default and XCL_SAFE_BARRIER=1 brings back the spin barrier. For main, #1413 fits the existing pattern; if it is merged, I'll close this.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs: translated::with_emit_switches, applied at the end of identity() (rerouted entries derive from it, so they follow), and the test emit_switches_change_the_translated_identity.

Tested

  • Apple M5 Pro, macOS 27.2.1, CrossOver 26.3.0 with D3DMetal 3.0 (Rosetta 2), Rust 1.100.0 x86_64-pc-windows-gnu, debug, at e56c368 (on main 06c9f55).
  • gpu::recomp::pso::shader_cache_tests, all 7 tests (the new one + the 6 existing): 7 passed, 0 failed, each in its own process.
  • Mutation check: with XCL_SAFE_BARRIER left out of with_emit_switches, the new test fails (left: 4, right: 6).
  • Whole suite: not run on Windows.

Regression run

  • None: I have no title of my own to run scripts/smoke.ps1 on. Needs someone with a title, or the maintainer's call.

Not tested

  • Windows, AMD / NVIDIA, the whole suite, any title.
  • The change only adds to the cache identity when a switch is set: a run without these switches uses the same identity as main.

AI use

  • Claude Code, Claude Opus 5.5: found the gap, wrote the change and the test, ran the tests and wrote this description.
<!-- greyfinch-sync:ivall/xcl:issue:5493407666 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327). Originally posted by [vakaobr](https://github.com/vakaobr) on 2026-11-25T14:35:21Z. --- Addresses #1409, like #1413, which came first. **Correction to what this said before:** only `XCL_SAFE_BARRIER` has the bug. `XCL_WAVE64_SPIN`, `XCL_X64_ALL_MASKS` and `XCL_RECOMP_NO_STRUCTURED` are already in `cache_allowed` on `main`, which turns the memory and the disk cache off whenever one of them is set, so they never reuse a stale translation and the tags this adds for them never take effect. `XCL_SAFE_BARRIER=0` changes the HLSL emitted for `s_barrier`, but neither `cache_allowed` nor the cache identity knows it, so a run with it can load a translation cached without it, and the other way round. #1413 adds it to `cache_allowed` (no cache while it is set), the same way `main` handles the other three. This keys the disk cache on it instead (`translated::identity()` gets a tag when it is set), so a run with it set is still cached. That only matters where the barrier switch is a mode people run in rather than a debug switch, as on the Mac branch from #258, where the native barrier is the default and `XCL_SAFE_BARRIER=1` brings back the spin barrier. For `main`, #1413 fits the existing pattern; if it is merged, I'll close this. **What is in it** - `crates/xcl/src/gpu/recomp/pso.rs`: `translated::with_emit_switches`, applied at the end of `identity()` (rerouted entries derive from it, so they follow), and the test `emit_switches_change_the_translated_identity`. **Tested** - Apple M5 Pro, macOS 27.2.1, CrossOver 26.3.0 with D3DMetal 3.0 (Rosetta 2), Rust 1.100.0 `x86_64-pc-windows-gnu`, debug, at e56c368 (on main 06c9f55). - `gpu::recomp::pso::shader_cache_tests`, all 7 tests (the new one + the 6 existing): 7 passed, 0 failed, each in its own process. - Mutation check: with `XCL_SAFE_BARRIER` left out of `with_emit_switches`, the new test fails (`left: 4, right: 6`). - Whole suite: not run on Windows. **Regression run** - None: I have no title of my own to run `scripts/smoke.ps1` on. Needs someone with a title, or the maintainer's call. **Not tested** - Windows, AMD / NVIDIA, the whole suite, any title. - The change only adds to the cache identity when a switch is set: a run without these switches uses the same identity as main. **AI use** - Claude Code, Claude Opus 5.5: found the gap, wrote the change and the test, ran the tests and wrote this description.
nnonno91 commented 2026-11-25 15:07:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-25T14:39:43Z.


Independent Windows check of e56c368079bb51c1ceccf60fbcbb1e1860f3b3c5, using actual cache files across process boundaries.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized profile.
  • cargo test --locked -p xcl --lib gpu::recomp::pso::shader_cache_tests -- --nocapture --test-threads=1 gave 21 passed, 0 failed, 0 ignored and no skips.
  • A temporary test called translated::cached for the same key and trivial DXC-compiled compute shader in nine separate processes sharing one empty-at-start cache directory. Ran cargo test --locked -p xcl --lib local_emitter_switch_disk_cache -- --nocapture --test-threads=1 with XCL_DIRECT_DXIL=0. Each run gave 1 passed, 0 failed and 0 ignored.
  • The four switches (XCL_SAFE_BARRIER=0, XCL_WAVE64_SPIN=0, XCL_X64_ALL_MASKS=1, and XCL_RECOMP_NO_STRUCTURED=1) each missed the default entry and made a distinct entry. Defaults and the barrier-off setting both hit on repeat. Explicit defaults reused the default identity, and XCL_TRANSLATED_CACHE=0 compiled with identity zero. Five cache files remained. The temporary test was removed.

Not tested

GPU execution, the emitter output under each setting, the parent revision, retail smoke and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) wrote the temporary cache fixture, ran the tests and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7165618466 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327#issuecomment-7165618466). Originally posted by [nnonno91](https://github.com/nnonno91) on 2026-11-25T14:39:43Z. --- Independent Windows check of `e56c368079bb51c1ceccf60fbcbb1e1860f3b3c5`, using actual cache files across process boundaries. **Tested** - Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized profile. - `cargo test --locked -p xcl --lib gpu::recomp::pso::shader_cache_tests -- --nocapture --test-threads=1` gave 21 passed, 0 failed, 0 ignored and no skips. - A temporary test called `translated::cached` for the same key and trivial DXC-compiled compute shader in nine separate processes sharing one empty-at-start cache directory. Ran `cargo test --locked -p xcl --lib local_emitter_switch_disk_cache -- --nocapture --test-threads=1` with `XCL_DIRECT_DXIL=0`. Each run gave 1 passed, 0 failed and 0 ignored. - The four switches (`XCL_SAFE_BARRIER=0`, `XCL_WAVE64_SPIN=0`, `XCL_X64_ALL_MASKS=1`, and `XCL_RECOMP_NO_STRUCTURED=1`) each missed the default entry and made a distinct entry. Defaults and the barrier-off setting both hit on repeat. Explicit defaults reused the default identity, and `XCL_TRANSLATED_CACHE=0` compiled with identity zero. Five cache files remained. The temporary test was removed. **Not tested** GPU execution, the emitter output under each setting, the parent revision, retail smoke and the full workspace suite. **AI use** OpenAI Codex (GPT-6.2 Sol) wrote the temporary cache fixture, ran the tests and prepared this report.
SlopTart commented 2026-11-25 15:07:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T14:47:03Z.


Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

Disclosure: the branch as fetched carries stacked unmerged content beyond the cache-key commit (title_list, dispatch_chain, split-restore work; 1780 insertions total). This row covers the branch as-is, same as any reviewer building it.

  • gpu_ suite (--release --locked, --test-threads=2): 142 passed / 3 failed / 1 ignored, identical to plain origin/main on this rig (rig's known baseline: fuzz seed 1003 of #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed).
  • Targeted run of the cache/identity tests (gpu::recomp::dxc::cache_tests:: and gpu::recomp::pso::shader_cache_tests:: filters): all green on this lane, including cache_key_tracks_the_dxc_toolchain and the direct-vs-HLSL identity tests; no collisions with the XCL-patched vkd3d-proton toolchain fingerprint on the Wine lane.

Adds the Wine/vkd3d-proton data point next to the independent Windows check.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7165808911 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327#issuecomment-7165808911). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T14:47:03Z. --- **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). Disclosure: the branch as fetched carries stacked unmerged content beyond the cache-key commit (title_list, dispatch_chain, split-restore work; 1780 insertions total). This row covers the branch as-is, same as any reviewer building it. - `gpu_` suite (`--release --locked`, `--test-threads=2`): 142 passed / 3 failed / 1 ignored, identical to plain `origin/main` on this rig (rig's known baseline: fuzz seed 1003 of #2115, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`). - Targeted run of the cache/identity tests (`gpu::recomp::dxc::cache_tests::` and `gpu::recomp::pso::shader_cache_tests::` filters): all green on this lane, including `cache_key_tracks_the_dxc_toolchain` and the direct-vs-HLSL identity tests; no collisions with the XCL-patched vkd3d-proton toolchain fingerprint on the Wine lane. Adds the Wine/vkd3d-proton data point next to the independent Windows check. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
DavidM1911 commented 2026-11-25 18:04:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:04:35Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7170403922 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327#issuecomment-7170403922). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T18:04:35Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-actions[bot] commented 2026-11-29 07:44:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:44:07Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252657317 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327#issuecomment-7252657317). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:44:07Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:50:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:50:28Z.


Triage (#1607) – head e58890f

The stale-translation bug this fixes (#1409) is fixed on main by 0d0a452: cache_allowed in pso.rs now lists XCL_SAFE_BARRIER next to XCL_WAVE64_SPIN, XCL_X64_ALL_MASKS and XCL_RECOMP_NO_STRUCTURED, so the translated cache is off whenever any of them is set.
With that, every tag with_emit_switches adds is only reached when the cache is not used, so the change has no effect on main. #1413 (the cache_allowed variant) is superseded by the same commit.
Recommendation: close (superseded by main commit 0d0a452).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304545545 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327#issuecomment-7304545545). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:50:28Z. --- **Triage (#1607)** – head e58890f The stale-translation bug this fixes (#1409) is fixed on main by 0d0a452: `cache_allowed` in pso.rs now lists `XCL_SAFE_BARRIER` next to `XCL_WAVE64_SPIN`, `XCL_X64_ALL_MASKS` and `XCL_RECOMP_NO_STRUCTURED`, so the translated cache is off whenever any of them is set. With that, every tag `with_emit_switches` adds is only reached when the cache is not used, so the change has no effect on main. #1413 (the cache_allowed variant) is superseded by the same commit. Recommendation: close (superseded by main commit 0d0a452). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:52:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:52:13Z.


Closing as superseded: this change is already on main (0d0a452). cache_allowed (recomp/pso.rs:1182) already turns the translated caches off when XCL_RECOMP_NO_STRUCTURED, XCL_X64_ALL_MASKS, XCL_WAVE64_SPIN or XCL_SAFE_BARRIER is set (also XCL_RECOMP_WHY, XCL_DXIL_NO_OPT), at the compute, mesh and geometry cache sites; so the PR's identity tags never apply

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311766048 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2327#issuecomment-7311766048). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:52:13Z. --- Closing as superseded: this change is already on `main` (0d0a452). cache_allowed (recomp/pso.rs:1182) already turns the translated caches off when XCL_RECOMP_NO_STRUCTURED, XCL_X64_ALL_MASKS, XCL_WAVE64_SPIN or XCL_SAFE_BARRIER is set (also XCL_RECOMP_WHY, XCL_DXIL_NO_OPT), at the compute, mesh and geometry cache sites; so the PR's identity tags never apply Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2317
No description provided.