perf(agc): read-only stencil binds trigger redundant publication #14842

Closed
opened 2026-11-01 19:34:30 +00:00 by lgqdaxia · 0 comments
lgqdaxia commented 2026-11-01 19:34:30 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by lgqdaxia on 2026-11-01T19:34:30Z.


Title and scene

Asset-free agc_driver_stencil_plane_memory test. No controlled commercial-title scene performance comparison is provided; the report currently establishes redundant publication work through component tests.

What is slow or what changed

After a stencil plane has been published successfully, a draw that cannot write stencil marks it dirty again. The next FlushDepthPlanes returns redundant publication work. On tested main snapshot f2d874c1fdccf781c0fa5d86619bb5dd8894b958, DepthSurfaceView receives depth write intent but unconditionally marks mirrorable stencil stale. The native depth writer predicate also counts all-KEEP stencil operations with nonzero write masks as a writer.

This is a performance candidate. Required same-scene main/PR performance summaries and traces are missing; no FPS or end-to-end speed improvement is claimed.

Summary lines

Not provided for the required same-machine, same-scene main/PR comparison. No FPS or end-to-end speed improvement is claimed.

Traces

The paired performance traces required by this form are not provided. Component-test logs and the correctness controls below do not replace those traces.

Digest

A paired performance-trace digest is not provided.

Capture

The capture protocol below is unverified for the missing paired performance report:

  • The caches were warm (the scene ran once and the title was restarted)
  • No other APS5_TRACE_* or APS5_PROFILE_* switch was set and the log was not redirected
  • Captures compared here come from the same machine, scene and settings

Test and reproduction

Asset-free agc_driver_stencil_plane_memory; no game dump or save is needed.

  1. Put the final test source on the tested main snapshot above, leaving production code unchanged.
  2. The fixture writes stencil 0x18, publishes it, and confirms a second flush is empty. Two preservation controls then check real HTILE stencil clears consumed by sampling or a depth-only flush before a read-only rebind. Both controls pass on the original production logic.
  3. A subsequent stencil-disabled draw should leave the stored plane clean. Original production logic instead fails:
AGC graphics: a stencil-disabled draw dirtied the stored stencil plane

The fixture also checks all-KEEP/nonzero-mask and zero-mask/REPLACE draws, unchanged stored bytes, real writes and retirement. The clear controls protect behavior the optimization must preserve.

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_AGC_EXECUTION_TESTS=StencilPlaneMemory
cmake --build build --target agc_driver_stencil_plane_memory_tests
cmake -E env ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R ^agc_driver_stencil_plane_memory$ -V --no-tests=error

Qualification

At final head 27607b4a961ff89a0d53a963fd08442db153728b, an incremental AGC rebuild/link completed and the five focused CTests for stencil memory, depth-buffer memory, sampling, plane fills and fast clear passed 5/5, once each. The NVIDIA GPU and validation layer were confirmed; no VUID-, SYNC-HAZARD or whole-CTest skip was reported. The two memory fixtures' conditional write-watch portions remain unexercised as detailed below.

Newer main snapshot e0caf1360035286bd22b9f2a3030e97b880ffb28 was checked statically: all four candidate base files are unchanged from tested f2, and the exact patch passes an independent index apply check. The candidate is not rebased to e0; shared DCC/StorageTexture behavior changed and the combined runtime has not been tested.

Historical causal comparison at pre-rename d1a0dbe2:

Windows 11 (10.0.26200), MinGW GCC 15.2.0, NVIDIA GeForce RTX 3080 Laptop GPU / NVIDIA 610.74. An AGC native SDK and the focused executables were built from the tested f2 snapshot plus candidate code; the tested d1 production translation units were force-recompiled and linked. The registration audit checked 1,692 executables.

That historical comparison used one run per variant, the same stencil fixture and shared unchanged SDK objects:

Production-path variant Stencil fixture result
Original f2d874c1 production TUs/header Both clear controls pass; expected failure at the later stencil-disabled assertion
Earlier e5c02408 DepthSurface TU control Expected failure at the first, sampling-consumed clear assertion; the depth-only clear case is not reached
Pre-rename d1a0dbe2 Passes both clear controls, all three read-only cases and existing real-write/retirement checks

The original control rebuilds the two original production TUs/header and three trace-identity TUs, sharing all other unchanged objects. It is not a second independent whole-tree build. The e5 control swaps only its DepthSurface TU; its shared trace identity remains d1. Shader caching was disabled throughout, including for any shared candidate-derived cache fingerprint.

