fix(agc): ignore a stencil clear on a target without a stencil plane #7720

Closed
LuisAguilarDev wants to merge 1 commit from upstream-pr/7720 into main
LuisAguilarDev commented 2026-10-19 02:46:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisAguilarDev on 2026-10-19T02:46:56Z.


What

Dragon Ball Xenoverse 2 (PPSA08587) stops at its first frames:

[videoout] presentation failed: AGC graphics: stencil clear requires a writable stencil plane

The draw clears depth and stencil together on a depth-only D16 target:

Register Value Meaning
DB_RENDER_CONTROL 0x00000003 DEPTH_CLEAR_ENABLE and STENCIL_CLEAR_ENABLE
DB_DEPTH_VIEW 0x00000000 neither plane read-only
DB_Z_INFO 0xa0000181 format Z_16
DB_STENCIL_INFO 0x20000180 format STENCIL_INVALID, no stencil plane

decodeDepth and DrawRejection in State.cpp refuse a stencil clear when the stencil plane is absent or read-only. A target without a stencil plane has no storage for the clear to write, so the stencil clear is now dropped there; the depth clear and colour writes proceed. A stencil clear on a read-only stencil plane still throws. The skip for draws with no depth surface bound (depthPlanesAbsent) is unchanged; it does not cover this case, because the depth plane is present.

Sources (inferred, no source states the hardware behaviour):

  • AMD PAL gfx9RsrcProcMgr.cpp builds the clear mask from the image's planes, so it never sets STENCIL_CLEAR_ENABLE on a depth-only image.
  • radeonsi si_clear.c drops PIPE_CLEAR_STENCIL when the format has no stencil.
  • shadPS4 vk_rasterizer.cpp applies the stencil clear only when StencilValid(), which is false for an invalid stencil format.

The console was not measured; this is recorded under Functional in docs/dev/debt/libSceAgcDriver.md.

Tested

  • Windows 11, MinGW-w64 GCC, Release, NVIDIA GeForce RTX 3070 Ti:
    • agc_driver_graphics passes in 7.5 s. The test that asserted the rejection of a stencil clear without a stencil plane now expects the depth clear alone and an empty precheck; without the State.cpp change it fails with stencil clear requires a writable stencil plane.
    • agc_driver_bda_device (#7584) and agc_driver_image_table_reuse (#7710) fail the same way with and without this change.
    • tools/check_conventions.py --base upstream/main and git diff --check pass.
  • PPSA08587, RTX 3070 Ti: with this change and the missing imports provided locally, the title no longer stops at this clear; it reaches gameplay.

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: PPSA08587 #6591
  • GPUs tested: NVIDIA GeForce RTX 3070 Ti, driver 610.88, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4915092017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7720). Originally posted by [LuisAguilarDev](https://github.com/LuisAguilarDev) on 2026-10-19T02:46:56Z. --- ### What Dragon Ball Xenoverse 2 (PPSA08587) stops at its first frames: ``` [videoout] presentation failed: AGC graphics: stencil clear requires a writable stencil plane ``` The draw clears depth and stencil together on a depth-only D16 target: | Register | Value | Meaning | |---|---|---| | `DB_RENDER_CONTROL` | `0x00000003` | `DEPTH_CLEAR_ENABLE` and `STENCIL_CLEAR_ENABLE` | | `DB_DEPTH_VIEW` | `0x00000000` | neither plane read-only | | `DB_Z_INFO` | `0xa0000181` | format `Z_16` | | `DB_STENCIL_INFO` | `0x20000180` | format `STENCIL_INVALID`, no stencil plane | `decodeDepth` and `DrawRejection` in `State.cpp` refuse a stencil clear when the stencil plane is absent or read-only. A target without a stencil plane has no storage for the clear to write, so the stencil clear is now dropped there; the depth clear and colour writes proceed. A stencil clear on a read-only stencil plane still throws. The skip for draws with no depth surface bound (`depthPlanesAbsent`) is unchanged; it does not cover this case, because the depth plane is present. Sources (inferred, no source states the hardware behaviour): - AMD PAL [`gfx9RsrcProcMgr.cpp`](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32/src/core/hw/gfxip/rpm/gfx9/gfx9RsrcProcMgr.cpp) builds the clear mask from the image's planes, so it never sets `STENCIL_CLEAR_ENABLE` on a depth-only image. - radeonsi `si_clear.c` drops `PIPE_CLEAR_STENCIL` when the format has no stencil. - shadPS4 `vk_rasterizer.cpp` applies the stencil clear only when `StencilValid()`, which is false for an invalid stencil format. The console was not measured; this is recorded under Functional in `docs/dev/debt/libSceAgcDriver.md`. ### Tested - Windows 11, MinGW-w64 GCC, Release, NVIDIA GeForce RTX 3070 Ti: - `agc_driver_graphics` passes in 7.5 s. The test that asserted the rejection of a stencil clear without a stencil plane now expects the depth clear alone and an empty precheck; without the `State.cpp` change it fails with `stencil clear requires a writable stencil plane`. - `agc_driver_bda_device` (#7584) and `agc_driver_image_table_reuse` (#7710) fail the same way with and without this change. - `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. - PPSA08587, RTX 3070 Ti: with this change and the missing imports provided locally, the title no longer stops at this clear; it reaches gameplay. ### 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 under Silent stubs in their library's technical 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: none - [x] Fixes: none - [x] Unblocks: PPSA08587 #6591 - [x] GPUs tested: NVIDIA GeForce RTX 3070 Ti, driver 610.88, Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-19 02:47:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T02:47:14Z.


Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6258564202 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7720#issuecomment-6258564202). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T02:47:14Z. --- Thank you for your contribution! Authors with no pull requests merged into `main` can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

Pull request closed

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!7720
No description provided.