Skip to content

Shaders: restore cached-only state after panic - #1960

Open
mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:shaders/cached-only-panic-safe
Open

mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:shaders/cached-only-panic-safe

Conversation

@mokkamokacaffe

Copy link
Copy Markdown

Addresses #1896 item 1 without overlapping the mesh deferral or timeout-worker work.

What is in it

  • Replace manual CACHED_ONLY toggling with an RAII guard that restores thread-local state during normal return and stack unwinding.
  • Restore the previous state instead of always writing false, so nested cached-only probes remain inside their outer scope.
  • Propagate an inner deferred miss to the enclosing cached-only probe while keeping miss state out of normal code.
  • Add focused regression tests for a caught panic and nested miss propagation.

Tested

  • git diff --check: passed.
  • Source-level audit of normal return, nested scope and panic-unwind paths.

The current Linux workspace does not contain Cargo/Rust, so the Rust tests were not run here.

Regression run

Not run: this shader-compilation runtime change needs paired Windows/GPU smoke runs on the exact head and a commit of main. Please apply test-only until matching xcl-smoke v1 blocks are available.

main:

Pending for 62265d3 or a newer commit of main.

PR:

Pending for f48d2ff8688604364df799dd76998fd1583367cb.

Not tested

  • Windows workspace suite.
  • A real caught shader-compilation panic followed by another pipeline probe.
  • Retail-title smoke or world-load run.

AI use

OpenAI Codex refreshed #1269, current main, open issues and newly opened PRs; isolated the unclaimed panic-safety part of #1896; implemented the RAII restoration and nesting tests; and performed source-level/diff validation. No hardware or generated test results are claimed.

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head f48d2ff (on its base 62265d3).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 978 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: cached_only_restores_tls_after_a_panic, nested_cached_only_propagates_a_miss_and_restores_the_outer_scope.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 987 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 80f4819 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine) test of f48d2ff merged on main 80f4819 with #684: its two tests pass, and both fail when cached_only is put back to main's body with the tests kept. A 60 s regression pair of a retail title showed no crash and no device removal with or without it.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b, RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 62 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0).

Tested

  • cargo test -j 8 --release -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=4 cached_only: 2 passed, 0 failed.
  • The same with the body of cached_only (dxc.rs:899) put back to main's: 2 failed, at dxc.rs:964 (assertion failed: in_cached_only()) and dxc.rs:951 (assertion failed: !in_cached_only()). So each test is red without the fix.
  • scripts/smoke.ps1, unchanged, 60 s on the start screen, one run of each tree:
main 80f4819 + #684 with f48d2ff
frames shown 1582 1507
presents per 2 s (last 3) 60 60 60 60 60 60
device removals / crashes 0 / 0 0 / 0
exit 0x89 0x89

The tree with the change ran first. The steady rate is the same in both, and I read the 75-frame difference in the totals as start-up time (a guess; one run each). The exit code is the same in both; my reading is the kill that ends a run under Wine (137).

Read

  • dxc.rs:874 to :905: when the guard drops it puts back the earlier CACHED_ONLY and MISSED and hands an inner miss to an outer cached-only scope, as the description says.
  • The one caller outside tests is real.rs:3413 (attempt), used at real.rs:4539, :4584 and :5197 (lines at f48d2ff) in the pipeline-creation handlers. I found no catch_unwind between those entry points and cached_only, the entry points are extern "system" (I read that as: a panic leaving one ends the process), and none of the three closures reaches attempt again. If that is right, a title run today never reads the left-over state, and the change guards tests and later callers. Is that your reading too?

Not tested: Windows; AMD and Intel; the title past the start screen.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the tests and the regression pair, and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@JJAutoCompare

Copy link
Copy Markdown

PR #1960 — Shaders: restore cached-only state after panic

Tested detached commit f48d2ff8688604364df799dd76998fd1583367cb on STOR-WINLAB. The worktree was clean.

Environment

Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB, driver 32.0.101.9175. Wave range 8–32, DoublePrecisionFloatShaderOps=0, D3D12 debug layer unavailable. Rust 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.9.2609.5, unoptimized dev/test profiles with debug info disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run succeeded outside the GPU lock.
  • cargo test -p xcl gpu::recomp::dxc::cache_tests -- --nocapture reported 12 passed, 0 failed, 0 ignored. Both PR tests passed here and in the workspace suite. One catches a synthetic panic and checks that cached-only mode is cleared and deferral is off. The other checks that an inner miss reaches the outer scope and cached-only mode is restored at both scope boundaries.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc A770 lock. Across 20 libtest summaries, including doctests, the totals were 963 passed, 25 failed, 45 ignored. Cargo exited 101.
  • Failures. Of 24 library failures, 20 reported CreateComputePipelineState rejection (0x80070057), including FP64 cases. Four reported output mismatches in fused FMA overflow, implicit-LOD sampling, f16 high-half preservation, and pixel-shader wave reduction. One test-title e2e failed its dynamic depth-bias check (blue pixel where green was expected).
  • Skips. The suite log contains 22 SKIPPED lines: 17 for unavailable wave64, three for refused per-lane wave32 forms, one for driver cache disabling unavailable, and one for unavailable heap windows. These include partial skips and provide no coverage for the skipped paths.

Not tested

Retail-title smoke runs, a main baseline, other GPUs, and D3D12 debug-layer paths. XCL_SAMPLE_* was unset, so sample-dependent cases provide no retail coverage. Failure attribution to this PR remains unverified without a baseline.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1960-suite.log and published this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@luckyteagirl

Copy link
Copy Markdown

Tested

  • Exact PR head f48d2ff8688604364df799dd76998fd1583367cb on Windows 11 build 26200, Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. The focused cache tests did not exercise the RX 6800M GPU.
  • cargo test --locked -p xcl --lib -j 2 gpu::recomp::dxc::cache_tests -- --test-threads=1 --show-output: 12 passed, 0 failed, 0 ignored, no explicit skips. The two new tests passed: a caught synthetic panic restored cached-only TLS state, and a nested probe propagated its cache miss while restoring the outer scope. The panic printed by the first test is expected and caught.
  • cargo build --locked --workspace -j 2: passed.

Not tested

  • A real pipeline probe after a shader compiler panic, the full workspace suite, or paired retail title smoke. This validates the focused TLS state behavior and build on Windows; it does not establish a runtime performance or title result.

AI use

OpenAI Codex (GPT-6, exact variant not exposed in this session) reviewed the exact diff, ran the focused suite and workspace build, checked the logs, and drafted this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants