Shaders: XCL_SAFE_BARRIER turns the translation caches off (#1409) #1403

Closed
tiagonogueiraa-bit wants to merge 2 commits from upstream-pr/1413 into main
tiagonogueiraa-bit commented 2026-11-24 15:43:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:43:14Z.


XCL_SAFE_BARRIER=0 changes the HLSL emitted for s_barrier in multi-wave compute programs (emit.rs:553), but the variable was neither in cache_allowed's list nor in the cache key. So a run with it stored those programs' DXIL with the plain group barrier, and later runs without it loaded that DXIL. In the other order, the variable had no effect on programs already cached. Fixes #1409.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs:
    • cache_allowed: XCL_SAFE_BARRIER joins the list of variables that change the emitted code. As for those, its presence alone turns the caches off.
    • shader_cache_bypasses_debug_overrides checks it, for every stage.
  • crates/xcl/build.rs: TRANSLATION_GLUE_REVISION goes to pso-glue-v2. Entries that a run with the variable set stored under the default key would otherwise stay readable, since pso.rs is outside the source hash; the new revision gives every build a new key (review by @pvfreis).

Tested

  • macOS, Rust stable: cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc, no errors (C code stubbed, nothing linked).
  • The test's new case fails on main: cache_allowed(Stage::Compute, |v| v == "XCL_SAFE_BARRIER") returns true there, as #1409 shows.
  • @pvfreis, native Windows, RTX 3060, this head merged onto b7aa9f3: cargo test --workspace --locked --no-fail-fast -- --test-threads=4 gives 769 passed, 1 failed, 41 ignored, the same as main b7aa9f3. shader_cache_bypasses_debug_overrides passes. The one failure is the e2e test's swap chain in a non-interactive session, on both. (report)

Regression run
Not run. I have no Windows machine here.

Not tested

  • A cache round trip with the variable set and then unset. @pvfreis's probe on c160d86 showed the stale entry being reused; the revision bump (190c97e) has not been run on Windows.
  • A retail title.

Overlaps
#1284 (XCL_LOOP_BUDGET), #245 (XCL_CS_PAD_ALL, XCL_NO_CS_PAD) and #613 (XCL_DXC_ARGS) add names to the same list and test. Whichever merges later rebases over a one-line conflict.

AI use

  • Claude Code with Claude Opus 5.5. It wrote the change and this description, and ran the macOS check.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5475421620 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T15:43:14Z. --- `XCL_SAFE_BARRIER=0` changes the HLSL emitted for `s_barrier` in multi-wave compute programs (`emit.rs:553`), but the variable was neither in `cache_allowed`'s list nor in the cache key. So a run with it stored those programs' DXIL with the plain group barrier, and later runs without it loaded that DXIL. In the other order, the variable had no effect on programs already cached. Fixes #1409. **What is in it** - `crates/xcl/src/gpu/recomp/pso.rs`: - `cache_allowed`: `XCL_SAFE_BARRIER` joins the list of variables that change the emitted code. As for those, its presence alone turns the caches off. - `shader_cache_bypasses_debug_overrides` checks it, for every stage. - `crates/xcl/build.rs`: `TRANSLATION_GLUE_REVISION` goes to `pso-glue-v2`. Entries that a run with the variable set stored under the default key would otherwise stay readable, since `pso.rs` is outside the source hash; the new revision gives every build a new key (review by @pvfreis). **Tested** - macOS, Rust stable: `cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc`, no errors (C code stubbed, nothing linked). - The test's new case fails on `main`: `cache_allowed(Stage::Compute, |v| v == "XCL_SAFE_BARRIER")` returns `true` there, as #1409 shows. - @pvfreis, native Windows, RTX 3060, this head merged onto `b7aa9f3`: `cargo test --workspace --locked --no-fail-fast -- --test-threads=4` gives 769 passed, 1 failed, 41 ignored, the same as `main` `b7aa9f3`. `shader_cache_bypasses_debug_overrides` passes. The one failure is the e2e test's swap chain in a non-interactive session, on both. ([report](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7137881049)) **Regression run** Not run. I have no Windows machine here. **Not tested** - A cache round trip with the variable set and then unset. @pvfreis's probe on `c160d86` showed the stale entry being reused; the revision bump (`190c97e`) has not been run on Windows. - A retail title. **Overlaps** #1284 (`XCL_LOOP_BUDGET`), #245 (`XCL_CS_PAD_ALL`, `XCL_NO_CS_PAD`) and #613 (`XCL_DXC_ARGS`) add names to the same list and test. Whichever merges later rebases over a one-line conflict. **AI use** - Claude Code with Claude Opus 5.5. It wrote the change and this description, and ran the macOS check. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
pvfreis commented 2026-11-24 17:06:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T16:34:34Z.


Test report for bfaf8c8b8d (this PR's head) merged onto main b7aa9f3bd2 (clean merge). shader_cache_bypasses_debug_overrides passes with XCL_SAFE_BARRIER added; no regression elsewhere. I opened #1409, and this is the fix it suggested.

Tested

  • RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, Windows 11 26H2 (10.0.26300), Rust 1.100.0 stable MSVC, debug
  • cargo build --workspace --locked --offline, then cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4:
    • main b7aa9f3: 769 passed, 1 failed, 41 ignored
    • this PR merged onto b7aa9f3: 769 passed, 1 failed, 41 ignored (the PR extends an existing test, shader_cache_bypasses_debug_overrides, which passes)
  • SKIPPED on this adapter (both): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)
  • The 1 failure is the same on both and not from this PR: test_title_runs_and_game_folder_is_untouched (e2e, presents 0), because these runs are in an isolated non-interactive session where CreateSwapChainForHwnd returns 0x887A0022.

Not tested

  • a cache round trip with XCL_SAFE_BARRIER=0 set and unset across two runs
  • AMD, Intel; a retail title (no smoke run here)

Tested and written with Claude Code (Claude Opus 5.5); the runs are real, on the hardware above.

<!-- greyfinch-sync:ivall/xcl:comment:7137881049 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1413#issuecomment-7137881049). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-11-24T16:34:34Z. --- Test report for bfaf8c8b8dcd7959179625fa27b8da4e3cbdc2ab (this PR's head) merged onto main b7aa9f3bd2 (clean merge). `shader_cache_bypasses_debug_overrides` passes with `XCL_SAFE_BARRIER` added; no regression elsewhere. I opened #1409, and this is the fix it suggested. **Tested** - RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, Windows 11 26H2 (10.0.26300), Rust 1.100.0 stable MSVC, debug - `cargo build --workspace --locked --offline`, then `cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4`: - main b7aa9f3: 769 passed, 1 failed, 41 ignored - this PR merged onto b7aa9f3: 769 passed, 1 failed, 41 ignored (the PR extends an existing test, `shader_cache_bypasses_debug_overrides`, which passes) - SKIPPED on this adapter (both): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64) - The 1 failure is the same on both and not from this PR: `test_title_runs_and_game_folder_is_untouched` (e2e, `presents` 0), because these runs are in an isolated non-interactive session where `CreateSwapChainForHwnd` returns 0x887A0022. **Not tested** - a cache round trip with `XCL_SAFE_BARRIER=0` set and unset across two runs - AMD, Intel; a retail title (no smoke run here) Tested and written with Claude Code (Claude Opus 5.5); the runs are real, on the hardware above.
DavidM1911 commented 2026-11-24 18:08:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:08:32Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138748153 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7138748153). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T17:08:32Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
tiagonogueiraa-bit commented 2026-11-24 21:08:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T19:23:02Z.


