GPU: fail closed on unresolved control flow and errored FSSMs in effects #2352

Manually merged
github merged 1 commit from gh-pr/2352/head into gh-pr/2352/base 2026-11-26 05:28:38 +00:00
Owner

@⁠Decodere on GitHub · 2026-11-25 16:19 UTC · original
Decodere:fix-2176-effects-fail-closed → main · +108 −5 · 1 files · 1 commits · merged 2026-11-25 18:17 UTC

Part of #2088
Part of #1452

Follow-up to #2176 (crates/xcl/src/gpu/effects.rs).

gpu::effects::big_and_image_only allows hle::d3d12x::pso_async to skip waiting on a big compute pipeline while the driver compiles it only when effects::of proves the shader writes nothing outside images. This PR closes three fail-open gaps in effects::of and effects::compute_code so unrecognized or incomplete control flow and errored FSSM containers never misclassify a memory-writing compute shader as image-only.

What is in it

  • gpu::effects::of (crates/xcl/src/gpu/effects.rs): decode into Vec<Decoded>, track any rdna2::F_TERMINATOR (S_ENDPGM, S_ENDPGM_SAVED, S_ENDPGM_ORDERED_PS_DONE), stop on trailing decode errors or S_CODE_END padding only after a terminator, require both a decoded terminator and a non-fallthrough tail (F_TERMINATOR, S_BRANCH, or resolved far_target), run rdna2::resolve_far_jumps(&mut insts), and return None if any F_BRANCH | F_INDIRECT instruction lacks a resolved rdna2::branch_target pointing to a decoded instruction PC.
  • gpu::effects::compute_code (crates/xcl/src/gpu/effects.rs): fail closed (None) when the matched hardware-CS (hw == 6) FSSM has f.error.is_some() (e.g. XBCH rsize mismatch where xbox::parse_xbch still calls analyze_fssm and populates f.programs).
  • gpu::effects::tests (crates/xcl/src/gpu/effects.rs): 3 pure-CPU unit tests covering early-S_ENDPGM undecodable-gap branch targets, tail fallthrough into undecoded bytes, missing terminators, S_ENDPGM_SAVED + trailing data, unresolved S_SETPC_B64 / S_SWAPPC_B64, out-of-range S_BRANCH / S_CALL_B64, valid and out-of-range resolved far jumps with trailing S_CODE_END padding, and XBCH rsize-errored FSSMs in big_and_image_only.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 build 26200, rustc 1.100.0, DXC 1.9.2609.5, release profile (--release).
  • Failing-first (before fix): cargo test --release -p xcl --lib gpu::effects::tests:: -- --nocapture: 4 passed, 3 failed (all 3 new tests failed on origin/main).
  • Targeted unit tests (after fix): cargo test --release -p xcl --lib gpu::effects::tests:: -- --nocapture: 7 passed, 0 failed, 0 ignored (0.01 s).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1275 passed, 0 failed, 46 ignored across 23 test binaries (28 pre-existing SKIPPED lines: 21 no wave64 on RTX 4060, 3 per-lane wave32 refused, 2 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in gpu::effects::tests).

Regression run

main:

xcl-smoke v1
commit: 082944135cd2b96288470a595861fa608eee08dc
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14013 MB

PR:

xcl-smoke v1
commit: 440e80211d54443756b8aade8111517db50f7475
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1583 (PresentX 1584)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13971 MB

Not tested

  • AMD / native wave64 hardware and D3D12 debug-layer test subsets (skipped on this RTX 4060 / non-debug-layer host; gpu::effects is pure-CPU static RDNA2/FSSM analysis).
  • Retail titles other than title: 29640639 or wild XBCH containers with mismatched rsize headers (covered synthetically via xbox::tests::sample / xbox::tests::fssm).

AI use

  • Google Antigravity (Gemini 4 Neon) — audited gpu/effects.rs, gpu/rdna2.rs, and gpu/xbox.rs, wrote the fail-closed logic and failing-first unit tests, and ran the workspace and paired smoke tests.
