fix(agc): storage access to a depth surface's stencil plane through its stencil aspect #2325

Closed
fisherjoey wants to merge 9 commits from upstream-pr/2325 into main
fisherjoey commented 2026-10-09 15:33:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T15:33:06Z.


What

Storage-image access to a depth surface's stencil plane. #425 handles the depth plane through Transfer and a writer. This change extends that model to the stencil aspect:

  • Transfer takes an aspect. The stencil plane needs an 8-bit storage format and a single layer; anything else still throws.
  • DepthSurface keeps a stencil writer next to the depth one, and TakeWrites and ApplyFastClear handle both planes.
  • SeedStorageFromStencil seeds it, and cachedStorageTexture calls it instead of throwing.

Depends on #425.

The diff shows #425's commits until it merges, since GitHub can't stack a PR on a branch in another fork. Review 598f7883 only. #1684 and #1842 also add stencil storage, against main and in a different way, so only one of the two approaches should land.

Tested

Linux (Nobara 44, kernel 7.2), GCC 16, RTX 5070 Ti with NVIDIA 595.91.07, and RADV.

  • New agc_driver_stencil_plane_storage: a draw writes stencil 0x5a, a compute image_load must return 0x5a, then a compute image_store of 42 must make stencil EQUAL 42 pass everywhere and EQUAL 0x5a nowhere. Fails on #425's head with storage access to a depth surface's stencil plane is not implemented; passes with this change. #425's agc_driver_depth_fast_clear tests pass.
  • ctest -R agc_ -j1: 227 of 227 on the RTX 5070 Ti and 227 of 227 on RADV (Ryzen 5 7600X iGPU, Mesa 26.2.1). tools/check_conventions.py --base 62b1e552: passes.
  • Stray (PPSA02100 v1.05): compute shader 0x200bd80000 binds the stencil plane of a 3840x2160 D32S8 surface as an R8_UINT storage image. With #425 alone the run stops at about 170 s on the stencil guard. With this change it gets past it.
  • Windows: not tested.

Checklist

  • Depends on: #425
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4802536750 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2325). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-09T15:33:06Z. --- ### What Storage-image access to a depth surface's stencil plane. #425 handles the depth plane through `Transfer` and a writer. This change extends that model to the stencil aspect: - `Transfer` takes an aspect. The stencil plane needs an 8-bit storage format and a single layer; anything else still throws. - `DepthSurface` keeps a stencil writer next to the depth one, and `TakeWrites` and `ApplyFastClear` handle both planes. - `SeedStorageFromStencil` seeds it, and `cachedStorageTexture` calls it instead of throwing. Depends on #425. The diff shows #425's commits until it merges, since GitHub can't stack a PR on a branch in another fork. Review 598f7883 only. #1684 and #1842 also add stencil storage, against `main` and in a different way, so only one of the two approaches should land. ### Tested Linux (Nobara 44, kernel 7.2), GCC 16, RTX 5070 Ti with NVIDIA 595.91.07, and RADV. - New `agc_driver_stencil_plane_storage`: a draw writes stencil 0x5a, a compute `image_load` must return 0x5a, then a compute `image_store` of 42 must make stencil EQUAL 42 pass everywhere and EQUAL 0x5a nowhere. Fails on #425's head with `storage access to a depth surface's stencil plane is not implemented`; passes with this change. #425's `agc_driver_depth_fast_clear` tests pass. - `ctest -R agc_ -j1`: 227 of 227 on the RTX 5070 Ti and 227 of 227 on RADV (Ryzen 5 7600X iGPU, Mesa 26.2.1). `tools/check_conventions.py --base 62b1e552`: passes. - Stray (PPSA02100 v1.05): compute shader 0x200bd80000 binds the stencil plane of a 3840x2160 D32S8 surface as an R8_UINT storage image. With #425 alone the run stops at about 170 s on the stencil guard. With this change it gets past it. - Windows: not tested. ### Checklist - [x] Depends on: #425 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 16:31:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T16:31:59Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2156 core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp L142
#2169 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/BufferFill.cpp L4, L203
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp L7, L58
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp L17-18
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp L65, L154-155
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L38, L107, L151-152, L155, L172
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L6, L710, L724
core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClear.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp
core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearSubmit.cpp
#2229 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp L17-18
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp L65, L154-155
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L12-13, L152-153, L155
#2261 docs/dev/TechnicalDebt.md L235
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085026229 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2325#issuecomment-6085026229). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T16:31:59Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2156 | `core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp` [L142](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp#L142) | | | | #2169 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/BufferFill.cpp` [L4](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/BufferFill.cpp#L4), [L203](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/BufferFill.cpp#L203)<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp` [L7](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp#L7), [L58](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp#L58)<br>`core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp` [L17-18](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp#L17-L18)<br>`core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp` [L65](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L65), [L154-155](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L154-L155)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp` [L38](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L38), [L107](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L107), [L151-152](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L151-L152), [L155](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L155), [L172](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L172)<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` [L6](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L6), [L710](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L710), [L724](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L724) | | `core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClear.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp`<br>`core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearSubmit.cpp` | | #2229 | `core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp` [L17-18](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp#L17-L18)<br>`core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp` [L65](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L65), [L154-155](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp#L154-L155)<br>`core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp` [L12-13](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L12-L13), [L152-153](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L152-L153), [L155](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L155) | | | | #2261 | `docs/dev/TechnicalDebt.md` [L235](https://github.com/boykopovar/AnyPS5/blob/f8c2f072463465f875dedb0d20b66c339160c1a1/docs/dev/TechnicalDebt.md#L235) | | |
Kikoarl commented 2026-10-09 17:53:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:53:08Z.


Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at 598f7883:

  • Build: Built cleanly in RAM (/tmp/anyps5_build) with zero warnings/errors.
  • Conventions: python3 tools/check_conventions.py --base origin/main --head HEAD -> PASS (0 errors).
  • Verification: Verified depth/stencil plane separation and storage access via stencil aspect in PacketMemory.cpp. Tested cleanly across Vulkan pipeline.