Thank you, @pvfreis, and @DavidM1911! The run is in Tested, and the PR is ready for review.

Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7142017621 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7142017621). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T19:23:02Z. --- Thank you, @pvfreis, and @DavidM1911! The run is in **Tested**, and the PR is ready for review. Written with Claude Code (Claude Opus 5.5).
pvfreis commented 2026-11-24 21:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T19:46:26Z.


The bypass for runs with XCL_SAFE_BARRIER set looks right. One upgrade case remains.

On stock c160d86, a synthetic s_barrier shader wrote different translated entries under the same cache key with the flag unset and set to 0. I copied just the =0 entry into an empty cache and ran again with the flag unset. XCL reused that entry without writing a lower-level DXIL cache entry.

At bfaf8c8, this patch leaves TRANSLATION_GLUE_REVISION unchanged. build.rs excludes pso.rs from the source hash, so a default run can still read a legacy entry when the hashed sources, DXC and shader settings match. Bumping the translation glue revision would retire those entries. The upgrade path was checked in the code.

Codex (GPT-6.2 Sol) ran the stock probe. Codex (GPT-6.2 Astra) independently checked the evidence and upgrade path.

<!-- greyfinch-sync:ivall/xcl:comment:7142569679 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7142569679). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-11-24T19:46:26Z. --- The bypass for runs with `XCL_SAFE_BARRIER` set looks right. One upgrade case remains. On stock `c160d86`, a synthetic `s_barrier` shader wrote different translated entries under the same cache key with the flag unset and set to `0`. I copied just the `=0` entry into an empty cache and ran again with the flag unset. XCL reused that entry without writing a lower-level DXIL cache entry. At `bfaf8c8`, this patch leaves `TRANSLATION_GLUE_REVISION` unchanged. `build.rs` excludes `pso.rs` from the source hash, so a default run can still read a legacy entry when the hashed sources, DXC and shader settings match. Bumping the translation glue revision would retire those entries. The upgrade path was checked in the code. Codex (GPT-6.2 Sol) ran the stock probe. Codex (GPT-6.2 Astra) independently checked the evidence and upgrade path.
tiagonogueiraa-bit commented 2026-11-24 21:09:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T19:48:29Z.


