Shaders: restore cache-only state across nesting and unwinding #1396

Open
github-bot wants to merge 1 commit from github-bot/gh-1396 into main AGit
Owner

@⁠anakatt on GitHub · 2026-11-24 15:33 UTC · original
anakatt:shaders/restore-cache-only-scopes → main · +54 −4 · 2 files · 1 commits · open

I fixed cache-only scopes losing their mode and miss state across nested calls or Rust unwinding. An inner probe previously enabled compilation inside its parent; a panic left later work stuck in cache-only mode.

What is in it

  • Use a stack guard to restore the previous thread-local mode on normal return and unwinding.
  • Preserve parent misses and propagate nested misses outward, while each probe reports its own misses.
  • Add two regression tests and document the scope behavior. No GPU execution changes.

Tested

I ran the tests in a Windows 11 Pro ARM64 UTM VM (10.0.26100.1742, 4 GiB RAM, Red Hat VirtIO GPU DOD 22.7.38.43), with Rust 1.100.0 and x86_64-pc-windows-msvc. The cache tests loaded DXC/DXIL 1.9.2602.17, compiler commit 21d28f72, from Windows SDK 10.0.26100.0.

  • Before: cargo test --locked -p xcl --lib gpu::recomp::dxc::cache_tests::cached_only_ -- --test-threads=4: 0 passed, 2 failed, 0 ignored, 719 filtered out. The nested-mode and post-unwind-mode assertions failed.
  • After: cargo test --locked -p xcl --lib gpu::recomp::dxc::cache_tests -- --test-threads=4: 12 passed, 0 failed, 0 ignored, 709 filtered out. No SKIPPED output.

Source: main 47efa2ecea0a12934719ae69b81930cf02a4b1c3 archive with the changed dxc.rs copied in before committing ca0e1b06d85fc8bb6a0021260e7f1363ca20e9db; not a clean head checkout. Shared target directory cleaned for xcl before reproduction; one build job; dev/test debug info disabled.

Not tested

Full workspace suite, native x64 Windows hardware, GPU execution, game performance and real-title runs. I did not build or run XCL on macOS, and I have not reproduced a game-level failure from these scope bugs.

Regression run

The required clean main/head real-title scripts/smoke.ps1 runs have not been performed. No xcl-smoke blocks are available; this remains a draft.

AI use

omp, openai-codex/gpt-6-astra: investigated, wrote the fix and regression tests, ran the Windows checks, and prepared this PR.

**@⁠anakatt** on GitHub · 2026-11-24 15:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/1396) `anakatt:shaders/restore-cache-only-scopes` → `main` · +54 −4 · 2 files · 1 commits · open I fixed cache-only scopes losing their mode and miss state across nested calls or Rust unwinding. An inner probe previously enabled compilation inside its parent; a panic left later work stuck in cache-only mode. ## What is in it - Use a stack guard to restore the previous thread-local mode on normal return and unwinding. - Preserve parent misses and propagate nested misses outward, while each probe reports its own misses. - Add two regression tests and document the scope behavior. No GPU execution changes. ## Tested I ran the tests in a Windows 11 Pro ARM64 UTM VM (10.0.26100.1742, 4 GiB RAM, Red Hat VirtIO GPU DOD 22.7.38.43), with Rust 1.100.0 and x86_64-pc-windows-msvc. The cache tests loaded DXC/DXIL **1.9.2602.17**, compiler commit `21d28f72`, from Windows SDK `10.0.26100.0`. - Before: `cargo test --locked -p xcl --lib gpu::recomp::dxc::cache_tests::cached_only_ -- --test-threads=4`: **0 passed, 2 failed, 0 ignored, 719 filtered out**. The nested-mode and post-unwind-mode assertions failed. - After: `cargo test --locked -p xcl --lib gpu::recomp::dxc::cache_tests -- --test-threads=4`: **12 passed, 0 failed, 0 ignored, 709 filtered out**. No `SKIPPED` output. Source: main `47efa2ecea0a12934719ae69b81930cf02a4b1c3` archive with the changed dxc.rs copied in before committing `ca0e1b06d85fc8bb6a0021260e7f1363ca20e9db`; not a clean head checkout. Shared target directory cleaned for xcl before reproduction; one build job; dev/test debug info disabled. ## Not tested Full workspace suite, native x64 Windows hardware, GPU execution, game performance and real-title runs. I did not build or run XCL on macOS, and I have not reproduced a game-level failure from these scope bugs. ## Regression run The required clean main/head real-title `scripts/smoke.ps1` runs have not been performed. No `xcl-smoke` blocks are available; this remains a draft. ## AI use omp, openai-codex/gpt-6-astra: investigated, wrote the fix and regression tests, ran the Windows checks, and prepared this PR.
The cache-only helper unconditionally cleared its mode after nested calls and never restored it on unwinding. A stack guard restores the prior mode and preserves/propagates misses without allocating.
Windows regressions failed before the fix (0 passed, 2 failed); afterward gpu::recomp::dxc::cache_tests passed 12/12, 709 filtered out, no skips. Windows 11 ARM64 UTM, x86_64 MSVC; DXC 1.9.2602.17 (21d28f72). Full suite and title smoke not run.
Assisted-by: omp (openai-codex/gpt-6-astra)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:46 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 16:55 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (b7aa9f3) in README.md — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-24 16:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1396#issuecomment-7138416232) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`b7aa9f3`) in `README.md` — needs a rebase before it can be tested.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:28 UTC · original

Regression run of ca0e1b06 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: ca0e1b06d85fc8bb6a0021260e7f1363ca20e9db
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1396#issuecomment-7151952897) Regression run of `ca0e1b06` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: ca0e1b06d85fc8bb6a0021260e7f1363ca20e9db gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1629 (PresentX 1629) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14813 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
This pull request has changes conflicting with the target branch.
  • README.md
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/1396/head:github-bot/gh-1396'
git switch 'github-bot/gh-1396'

Merge

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