LGTM!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086313303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2325#issuecomment-6086313303). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-09T17:53:08Z. --- Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at `598f7883`: - **Build**: Built cleanly in RAM (`/tmp/anyps5_build`) with zero warnings/errors. - **Conventions**: `python3 tools/check_conventions.py --base origin/main --head HEAD` -> **PASS (0 errors)**. - **Verification**: Verified depth/stencil plane separation and storage access via stencil aspect in `PacketMemory.cpp`. Tested cleanly across Vulkan pipeline. LGTM!
fisherjoey commented 2026-10-09 18:09:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T18:09:22Z.


I missed #2076 when I opened this. @jdmagic opened it nine hours before this one, and it does the same thing: both stack on #425 and route a storage T# at a depth surface's stencil plane through Transfer with the stencil aspect (SeedStorageFromStencil, DepthStencilPlaneAt, a stencil writer next to the depth one). Most of the stencil code is identical.

#2076 came first, so that's the one to review. This PR adds two things on top of it:

  • HTILE stencil fast clears: decodeDepth reads the HTILE address and whether HTILE holds stencil state (TILE_STENCIL_DISABLE), and a whole-HTILE fill with SMem 0 clears the stencil plane (HtileFillClears, HtileFillCovers).
  • agc_driver_stencil_plane_storage: a draw writes stencil 0x5a, a compute image_load must read 0x5a, and an image_store of 42 must make stencil EQUAL 42 pass. It fails on #425's head and passes here.

I can't open a follow-up PR on top of #2076 (new PRs from me are closed by intake for now), so I'm closing this one. Both parts are in commit 598f7883 on fisherjoey/AnyPS5 fix/agc-stencil-plane-storage, on #425's head 62b1e552. @jdmagic, feel free to cherry-pick either part into #2076.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086577728 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2325#issuecomment-6086577728). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-09T18:09:22Z. --- I missed #2076 when I opened this. @jdmagic opened it nine hours before this one, and it does the same thing: both stack on #425 and route a storage T# at a depth surface's stencil plane through `Transfer` with the stencil aspect (`SeedStorageFromStencil`, `DepthStencilPlaneAt`, a stencil writer next to the depth one). Most of the stencil code is identical. #2076 came first, so that's the one to review. This PR adds two things on top of it: - HTILE stencil fast clears: `decodeDepth` reads the HTILE address and whether HTILE holds stencil state (`TILE_STENCIL_DISABLE`), and a whole-HTILE fill with SMem 0 clears the stencil plane (`HtileFillClears`, `HtileFillCovers`). - `agc_driver_stencil_plane_storage`: a draw writes stencil 0x5a, a compute `image_load` must read 0x5a, and an `image_store` of 42 must make stencil EQUAL 42 pass. It fails on #425's head and passes here. I can't open a follow-up PR on top of #2076 (new PRs from me are closed by intake for now), so I'm closing this one. Both parts are in commit 598f7883 on fisherjoey/AnyPS5 `fix/agc-stencil-plane-storage`, on #425's head 62b1e552. @jdmagic, feel free to cherry-pick either part into #2076. AI-assisted: yes

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