test(shader): cover fault check dedup for formatted loads and loops #17523

Merged
adam25136 merged 1 commit from upstream-pr/17523 into main 2026-11-12 23:28:17 +00:00
adam25136 commented 2026-11-08 20:12:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adam25136 on 2026-11-08T20:12:12Z.


What

The fault check dedup from #15795 has a debt entry that names two untested paths: "The formatted swizzle-selector check and loops are not covered by tests." It ends with "Closes when: a test covers the swizzle-selector check and a loop." This PR adds those cases to agc_driver_fault_check_dedup and removes that sentence and its closing condition from the entry; the rest of the entry stays.

  • Formatted loads. Program::FormatLoad emits BUFFER_LOAD_FORMAT_X (MUBUF op 0) through a GPU descriptor. Descriptor A gets a third state next to valid and reserved bit set: dst_sel_x = 2, which only the selector check of a formatted load (formattedDispatch, key 9 + components) faults on. New cases:
    • two formatted loads of A: the second loses both its descriptor check and its selector check (2 calls removed);
    • a formatted load, then a raw load of A: only the descriptor check is removed (1);
    • a raw load, then a formatted load of A: the raw load covers the descriptor check but not the selector check (1); with the reserved selector the fault is reported at the formatted load.
  • Loops. Program::Loop emits a scalar loop on s20 (s_mov_b32, s_add_u32, s_cmp_lt_u32, s_cbranch_scc1, three passes; the output does not show the pass count). These cases meet the entry's closing condition; the one dominance mutation tried is caught first by an existing case (see Tested). New cases:
    • a formatted load, and a raw load, before a loop cover the same load in its body (2 and 1 removed);
    • a check in the loop body covers the loop exit (1);
    • a check in a loop under a skipped uniform if does not cover the join (0);
    • a different descriptor in the loop: only its own later check is removed (1).
  • Each case runs with A valid and with its reserved bit set, programs with a formatted load also with the reserved selector, each with B valid and invalid. As before, the default and APS5_NO_FAULT_CHECK_DEDUP must give the same fault and output, and the removed count, the fault and the values must match the expectation. Programs holds 32 programs instead of 16.

Tested

