fix(agc): preserve ClearMRT color writes and validate stencil clears #1534
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1534"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-08T11:27:33Z.
What
Proposed replacement for #1479: retain the ClearMRT color outputs while clearing stencil, with writable-plane validation and regression coverage. The original implementation is included as a separate commit with Aryan Sharma's authorship preserved. This PR is standalone and does not require #1479 to merge first.
DB_RENDER_CONTROL = 0x22setsSTENCIL_CLEAR_ENABLE, not depth clear. Rejecting the whole draw drops its color writes as well. In God of War Sons of Sparta (PPSA28997), the uncleared scene target accumulates the previous frames' lighting and develops growing white highlights.Rasterize the existing draw with
ALWAYScomparison and stencilREPLACEon both faces, usingDB_STENCIL_CLEAR. This retains color exports, write masks and scissor coverage. No extra GPU pass, allocation or synchronization is introduced.Compared with #1479:
Register definitions: AMD PAL DB_RENDER_CONTROL; clear/read-only view setup: AMD PAL DepthStencilView::InitRegistersCommon. Vulkan replacement uses the reference value as specified by VkStencilOp. No shader instruction semantics are changed.
Tested
agc_driver_graphicspasses after rebasing both commits ontomainatb1c5f10d.tools/check_conventions.py --base origin/mainandgit diff --check origin/main...HEADpass.The automated tests validate decoded graphics state; they do not read back rendered GPU pixels. The game captures demonstrate the underlying ClearMRT fix, rather than an A/B comparison of the additional validation changes. Their resolutions differ, and they are not an FPS benchmark.
Before:
After:
Checklist
main(b1c5f10d); overlapping open PRs checked — #1479 is explicitly proposed for replacement, with original authorship preserved.NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt — no silent stubs added.mdfiles or images added to the repository (attach them to this PR)@oneandonlydean @adriadam10 — proposing this as a replacement for #1479 because it preserves the original rasterized ClearMRT fix and its author's credit, while closing two reproduced decoder gaps: writes to read-only stencil and rejection by stencil operations that the clear overrides. It also adds MRT/scissor regressions and Windows 10 / RTX 3080 visual evidence. The overlap is explicit above so you can choose which PR to merge.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T04:46:25Z.
Linux results, since this was tested on Windows only. Everything passes here.
Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. This PR merged ontomainf1451396cleanly.mainf1451396main+ this PRctest -R agc_driver -j1-E agc_driver)The CPU failure is
guest_dynamic_loader, which fails the same way onmain.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-09T11:55:24Z.
Uncharted: Legacy of Thieves Collection (PPSA05684) clears with draws that set
DB_RENDER_CONTROLto 0x3 (depth and stencil) and stops onmainwith:I opened the depth half on top of this PR as #2219 (
Depends on #1534): the draw is rasterized as submitted with an always-passing depth write and the viewport depth range pinned toDB_DEPTH_CLEAR, so it covers only what the title's geometry covers.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:04:38Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/State.cppL852-854Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T01:09:55Z.
Checked: build + ctest on the merged tree (agc_driver_graphics and agc_driver_prepared_graphics pass); the new test fails without the State.cpp change; stencil-clear state is chosen before ordinary stencil ops, read-only/absent stencil throws in both
DecodeStateand theDrawRejectionprecheck, depth clear/copy still rejected. Linux results from @fisherjoey agree. Merging.Note: #2179 touches the
depthSurfaceline inDrawRejectionand will need a rebase on top of this.