perf(agc): remember shader validation failures and reject repeats without throwing #192

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/192 into main 2026-09-30 19:12:59 +00:00
MichonGoddijn231849 commented 2026-09-30 16:46:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-09-30T16:46:30Z.


What

A draw whose shaders fail ValidateShaders is skipped by throwing, and the unwinding costs about 1–1.5 ms per throw on this toolchain (LibcUnwind decodes the frames). A title that keeps issuing the same rejected combination pays that for every draw.

  • CachedFragmentOutputs already remembers the fragment outputs of a validated configuration, keyed by the stages' variants, push constant placement, vertex attribute shapes and the state fields validation checks. Its key is now built by ValidationKey.
  • A configuration that fails validation is remembered under the same key, with its message; the first failure still throws as before.
  • The driver asks KnownDrawRejection before a (non-recipe) draw. A known failure returns DrawVerdict::Rejected with the same message, so the skip is reported as before, without an exception.
  • The memo is bounded like the success memo (cleared past 1024 entries), and APS5_NO_VALIDATE_CACHE=1 still disables both.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • GTA V (PPSA04264) with #167 and #186, in the Story Mode world. Most rejections are fragment shaders declaring DepthReplacing, about 5000 draws per 10 s.
    • Before: those draws cost about 1.4 ms each in unwinding, and the game ran at 0.5–1 fps.
    • With this change: about 2–3 fps. The skip reports are unchanged.
  • ctest: the same results as plain main on this machine. The failures are identical there: agc_driver* exit with 0xc0000139 at startup, and empty_tls, tls_function_coverage, windows_gui and guest_intel_trampolines fail.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4693402555 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/192). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-09-30T16:46:30Z. --- ### What A draw whose shaders fail `ValidateShaders` is skipped by throwing, and the unwinding costs about 1–1.5 ms per throw on this toolchain (`LibcUnwind` decodes the frames). A title that keeps issuing the same rejected combination pays that for every draw. - `CachedFragmentOutputs` already remembers the fragment outputs of a validated configuration, keyed by the stages' variants, push constant placement, vertex attribute shapes and the state fields validation checks. Its key is now built by `ValidationKey`. - A configuration that fails validation is remembered under the same key, with its message; the first failure still throws as before. - The driver asks `KnownDrawRejection` before a (non-recipe) draw. A known failure returns `DrawVerdict::Rejected` with the same message, so the skip is reported as before, without an exception. - The memo is bounded like the success memo (cleared past 1024 entries), and `APS5_NO_VALIDATE_CACHE=1` still disables both. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - GTA V (PPSA04264) with #167 and #186, in the Story Mode world. Most rejections are fragment shaders declaring `DepthReplacing`, about 5000 draws per 10 s. - Before: those draws cost about 1.4 ms each in unwinding, and the game ran at 0.5–1 fps. - With this change: about 2–3 fps. The skip reports are unchanged. - `ctest`: the same results as plain `main` on this machine. The failures are identical there: `agc_driver*` exit with `0xc0000139` at startup, and `empty_tls`, `tls_function_coverage`, `windows_gui` and `guest_intel_trampolines` fail. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 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!192
No description provided.