**@⁠Decodere** on GitHub · 2026-11-25 16:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2352) `Decodere:fix-2176-effects-fail-closed` → `main` · +108 −5 · 1 files · 1 commits · merged 2026-11-25 18:17 UTC Part of #2088 Part of #1452 Follow-up to #2176 (`crates/xcl/src/gpu/effects.rs`). `gpu::effects::big_and_image_only` allows `hle::d3d12x::pso_async` to skip waiting on a big compute pipeline while the driver compiles it only when `effects::of` proves the shader writes nothing outside images. This PR closes three fail-open gaps in `effects::of` and `effects::compute_code` so unrecognized or incomplete control flow and errored FSSM containers never misclassify a memory-writing compute shader as image-only. **What is in it** - `gpu::effects::of` (`crates/xcl/src/gpu/effects.rs`): decode into `Vec<Decoded>`, track any `rdna2::F_TERMINATOR` (`S_ENDPGM`, `S_ENDPGM_SAVED`, `S_ENDPGM_ORDERED_PS_DONE`), stop on trailing decode errors or `S_CODE_END` padding only after a terminator, require both a decoded terminator and a non-fallthrough tail (`F_TERMINATOR`, `S_BRANCH`, or resolved `far_target`), run `rdna2::resolve_far_jumps(&mut insts)`, and return `None` if any `F_BRANCH | F_INDIRECT` instruction lacks a resolved `rdna2::branch_target` pointing to a decoded instruction PC. - `gpu::effects::compute_code` (`crates/xcl/src/gpu/effects.rs`): fail closed (`None`) when the matched hardware-CS (`hw == 6`) FSSM has `f.error.is_some()` (e.g. XBCH `rsize` mismatch where `xbox::parse_xbch` still calls `analyze_fssm` and populates `f.programs`). - `gpu::effects::tests` (`crates/xcl/src/gpu/effects.rs`): 3 pure-CPU unit tests covering early-`S_ENDPGM` undecodable-gap branch targets, tail fallthrough into undecoded bytes, missing terminators, `S_ENDPGM_SAVED` + trailing data, unresolved `S_SETPC_B64` / `S_SWAPPC_B64`, out-of-range `S_BRANCH` / `S_CALL_B64`, valid and out-of-range resolved far jumps with trailing `S_CODE_END` padding, and XBCH `rsize`-errored FSSMs in `big_and_image_only`. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 build 26200, `rustc 1.100.0`, DXC `1.9.2609.5`, release profile (`--release`). - Failing-first (before fix): `cargo test --release -p xcl --lib gpu::effects::tests:: -- --nocapture`: 4 passed, 3 failed (all 3 new tests failed on `origin/main`). - Targeted unit tests (after fix): `cargo test --release -p xcl --lib gpu::effects::tests:: -- --nocapture`: 7 passed, 0 failed, 0 ignored (`0.01 s`). - `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture`: 1275 passed, 0 failed, 46 ignored across 23 test binaries (28 pre-existing `SKIPPED` lines: 21 no wave64 on RTX 4060, 3 per-lane wave32 refused, 2 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in `gpu::effects::tests`). **Regression run** main: ``` xcl-smoke v1 commit: 082944135cd2b96288470a595861fa608eee08dc gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1580 (PresentX 1580) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14013 MB ``` PR: ``` xcl-smoke v1 commit: 440e80211d54443756b8aade8111517db50f7475 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1583 (PresentX 1584) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13971 MB ``` **Not tested** - AMD / native wave64 hardware and D3D12 debug-layer test subsets (skipped on this RTX 4060 / non-debug-layer host; `gpu::effects` is pure-CPU static RDNA2/FSSM analysis). - Retail titles other than `title: 29640639` or wild XBCH containers with mismatched `rsize` headers (covered synthetically via `xbox::tests::sample` / `xbox::tests::fssm`). **AI use** - Google Antigravity (Gemini 4 Neon) — audited `gpu/effects.rs`, `gpu/rdna2.rs`, and `gpu/xbox.rs`, wrote the fail-closed logic and failing-first unit tests, and ran the workspace and paired smoke tests.
`gpu::effects::of` previously stopped scanning on the first undecodable
dword after any `S_ENDPGM`, accepted programs without a terminator or
whose decoded tail could fall through into undecoded bytes, and ignored
indirect jumps and out-of-range branches. If a live branch jumped past
an early `S_ENDPGM` and undecodable gap (or an indirect/out-of-range
transfer targeted code outside the decoded slice), memory writes beyond
the stopped decode point were missed and `big_and_image_only` could
misclassify a memory-writing compute shader as image-only.

`compute_code` also accepted hardware-CS FSSM entries whose `f.error`
was populated (e.g. XBCH `rsize` mismatch, where `xbox::parse_xbch`
records `f.error` and still populates `f.programs`).

Resolve static far jumps (`rdna2::resolve_far_jumps`), require a
decoded `F_TERMINATOR` and a non-fallthrough tail, fail closed (`None`)
on any unresolved indirect transfer or branch targeting outside the
decoded instruction PCs, treat trailing `S_CODE_END` after a terminator
as padding, and reject `f.error.is_some()` in `compute_code`.