Windows 10 Pro 22H2 (19045), i9-12900KF, NVIDIA GeForce RTX 5080 (10de:2c02, driver 621.14, 32.0.16.2114), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, this branch rebased onto main bfdb58119e:

  • ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build -R '^agc_driver_fault_check_dedup$' -V passes, with Selected GPU name=NVIDIA GeForce RTX 5080 in the log: 17 cases, the 4 with a formatted load in 6 descriptor states and the others in 4. 0.95 s, against 0.63 s for main's test.
  • With ANYPS5_ENABLE_SPIRV_TOOLS=ON (separate build, as the Linux CI job builds it) the test passes with the same removed counts: 4.74-4.83 s over three runs after a first run of 9.18 s, against 2.29-2.38 s over three runs of main's test.
  • Validation: the same test on main and on this branch, with the same two variables plus VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.367, the Khronos nightly built from 3baa2b8) and VK_LOADER_LAYERS_DISABLE=~implicit~, through ctest -V. Neither log has was not found but was requested by env var VK_INSTANCE_LAYERS or a VUID- line. A rerun on this branch with VK_LOADER_DEBUG=layer shows the layer inserted.
  • Mutations of SpirvRuntimeBuffer.cpp on this commit, each reverted afterwards:
    • the selector check keyed like the descriptor check (9u + components to 8u): the full test fails at "formatted load, same descriptor twice" with "the default removed 3 record_bda_fault calls (23 opt-out, 20 default), expected 2". "raw load does not cover the selector check of a formatted load", run alone, fails with "the default removed 2 record_bda_fault calls (23 opt-out, 21 default), expected 1". With the count check disabled it fails on the fault instead: with A's reserved selector, APS5_NO_FAULT_CHECK_DEDUP reports the fault at the formatted load (instruction=0x5c) and the default reports none.
    • faultBlockDominates returning true: the full test fails first at the existing case "check in a skipped uniform if does not cover the join". "check in a skipped loop does not cover the join", run alone, fails with "the default removed 1 record_bda_fault calls (14 opt-out, 13 default), expected 0".
  • Rebased again onto main 095ff72367 before opening: the test passes there too (0.96 s, RTX 5080); the results above are from bfdb58119e.
  • python tools/check_conventions.py --base origin/main with this title and description passed.
  • python tools/pr_overlap.py --branch probed all 1,856 open pull requests: 95 share a file or an export with this branch. Its line comparison did not finish here, so I checked those files on the heads it fetched: no open pull request changes FaultCheckDedup.cpp; the 10 that change SpirvRuntimeBuffer.cpp change none of faultCheckCovered, faultCheckKey, faultBlockDominates, PlanFaultCheckDominators or formattedDispatch; and none of the 93 that edit docs/dev/debt/shader.md changes the "Fault check dedup" entry.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 621.14, Windows 10 22H2 (19045)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5214725498 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17523). Originally posted by [adam25136](https://github.com/adam25136) on 2026-11-08T20:12:12Z. --- ### What The fault check dedup from #15795 has a debt entry that names two untested paths: "The formatted swizzle-selector check and loops are not covered by tests." It ends with "Closes when: a test covers the swizzle-selector check and a loop." This PR adds those cases to `agc_driver_fault_check_dedup` and removes that sentence and its closing condition from the entry; the rest of the entry stays. - **Formatted loads.** `Program::FormatLoad` emits `BUFFER_LOAD_FORMAT_X` (MUBUF op 0) through a GPU descriptor. Descriptor A gets a third state next to valid and reserved bit set: `dst_sel_x` = 2, which only the selector check of a formatted load (`formattedDispatch`, key `9 + components`) faults on. New cases: - two formatted loads of A: the second loses both its descriptor check and its selector check (2 calls removed); - a formatted load, then a raw load of A: only the descriptor check is removed (1); - a raw load, then a formatted load of A: the raw load covers the descriptor check but not the selector check (1); with the reserved selector the fault is reported at the formatted load. - **Loops.** `Program::Loop` emits a scalar loop on `s20` (`s_mov_b32`, `s_add_u32`, `s_cmp_lt_u32`, `s_cbranch_scc1`, three passes; the output does not show the pass count). These cases meet the entry's closing condition; the one dominance mutation tried is caught first by an existing case (see Tested). New cases: - a formatted load, and a raw load, before a loop cover the same load in its body (2 and 1 removed); - a check in the loop body covers the loop exit (1); - a check in a loop under a skipped uniform `if` does not cover the join (0); - a different descriptor in the loop: only its own later check is removed (1). - Each case runs with A valid and with its reserved bit set, programs with a formatted load also with the reserved selector, each with B valid and invalid. As before, the default and `APS5_NO_FAULT_CHECK_DEDUP` must give the same fault and output, and the removed count, the fault and the values must match the expectation. `Programs` holds 32 programs instead of 16. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 10 Pro 22H2 (19045), i9-12900KF, NVIDIA GeForce RTX 5080 (`10de:2c02`, driver 621.14, 32.0.16.2114), WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, this branch rebased onto `main` `bfdb58119e`: - `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build -R '^agc_driver_fault_check_dedup$' -V` passes, with `Selected GPU name=NVIDIA GeForce RTX 5080` in the log: 17 cases, the 4 with a formatted load in 6 descriptor states and the others in 4. 0.95 s, against 0.63 s for `main`'s test. - With `ANYPS5_ENABLE_SPIRV_TOOLS=ON` (separate build, as the Linux CI job builds it) the test passes with the same removed counts: 4.74-4.83 s over three runs after a first run of 9.18 s, against 2.29-2.38 s over three runs of `main`'s test. - Validation: the same test on `main` and on this branch, with the same two variables plus `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (1.4.367, the Khronos nightly built from `3baa2b8`) and `VK_LOADER_LAYERS_DISABLE=~implicit~`, through `ctest -V`. Neither log has `was not found but was requested by env var VK_INSTANCE_LAYERS` or a `VUID-` line. A rerun on this branch with `VK_LOADER_DEBUG=layer` shows the layer inserted. - Mutations of `SpirvRuntimeBuffer.cpp` on this commit, each reverted afterwards: - the selector check keyed like the descriptor check (`9u + components` to `8u`): the full test fails at "formatted load, same descriptor twice" with "the default removed 3 record_bda_fault calls (23 opt-out, 20 default), expected 2". "raw load does not cover the selector check of a formatted load", run alone, fails with "the default removed 2 record_bda_fault calls (23 opt-out, 21 default), expected 1". With the count check disabled it fails on the fault instead: with A's reserved selector, `APS5_NO_FAULT_CHECK_DEDUP` reports the fault at the formatted load (`instruction=0x5c`) and the default reports none. - `faultBlockDominates` returning true: the full test fails first at the existing case "check in a skipped uniform if does not cover the join". "check in a skipped loop does not cover the join", run alone, fails with "the default removed 1 record_bda_fault calls (14 opt-out, 13 default), expected 0". - Rebased again onto `main` `095ff72367` before opening: the test passes there too (0.96 s, RTX 5080); the results above are from `bfdb58119e`. - `python tools/check_conventions.py --base origin/main` with this title and description passed. - `python tools/pr_overlap.py --branch` probed all 1,856 open pull requests: 95 share a file or an export with this branch. Its line comparison did not finish here, so I checked those files on the heads it fetched: no open pull request changes `FaultCheckDedup.cpp`; the 10 that change `SpirvRuntimeBuffer.cpp` change none of `faultCheckCovered`, `faultCheckKey`, `faultBlockDominates`, `PlanFaultCheckDominators` or `formattedDispatch`; and none of the 93 that edit `docs/dev/debt/shader.md` changes the "Fault check dedup" entry. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA GeForce RTX 5080, driver 621.14, Windows 10 22H2 (19045) - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
boykopovar/AnyPS5!17523
No description provided.