perf(agc): keep unchanged guest layers of a depth plane copy #2490

Merged
oneandonlydean merged 1 commit from upstream-pr/2490 into main 2026-10-13 01:48:44 +00:00
oneandonlydean commented 2026-10-09 23:10:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T23:10:15Z.


What

Follow-up to #425, as asked in its review.

DepthPlaneCopy (sampling a depth surface as a 2D array, a cube or its integer bits) keeps each slice it read from guest memory in its staging buffer, together with the write generation it was read at. The next use reads and detiles that slice again only when:

  • its address, size or tiling changed;
  • the write tracker reports a write since (UnchangedSince);
  • recorded GPU work writes the range (Recorder::SnapshotWriteOverlaps); or
  • a depth surface held that slice in between.

Without write watching, every use reads, as before.

#425 is merged, so this head is rebased onto main 1c5e6287 and holds only its own commit. It applied without conflicts and the change is the same.

Why

Every use read and detiled every slice no depth surface holds, even when nothing had written it.

The rule is the one a cached sampled snapshot already uses for a hit (cachedTexture: collect, then UnchangedSince), plus the pending-write check, so it is no looser than the existing texture path.

Tested

Linux (CachyOS, GCC 16.2.1, Release with CI's configure flags and ANYPS5_ENABLE_SPIRV_TOOLS=ON, full build and libs), RTX 4090, NVIDIA 610.57.04.

  • ctest -R "agc|shader" (--parallel 4, ANYPS5_REQUIRE_VULKAN=1): 462/462 on this head (af716047), 461/461 on main 1c5e6287. tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.

  • The seven agc_driver_depth* tests under VK_LAYER_KHRONOS_validation: pass, no validation message.

  • New agc_driver_depth_plane_guest_layers. A 2-layer D32 array: layer 0 is a depth surface, layer 1 is in watched guest memory. Checks:

    • the first use reads layer 1;
    • a second use without writes does not read it;
    • a CPU write and a driver store (MarkWritten) each make the next use read it again.

    It passes with the change (5 of 5 runs). On main 1c5e6287 with only the test added it fails: sampling the depth planes again read the guest layer no depth surface holds although nothing wrote it.

  • A 3D title we test with stops on main before its title scene without #4500, so it was measured on main 1c5e6287 + #4500, with this and #2491 together: frames per second in the title scene and in the menu after it.

    build title fps menu fps
    main 1c5e6287 + #4500 0.8 0.65
    the same + this + #2491 17.3 13.7

    Without the two changes the title scene runs at 0.6 to 0.9 fps from its first frame on (74 frames in 90 s); with them the run goes on into the first level. One run each; caches warm for the second row. In the second row #4500's store-back also bumps the write serial (see #2491).

Not run on this head: the 2D title we test with (it ran on #2491's head, which contains this commit). Not tested on Windows or on AMD.

Checklist

  • Based on current main (1c5e6287, the merge of #425); no other open PR changes DepthPlaneCopy (#1368 samples depth arrays with its own storage, separately)
  • 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
  • Unblocks: none
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4806836241 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2490). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T23:10:15Z. --- ### What Follow-up to #425, as asked in its review. `DepthPlaneCopy` (sampling a depth surface as a 2D array, a cube or its integer bits) keeps each slice it read from guest memory in its staging buffer, together with the write generation it was read at. The next use reads and detiles that slice again only when: - its address, size or tiling changed; - the write tracker reports a write since (`UnchangedSince`); - recorded GPU work writes the range (`Recorder::SnapshotWriteOverlaps`); or - a depth surface held that slice in between. Without write watching, every use reads, as before. #425 is merged, so this head is rebased onto `main` 1c5e6287 and holds only its own commit. It applied without conflicts and the change is the same. ### Why Every use read and detiled every slice no depth surface holds, even when nothing had written it. The rule is the one a cached sampled snapshot already uses for a hit (`cachedTexture`: collect, then `UnchangedSince`), plus the pending-write check, so it is no looser than the existing texture path. ### Tested Linux (CachyOS, GCC 16.2.1, Release with CI's configure flags and `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, full build and `libs`), RTX 4090, NVIDIA 610.57.04. - `ctest -R "agc|shader"` (`--parallel 4`, `ANYPS5_REQUIRE_VULKAN=1`): 462/462 on this head (`af716047`), 461/461 on `main` 1c5e6287. `tools/check_conventions.py --base origin/main` and `tools/check_test_registration.py` pass. - The seven `agc_driver_depth*` tests under `VK_LAYER_KHRONOS_validation`: pass, no validation message. - New `agc_driver_depth_plane_guest_layers`. A 2-layer D32 array: layer 0 is a depth surface, layer 1 is in watched guest memory. Checks: - the first use reads layer 1; - a second use without writes does not read it; - a CPU write and a driver store (`MarkWritten`) each make the next use read it again. It passes with the change (5 of 5 runs). On `main` 1c5e6287 with only the test added it fails: `sampling the depth planes again read the guest layer no depth surface holds although nothing wrote it`. - A 3D title we test with stops on `main` before its title scene without #4500, so it was measured on `main` 1c5e6287 + #4500, with this and #2491 together: frames per second in the title scene and in the menu after it. | build | title fps | menu fps | |---|---|---| | `main` 1c5e6287 + #4500 | 0.8 | 0.65 | | the same + this + #2491 | 17.3 | 13.7 | Without the two changes the title scene runs at 0.6 to 0.9 fps from its first frame on (74 frames in 90 s); with them the run goes on into the first level. One run each; caches warm for the second row. In the second row #4500's store-back also bumps the write serial (see #2491). Not run on this head: the 2D title we test with (it ran on #2491's head, which contains this commit). Not tested on Windows or on AMD. ### Checklist - [x] Based on current `main` (1c5e6287, the merge of #425); no other open PR changes `DepthPlaneCopy` (#1368 samples depth arrays with its own storage, separately) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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] Unblocks: none - [x] AI-assisted: yes (Claude Code)
Mouhand-Kaddo commented 2026-10-10 10:04:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:04:54Z.


Additional platform validation on standalone PR head 5f0e7304189174bbfc033f37138b06ed15e4e77a:

Windows: passed — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja.

Release / BUILD_TESTING=ON: built the selected test targets; 2 CTest cases, 0 failures, 0 CTest skips.

Tests: agc_driver_graphics, agc_driver_depth_plane_guest_layers.

Reproduce after building the test targets: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(depth_plane_guest_layers|graphics)$".

Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002.

Integration limitation: a local merge against main 948a526c2 has source conflicts; these results validate the standalone PR head, not a resolved merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096392739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2490#issuecomment-6096392739). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-10T10:04:54Z. --- <!-- anyps5-platform-validation:5f0e7304189174bbfc033f37138b06ed15e4e77a --> Additional platform validation on standalone PR head `5f0e7304189174bbfc033f37138b06ed15e4e77a`: **Windows: passed** — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja. Release / `BUILD_TESTING=ON`: built the selected test targets; 2 CTest cases, 0 failures, 0 CTest skips. Tests: `agc_driver_graphics`, `agc_driver_depth_plane_guest_layers`. Reproduce after building the test targets: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(depth_plane_guest_layers|graphics)$"`. Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002. Integration limitation: a local merge against main `948a526c2` has source conflicts; these results validate the standalone PR head, not a resolved merge.
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!2490
No description provided.