Part of #2088
Part of #1452

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:28:38 +00:00
github manually merged commit 440e80211d into gh-pr/2352/base 2026-11-26 05:28:38 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 16:49 UTC · original

Tested: current PR head merged onto current origin/main (clean, 440e8021), 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).

No Linux/Wine report in the thread yet; adding one.

  • First suite attempt died mid-run with a one-off device removal (radv/amdgpu: The CS has been rejected (-14), D3D12 device removed: 0x887a0005) before any test verdict. dmesg shows nothing beyond the usual amdgpu fini chatter, no ring faults. Clean rerun immediately after, so disclosed as a rig event, not a result.
  • gpu_ suite (rerun): 144 passed / 3 failed / 1 ignored, exactly this 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). No delta from the PR.
  • All three new fail-closed tests (outside the gpu_ filter), targeted in one run: branch_past_early_end_gap_and_fallthrough_say_nothing, errored_fssm_is_rejected_by_big_and_image_only, unresolved_indirect_and_oob_branches_fail_closed_while_far_jump_passes: 3 passed; 0 failed.

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.

**@⁠SlopTart** on GitHub · 2026-11-25 16:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2352#issuecomment-7168596699) **Tested**: current PR head merged onto current `origin/main` (clean, `440e8021`), 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). No Linux/Wine report in the thread yet; adding one. - First suite attempt died mid-run with a one-off device removal (`radv/amdgpu: The CS has been rejected (-14)`, `D3D12 device removed: 0x887a0005`) before any test verdict. dmesg shows nothing beyond the usual amdgpu fini chatter, no ring faults. Clean rerun immediately after, so disclosed as a rig event, not a result. - `gpu_` suite (rerun): 144 passed / 3 failed / 1 ignored, exactly this 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`). No delta from the PR. - All three new fail-closed tests (outside the `gpu_` filter), targeted in one run: `branch_past_early_end_gap_and_fallthrough_say_nothing`, `errored_fssm_is_rejected_by_big_and_image_only`, `unresolved_indirect_and_oob_branches_fail_closed_while_far_jump_passes`: `3 passed; 0 failed`. **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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 18:37 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-25 18:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/2352#issuecomment-7171166137) 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!
Author
Owner

@⁠SashaTun on GitHub · 2026-11-25 18:33 UTC · original · edited 2026-11-25 18:43 UTC

Test report on an NVIDIA card (Windows, retail title).

Tested

  • Commit: 440e80211d54443756b8aade8111517db50f7475 (fix-2176-effects-fail-closed), clean checkout of the PR head, no uncommitted changes.

  • Hardware: NVIDIA GeForce RTX 5060 (8 GB), driver 32.0.16.2101; 31.9 GB RAM; Windows 11 build 26200 x64.

  • Toolchain: Rust 1.100.0 (stable-x86_64-pc-windows-msvc); DXC 1.9 (Windows SDK 10.0.26100.0); release profile; no XCL_SAMPLE_* variables.

  • Command: cargo test --release --workspace --no-fail-fast -- --test-threads=4
    → 1271 passed, 4 failed, 46 ignored; 28 SKIPPED lines (21 of them no wave64 — this card runs 32-wide waves only).

  • The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0,1,2,3}, all with the same error: CreateComputePipelineState: 0x8007000E (out of memory) — the 8 GB VRAM wall. The same 4 failures occur on main 68a284a on this card, so they are not from this PR.

  • Regression run on a retail title (scripts/smoke.ps1, 60 s, same title, same duration, same card, both runs from a clean data directory):

    xcl-smoke v1
    commit: 68a284a596bd558b6bd9db6eedda6d6aa178c360
    gpu: NVIDIA GeForce RTX 5060
    title: 3c290c16
    seconds: 60
    exit: 0x0
    frames shown: 912 (PresentX 912)
    presents per 2 s (last 3): 42 41 42
    device removals: 0
    crashes: 0
    peak commit: 15022 MB
    
    xcl-smoke v1
    commit: 440e80211d54443756b8aade8111517db50f7475
    gpu: NVIDIA GeForce RTX 5060
    title: 3c290c16
    seconds: 60
    exit: 0x0
    frames shown: 973 (PresentX 973)
    presents per 2 s (last 3): 60 60 60
    device removals: 0
    crashes: 0
    peak commit: 14728 MB
    

    The PR's run shows no device removal and no crash, 973 frames against main's 912 (≥ 80 %) and a peak commit of 14 728 MB against main's 15 022 MB (≤ 125 %). A second run of the same head commit gave 989 frames and a peak commit of 14 553 MB, the same shape.