agc_driver_depth_plane_fill and agc_driver_depth_fast_clear additionally pass 2/2 on each of f2d874c1 and d1a0dbe2 (one run each), covering stencil fills/alias inheritance and HTILE/direct-clear controls. Both fixtures complete with the NVIDIA GPU and validation layer confirmed, no VUID-/SYNC-HAZARD, and no conditional early return or skipped CTest.

agc_driver_depth_plane_buffer_memory and agc_driver_depth_plane_sampling pass on all three variants. The unmodified original stencil fixture passes on original and pre-rename candidate logic. Every run loaded the requested validation layer and selected the NVIDIA GPU; no VUID- or SYNC-HAZARD messages were found. No whole CTest was skipped. The conditional write-watched portions of both stencil-plane-memory and depth-plane-buffer-memory were not exercised; the latter returns before its later CPU-write/HTILE cases. The new stencil clear-order controls ran before the stencil fixture's conditional branch. No full CTest suite, hosted CI, Linux or other-GPU result is claimed.

The candidate uses DepthSurfaceViewWithStencilWriteIntent; the legacy three-argument entry point stays conservative. The stencilTested contract in #9533, #9717, #9742, #13021 and #13023 is distinct from stencilWritten. Real storage-image writes from #12617 must still mark stencil dirty; these combinations have not been runtime-tested.

This builds on #12210. #12617 handles pending storage-image writes into stencil; #10382 handles analogous BDA leases. Neither is implemented here. The recorded 2026-11-01 issue/PR/Discussion searches found no same-root report or fix.