Thanks @pvfreis, you're right: with pso.rs outside the source hash, an entry stored by a run with the variable set stays valid for default runs after this change. 190c97e bumps TRANSLATION_GLUE_REVISION to pso-glue-v2, so every build gets a new key and those entries are retired. Description updated.

<!-- greyfinch-sync:ivall/xcl:comment:7142617166 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7142617166). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T19:48:29Z. --- Thanks @pvfreis, you're right: with `pso.rs` outside the source hash, an entry stored by a run with the variable set stays valid for default runs after this change. `190c97e` bumps `TRANSLATION_GLUE_REVISION` to `pso-glue-v2`, so every build gets a new key and those entries are retired. Description updated.
Mischief8713 commented 2026-11-24 21:09:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Mischief8713 on 2026-11-24T20:36:52Z.


GPU run of 190c97e on Windows (NVIDIA GTX 1660 Ti, Turing): 707 passed, 0 failed, 21 ignored

Tested

  • NVIDIA GeForce GTX 1660 Ti 6 GB (Turing, driver 32.0.16.2114), Ryzen 5 2600X, Windows 11 (10.0.26300), rustc 1.100.0, debug build
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4; build exit 0, test exit 0
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64)
  • The head does not contain current main (9039900). It was run as it is.
  • lib: 707 passed, 0 failed, 21 ignored.
  • This is the PR's second commit (bfaf8c8, then 190c97e); the head, not bfaf8c8, was run. The diff touches build.rs and pso.rs, and the suite has no new test name for it, so this shows that nothing else broke.

Not tested

  • No retail title and no scripts/smoke.ps1 run, so no regression run
  • A run with XCL_SAFE_BARRIER set, since that needs a title
  • AMD GPUs; only Turing was run here

AI use

  • Claude Code with Claude Sonnet 5.5 ran the commands and wrote this report. I checked the output.
<!-- greyfinch-sync:ivall/xcl:comment:7143817437 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7143817437). Originally posted by [Mischief8713](https://github.com/Mischief8713) on 2026-11-24T20:36:52Z. --- **GPU run of `190c97e` on Windows (NVIDIA GTX 1660 Ti, Turing): 707 passed, 0 failed, 21 ignored** **Tested** - NVIDIA GeForce GTX 1660 Ti 6 GB (Turing, driver 32.0.16.2114), Ryzen 5 2600X, Windows 11 (10.0.26300), rustc 1.100.0, debug build - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`; build exit 0, test exit 0 - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64) - The head does not contain current `main` (`9039900`). It was run as it is. - lib: 707 passed, 0 failed, 21 ignored. - This is the PR's second commit (`bfaf8c8`, then `190c97e`); the head, not `bfaf8c8`, was run. The diff touches `build.rs` and `pso.rs`, and the suite has no new test name for it, so this shows that nothing else broke. **Not tested** - No retail title and no `scripts/smoke.ps1` run, so no regression run - A run with `XCL_SAFE_BARRIER` set, since that needs a title - AMD GPUs; only Turing was run here **AI use** - Claude Code with Claude Sonnet 5.5 ran the commands and wrote this report. I checked the output.
DavidM1911 commented 2026-11-26 06:06:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:13:16Z.


Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7183289002 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7183289002). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:13:16Z. --- Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
github-actions[bot] commented 2026-12-01 02:32:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:32:16Z.


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:7298722940 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7298722940). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:32:16Z. --- 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 05:39:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:39:58Z.


Triage (#1607) – head 190c97e

main commit 0d0a452 (Recompiler: no translated disk cache while XCL_SAFE_BARRIER is set) already adds XCL_SAFE_BARRIER to cache_allowed's list and to shader_cache_bypasses_debug_overrides in gpu/recomp/pso.rs, which is the whole fix for #1409 here.
The TRANSLATION_GLUE_REVISION bump to pso-glue-v2 is also moot: main is at pso-glue-v5.
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:7302008570 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7302008570). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:39:58Z. --- **Triage (#1607)** – head 190c97e main commit 0d0a452 (Recompiler: no translated disk cache while XCL_SAFE_BARRIER is set) already adds XCL_SAFE_BARRIER to cache_allowed's list and to shader_cache_bypasses_debug_overrides in gpu/recomp/pso.rs, which is the whole fix for #1409 here. The TRANSLATION_GLUE_REVISION bump to pso-glue-v2 is also moot: main is at pso-glue-v5. 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 15:59:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:59:17Z.


Closing as superseded: this change is already on main (0d0a4521). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7316847758 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7316847758). Originally posted by [throny](https://github.com/throny) on 2026-12-01T15:59:17Z. --- Closing as superseded: this change is already on `main` (0d0a4521). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5).

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!1403
No description provided.