fix(libSceAgcDriver): skip depth and stencil tests whose plane is absent #453

Merged
SP4C3B4R-8 merged 1 commit from upstream-pr/453 into main 2026-10-04 22:41:27 +00:00
SP4C3B4R-8 commented 2026-10-03 11:18:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-03T11:18:52Z.


What

A draw can enable the depth or stencil test in DB_DEPTH_CONTROL while DB_Z_INFO / DB_STENCIL_INFO declare the corresponding plane absent (format 0 / INVALID), for example a stencil test with ALWAYS and KEEP on a depth-only surface. Such a draw was rejected with "stencil test without a stencil plane" (or "depth test without a depth plane"), so none of its depth writes happened either.

The hardware behaves as if the test of an absent plane were disabled. decodeDepth now clears the test bits of an absent plane instead of throwing, and a draw whose planes are both declared absent is treated like a depth pass-through instead of being rejected by DrawRejection. A depth or stencil register that is missing entirely still goes through the existing checks.

Tested

Windows 11, MinGW-w64 GCC 15.2.0. agc_driver_graphics_tests and agc_driver_pm4_tests pass on this branch alone; Graphics.cpp checks that tests on two absent planes are dropped and not rejected, and that a depth test without a depth plane is dropped while the stencil test of a present stencil plane is kept. With a retail title, about 13k draws per minute that write the main depth buffer are no longer skipped.

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 (Claude). I reviewed and take responsibility for every line.

🤖 Generated with Claude Code

https://claude.ai/code/session_018m6Ad8zkQKPKZmyUQK9vfE

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4726152149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/453). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-03T11:18:52Z. --- ### What A draw can enable the depth or stencil test in `DB_DEPTH_CONTROL` while `DB_Z_INFO` / `DB_STENCIL_INFO` declare the corresponding plane absent (format 0 / `INVALID`), for example a stencil test with `ALWAYS` and `KEEP` on a depth-only surface. Such a draw was rejected with "stencil test without a stencil plane" (or "depth test without a depth plane"), so none of its depth writes happened either. The hardware behaves as if the test of an absent plane were disabled. `decodeDepth` now clears the test bits of an absent plane instead of throwing, and a draw whose planes are both declared absent is treated like a depth pass-through instead of being rejected by `DrawRejection`. A depth or stencil register that is missing entirely still goes through the existing checks. ### Tested Windows 11, MinGW-w64 GCC 15.2.0. `agc_driver_graphics_tests` and `agc_driver_pm4_tests` pass on this branch alone; `Graphics.cpp` checks that tests on two absent planes are dropped and not rejected, and that a depth test without a depth plane is dropped while the stencil test of a present stencil plane is kept. With a retail title, about 13k draws per minute that write the main depth buffer are no longer skipped. ### 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 (Claude). I reviewed and take responsibility for every line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018m6Ad8zkQKPKZmyUQK9vfE
oneandonlydean commented 2026-10-04 09:57:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T09:57:22Z.


This passed my PPSA21564 check, but it now conflicts with main after #376 and #294 merged. Could you rebase? Then it's ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5978752509 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/453#issuecomment-5978752509). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T09:57:22Z. --- This passed my PPSA21564 check, but it now conflicts with main after #376 and #294 merged. Could you rebase? Then it's ready to merge from my side.
SP4C3B4R-8 commented 2026-10-04 10:21:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-04T10:21:26Z.


Rebased onto main (2cf901bc), now 48ebf319. The only conflict was in DrawRejection after the depth-bounds change: I kept main's handling (0xb mask, "depth bounds without a depth surface") and only added the absent-planes check, which still applies to the depth and stencil tests (word & 3). Graphics and PM4 tests pass locally. Thanks for checking it against PPSA21564.

Written with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5978979674 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/453#issuecomment-5978979674). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-04T10:21:26Z. --- Rebased onto main (2cf901bc), now 48ebf319. The only conflict was in `DrawRejection` after the depth-bounds change: I kept main's handling (`0xb` mask, "depth bounds without a depth surface") and only added the absent-planes check, which still applies to the depth and stencil tests (`word & 3`). Graphics and PM4 tests pass locally. Thanks for checking it against PPSA21564. Written with AI assistance (Claude Code).
oneandonlydean commented 2026-10-04 22:38:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:38:04Z.


Thanks for the rebase. Keeping main's 0xb mask and the depth bounds rule is right, and the commit is otherwise unchanged. My PPSA21564 check ran with the same rule (tests on an absent depth or stencil plane are dropped) and your test, and the full ctest passes here on current main. Ready to merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985219646 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/453#issuecomment-5985219646). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T22:38:04Z. --- Thanks for the rebase. Keeping main's `0xb` mask and the depth bounds rule is right, and the commit is otherwise unchanged. My PPSA21564 check ran with the same rule (tests on an absent depth or stencil plane are dropped) and your test, and the full ctest passes here on current main. Ready to merge.
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!453
No description provided.