Not tested

  • AMD cards (none here) and wave64-only GPUs: this card runs 32-wide waves, so the wave64 tests skip and the split-wave64 path is the one that runs.
  • The title's world load: the 60 s run stays in the menus (the title's menu rate is 30 fps) and does not reach the effects path this PR changes, so the report is a regression check, not a check of the PR's own behaviour. The PR's unit tests cover the decoder paths it touches.
  • The PR branch is 28 commits behind main, so the tree tested here is the branch head as it stands. main has one further failure on this card that this branch does not contain: gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, a test added after the branch point. It is not card-specific - main's own CI fails on it too - and I am reporting it separately.
  • The menus' frame rate differs between the two runs (21 fps on main, 30 fps on the PR head). That is not attributed to this PR — it only changes the effects decoder, and the branch is older than main — but I could not measure the world load, so I cannot say where the difference comes from.

AI use

MiniMax Code (MiniMax-M3.1-Flash) built the commits, ran the test suite and the smoke runs, and wrote this report from the real output.

**@⁠SashaTun** on GitHub · 2026-11-25 18:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2352#issuecomment-7171070461) · edited 2026-11-25 18:43 UTC **Test report on an NVIDIA card (Windows, retail title).** **Tested** - **Commit:** `440e80211d54443756b8aade8111517db50f7475` (`fix-2176-effects-fail-closed`), clean checkout of the PR head, no uncommitted changes. - **Hardware:** NVIDIA GeForce RTX 5060 (8 GB), driver `32.0.16.2101`; 31.9 GB RAM; Windows 11 build 26200 x64. - **Toolchain:** Rust `1.100.0` (`stable-x86_64-pc-windows-msvc`); DXC 1.9 (Windows SDK `10.0.26100.0`); release profile; no `XCL_SAMPLE_*` variables. - **Command:** `cargo test --release --workspace --no-fail-fast -- --test-threads=4` → **1271 passed, 4 failed, 46 ignored**; 28 `SKIPPED` lines (21 of them `no wave64` — this card runs 32-wide waves only). - **The 4 failures** are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0,1,2,3}`, all with the same error: `CreateComputePipelineState: 0x8007000E` (out of memory) — the 8 GB VRAM wall. **The same 4 failures occur on `main` `68a284a` on this card**, so they are not from this PR. - **Regression run on a retail title** (`scripts/smoke.ps1`, 60 s, same title, same duration, same card, both runs from a clean data directory): `````` xcl-smoke v1 commit: 68a284a596bd558b6bd9db6eedda6d6aa178c360 gpu: NVIDIA GeForce RTX 5060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 912 (PresentX 912) presents per 2 s (last 3): 42 41 42 device removals: 0 crashes: 0 peak commit: 15022 MB `````` `````` xcl-smoke v1 commit: 440e80211d54443756b8aade8111517db50f7475 gpu: NVIDIA GeForce RTX 5060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 973 (PresentX 973) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14728 MB `````` The PR's run shows no device removal and no crash, 973 frames against `main`'s 912 (≥ 80 %) and a peak commit of 14 728 MB against `main`'s 15 022 MB (≤ 125 %). A second run of the same head commit gave 989 frames and a peak commit of 14 553 MB, the same shape. **Not tested** - **AMD cards** (none here) and wave64-only GPUs: this card runs 32-wide waves, so the wave64 tests skip and the split-wave64 path is the one that runs. - **The title's world load:** the 60 s run stays in the menus (the title's menu rate is 30 fps) and does not reach the effects path this PR changes, so the report is a regression check, not a check of the PR's own behaviour. The PR's unit tests cover the decoder paths it touches. - The PR branch is 28 commits behind `main`, so the tree tested here is the branch head as it stands. `main` has one further failure on this card that this branch does not contain: `gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, a test added after the branch point. It is not card-specific - `main`'s own CI fails on it too - and I am reporting it separately. - The menus' frame rate differs between the two runs (21 fps on `main`, 30 fps on the PR head). That is not attributed to this PR — it only changes the effects decoder, and the branch is older than `main` — but I could not measure the world load, so I cannot say where the difference comes from. **AI use** MiniMax Code (MiniMax-M3.1-Flash) built the commits, ran the test suite and the smoke runs, and wrote this report from the real output.
This discussion has been locked. Commenting is limited to contributors.
No description provided.