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

Merged
LuisAguilarDev merged 1 commit from upstream-pr/8099 into main 2026-10-22 16:43:37 +00:00
LuisAguilarDev commented 2026-10-19 21:36:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisAguilarDev on 2026-10-19T21:36:57Z.


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

Replaces #7720, which GitHub does not allow to reopen after the open PR limit closed it. Same branch and commit; the discussion is there.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4927760831 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8099). Originally posted by [LuisAguilarDev](https://github.com/LuisAguilarDev) on 2026-10-19T21:36:57Z. --- ### 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) Replaces #7720, which GitHub does not allow to reopen after the open PR limit closed it. Same branch and commit; the discussion is there.
slick-daddy commented 2026-10-19 22:14:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slick-daddy on 2026-10-19T22:14:23Z.


Rebase please.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278546118 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8099#issuecomment-6278546118). Originally posted by [slick-daddy](https://github.com/slick-daddy) on 2026-10-19T22:14:23Z. --- Rebase please.
savvaniss commented 2026-10-20 02:37:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-20T02:37:53Z.


Another title needs the same rule. Trivial Pursuit Live! (CUSA03312, Hasbro Family Fun Pack, PS4) stops at character selection on the PS4 path of #6977 with AGC graphics: stencil clear requires a writable stencil plane. Its Unity clear sets both clear bits on a Z_32_FLOAT depth target whose DB_STENCIL_INFO format is invalid.

I had written the same change before I found this PR: drop the clear in decodeDepth and DrawRejection when there is no stencil plane, and keep the read-only throw. I'm not opening a second PR. With the rule applied to the PS4 build, the title gets past that screen and renders the selected character.

On Windows 11 (WinLibs GCC 15.2), agc_driver_graphics passes on main and with the rule, on an RX 9070 XT and a UHD 770, under VK_LAYER_KHRONOS_validation with no VUID- lines. That run used my copy of the change, not this branch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6282038813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8099#issuecomment-6282038813). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-20T02:37:53Z. --- Another title needs the same rule. Trivial Pursuit Live! (CUSA03312, Hasbro Family Fun Pack, PS4) stops at character selection on the PS4 path of #6977 with `AGC graphics: stencil clear requires a writable stencil plane`. Its Unity clear sets both clear bits on a `Z_32_FLOAT` depth target whose `DB_STENCIL_INFO` format is invalid. I had written the same change before I found this PR: drop the clear in `decodeDepth` and `DrawRejection` when there is no stencil plane, and keep the read-only throw. I'm not opening a second PR. With the rule applied to the PS4 build, the title gets past that screen and renders the selected character. On Windows 11 (WinLibs GCC 15.2), `agc_driver_graphics` passes on `main` and with the rule, on an RX 9070 XT and a UHD 770, under `VK_LAYER_KHRONOS_validation` with no `VUID-` lines. That run used my copy of the change, not this branch.
TheSovietWaffle commented 2026-10-20 07:40:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T07:40:30Z.


AMD data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head 342252f52: agc_driver_graphics passes 3 of 3 on both GPUs. (The head is about 1,240 commits behind current main; I tested it as is, not rebased.)

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285945942 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8099#issuecomment-6285945942). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-20T07:40:30Z. --- AMD data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (`1002:164e`, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head `342252f52`: `agc_driver_graphics` passes 3 of 3 on both GPUs. (The head is about 1,240 commits behind current `main`; I tested it as is, not rebased.) AI-assisted: yes (Claude Code).
blawesom commented 2026-10-20 07:52:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T07:52:33Z.


Rebase handoff — rebased onto current main (3fd1cc393, authorship unchanged). One debt-entry conflict with main's newer "Color export type" entry, unioned (both entries kept).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; 1672/1675 — green apart from the three known main failures (#7584 BDA, #7784 guest-memory, tessellation), none from this PR; conventions pass.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/8099
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is ecc8a5029.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286164162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8099#issuecomment-6286164162). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-20T07:52:33Z. --- **Rebase handoff** — rebased onto current `main` (`3fd1cc393`, authorship unchanged). One debt-entry conflict with `main`'s newer "Color export type" entry, unioned (both entries kept). Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): builds; **1672/1675 — green apart from the three known `main` failures** (#7584 BDA, #7784 guest-memory, tessellation), none from this PR; conventions pass. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/8099 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `ecc8a5029`.
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!8099
No description provided.