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

Open
github-bot wants to merge 2 commits from github-bot/gh-1413 into main AGit
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 15:43 UTC · original
tiagonogueiraa-bit:safe-barrier-cache → main · +3 −3 · 2 files · 2 commits · open

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

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 15:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413) `tiagonogueiraa-bit:safe-barrier-cache` → `main` · +3 −3 · 2 files · 2 commits · open `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://git.gtahub.st/github/xcl-dev--xcl/pulls/1413)) **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)
XCL_SAFE_BARRIER=0 changes the HLSL emitted for s_barrier in multi-wave
compute programs (emit.rs), but the variable was neither in
cache_allowed's list nor in the cache key. 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.

It is now in cache_allowed's list, like the other variables that change
the emitted code. As for those, its presence alone turns the caches off.
shader_cache_bypasses_debug_overrides checks it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Entries a run with XCL_SAFE_BARRIER=0 or =1 stored under the default key
stay readable after the bypass, since pso.rs is outside the source hash.
Bumping TRANSLATION_GLUE_REVISION gives every build a new key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:09 +00:00
Author
Owner

@⁠pvfreis on GitHub · 2026-11-24 16:34 UTC · original

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.

**@⁠pvfreis** on GitHub · 2026-11-24 16:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7137881049) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 17:08 UTC · original

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

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

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 17:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7138748153) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 19:23 UTC · original

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).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 19:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7142017621) 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).
Author
Owner

@⁠pvfreis on GitHub · 2026-11-24 19:46 UTC · original

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.

**@⁠pvfreis** on GitHub · 2026-11-24 19:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7142569679) 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.
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 19:48 UTC · original

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.

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 19:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7142617166) 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.
Author
Owner

@⁠Mischief8713 on GitHub · 2026-11-24 20:36 UTC · original

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.
**@⁠Mischief8713** on GitHub · 2026-11-24 20:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7143817437) **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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 05:13 UTC · original

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.

**@⁠DavidM1911** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1413#issuecomment-7183289002) 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.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/pso.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1413/head:github-bot/gh-1413'
git switch 'github-bot/gh-1413'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1413'
git switch 'github-bot/gh-1413'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1413'
git switch 'github-bot/gh-1413'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1413'
git switch 'main'
git merge --squash 'github-bot/gh-1413'
git switch 'main'
git merge --ff-only 'github-bot/gh-1413'
git switch 'main'
git merge 'github-bot/gh-1413'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.