Proposed branch: lgqdaxia/AnyPS5:codex/quarry-write-intent, 27607b4a961ff89a0d53a963fd08442db153728b. Draft PR #14843 remains unmerged and accepts perf numbers missing until the required performance report exists. With #10760 already open, the one-open-PR intake policy may close it automatically. The branch remains available for anyone to use, adapt, replace or ignore while pursuing an independent fix.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6151152442 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/14842). Originally posted by [lgqdaxia](https://github.com/lgqdaxia) on 2026-11-01T19:34:30Z. --- ### Title and scene Asset-free `agc_driver_stencil_plane_memory` test. No controlled commercial-title scene performance comparison is provided; the report currently establishes redundant publication work through component tests. ### What is slow or what changed After a stencil plane has been published successfully, a draw that cannot write stencil marks it dirty again. The next `FlushDepthPlanes` returns redundant publication work. On tested main snapshot `f2d874c1fdccf781c0fa5d86619bb5dd8894b958`, `DepthSurfaceView` receives depth write intent but unconditionally marks mirrorable stencil stale. The native depth writer predicate also counts all-KEEP stencil operations with nonzero write masks as a writer. This is a performance candidate. Required same-scene main/PR performance summaries and traces are missing; no FPS or end-to-end speed improvement is claimed. ### Summary lines Not provided for the required same-machine, same-scene main/PR comparison. No FPS or end-to-end speed improvement is claimed. ### Traces The paired performance traces required by this form are not provided. Component-test logs and the correctness controls below do not replace those traces. ### Digest A paired performance-trace digest is not provided. ### Capture The capture protocol below is unverified for the missing paired performance report: - [ ] The caches were warm (the scene ran once and the title was restarted) - [ ] No other APS5_TRACE_* or APS5_PROFILE_* switch was set and the log was not redirected - [ ] Captures compared here come from the same machine, scene and settings ### Test and reproduction Asset-free `agc_driver_stencil_plane_memory`; no game dump or save is needed. 1. Put [the final test source](https://github.com/lgqdaxia/AnyPS5/blob/27607b4a961ff89a0d53a963fd08442db153728b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneMemory.cpp) on the tested main snapshot above, leaving production code unchanged. 2. The fixture writes stencil `0x18`, publishes it, and confirms a second flush is empty. Two preservation controls then check real HTILE stencil clears consumed by sampling or a depth-only flush before a read-only rebind. Both controls pass on the original production logic. 3. A subsequent stencil-disabled draw should leave the stored plane clean. Original production logic instead fails: ```text AGC graphics: a stencil-disabled draw dirtied the stored stencil plane ``` The fixture also checks all-KEEP/nonzero-mask and zero-mask/REPLACE draws, unchanged stored bytes, real writes and retirement. The clear controls protect behavior the optimization must preserve. ```text cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_AGC_EXECUTION_TESTS=StencilPlaneMemory cmake --build build --target agc_driver_stencil_plane_memory_tests cmake -E env ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R ^agc_driver_stencil_plane_memory$ -V --no-tests=error ``` ### Qualification At final head `27607b4a961ff89a0d53a963fd08442db153728b`, an incremental AGC rebuild/link completed and the five focused CTests for stencil memory, depth-buffer memory, sampling, plane fills and fast clear passed 5/5, once each. The NVIDIA GPU and validation layer were confirmed; no `VUID-`, `SYNC-HAZARD` or whole-CTest skip was reported. The two memory fixtures' conditional write-watch portions remain unexercised as detailed below. Newer main snapshot `e0caf1360035286bd22b9f2a3030e97b880ffb28` was checked statically: all four candidate base files are unchanged from tested `f2`, and the exact patch passes an independent index apply check. The candidate is not rebased to `e0`; shared DCC/StorageTexture behavior changed and the combined runtime has not been tested. Historical causal comparison at pre-rename `d1a0dbe2`: Windows 11 (10.0.26200), MinGW GCC 15.2.0, NVIDIA GeForce RTX 3080 Laptop GPU / NVIDIA 610.74. An AGC native SDK and the focused executables were built from the tested f2 snapshot plus candidate code; the tested d1 production translation units were force-recompiled and linked. The registration audit checked 1,692 executables. That historical comparison used one run per variant, the same stencil fixture and shared unchanged SDK objects: | Production-path variant | Stencil fixture result | | --- | --- | | Original `f2d874c1` production TUs/header | Both clear controls pass; expected failure at the later stencil-disabled assertion | | Earlier `e5c02408` DepthSurface TU control | Expected failure at the first, sampling-consumed clear assertion; the depth-only clear case is not reached | | Pre-rename `d1a0dbe2` | Passes both clear controls, all three read-only cases and existing real-write/retirement checks | The original control rebuilds the two original production TUs/header and three trace-identity TUs, sharing all other unchanged objects. It is not a second independent whole-tree build. The `e5` control swaps only its DepthSurface TU; its shared trace identity remains `d1`. Shader caching was disabled throughout, including for any shared candidate-derived cache fingerprint. `agc_driver_depth_plane_fill` and `agc_driver_depth_fast_clear` additionally pass 2/2 on each of `f2d874c1` and `d1a0dbe2` (one run each), covering stencil fills/alias inheritance and HTILE/direct-clear controls. Both fixtures complete with the NVIDIA GPU and validation layer confirmed, no `VUID-`/`SYNC-HAZARD`, and no conditional early return or skipped CTest. `agc_driver_depth_plane_buffer_memory` and `agc_driver_depth_plane_sampling` pass on all three variants. The unmodified original stencil fixture passes on original and pre-rename candidate logic. Every run loaded the requested validation layer and selected the NVIDIA GPU; no `VUID-` or `SYNC-HAZARD` messages were found. No whole CTest was skipped. The conditional write-watched portions of both stencil-plane-memory and depth-plane-buffer-memory were not exercised; the latter returns before its later CPU-write/HTILE cases. The new stencil clear-order controls ran before the stencil fixture's conditional branch. No full CTest suite, hosted CI, Linux or other-GPU result is claimed. ### Related work and proposed patch The candidate uses `DepthSurfaceViewWithStencilWriteIntent`; the legacy three-argument entry point stays conservative. The `stencilTested` contract in #9533, #9717, #9742, #13021 and #13023 is distinct from `stencilWritten`. Real storage-image writes from #12617 must still mark stencil dirty; these combinations have not been runtime-tested. This builds on [#12210](https://github.com/boykopovar/AnyPS5/pull/12210). [#12617](https://github.com/boykopovar/AnyPS5/pull/12617) handles pending storage-image writes into stencil; [#10382](https://github.com/boykopovar/AnyPS5/pull/10382) handles analogous BDA leases. Neither is implemented here. The recorded 2026-11-01 issue/PR/Discussion searches found no same-root report or fix. Proposed branch: [lgqdaxia/AnyPS5:codex/quarry-write-intent](https://github.com/lgqdaxia/AnyPS5/tree/codex/quarry-write-intent), `27607b4a961ff89a0d53a963fd08442db153728b`. [Draft PR #14843](https://github.com/boykopovar/AnyPS5/pull/14843) remains unmerged and accepts `perf numbers missing` until the required performance report exists. With [#10760](https://github.com/boykopovar/AnyPS5/pull/10760) already open, the one-open-PR intake policy may close it automatically. The branch remains available for anyone to use, adapt, replace or ignore while pursuing an independent fix. AI-assisted: yes
Sign in to join this conversation.
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#14842
No description provided.