fix(agc): give a vertex copy headroom when its range keeps growing #19100

Merged
videogamer10293 merged 2 commits from upstream-pr/19100 into main 2026-11-24 09:55:22 +00:00
videogamer10293 commented 2026-11-12 19:27:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by videogamer10293 on 2026-11-12T19:27:12Z.


What

A draw whose vertex range starts at the same address as a kept copy, but reaches a little further, cannot reuse that copy. A vertex lookup takes only a kept copy at least as long as the read (Recorder.cpp#L3700). So draws that walk through one large vertex buffer in consecutive windows copy the whole range again on every draw. Where vertex input is copied rather than read in place, each copy is a new host buffer, and a burst of them can push the host heap over its budget. NVIDIA's Windows driver is such a case: DrawInputsInPlaceUsable is false for it, so only inputs of up to 1024 bytes with few reads are bound in place.

With this change, when a vertex copy misses only because the kept copy at the same address is unchanged but shorter, the new copy is made longer than the read. The next draws in the sequence then reuse it.

  • Recorder::ShorterDrawSnapshotKept tells whether such a copy is kept. It must have the same address and use, be shorter, come from the current allocation registry, not be an owned-input copy, and be unchanged since it was made, from where its bytes start (a copy can start past its address, #9875).
  • CopyDrawInput takes a growLimit. It grows only vertex copies, only past such a kept copy, by at most a quarter of the read, never past the limit, and never past DrawInputBudget (a longer copy would not be kept). The grown range is collected with the read, so the kept copy's generation covers all of it.
  • The draw does not read the extra bytes, so they are taken only when nothing has to be done first. They must be accessible. They must have no pending GPU write, label or queued store (Recorder::GuestWritesPendingIn), no storage image with pending results, and no unpublished unit shadow. They must not overlap a resident depth surface or host-only samples (HostOnlySampleRanges). These checks are queries only. The read itself still goes through GuestMemory::Read; the extra bytes are then copied directly, without its flush and read guard.
  • The vertex path passes the end of the attribute descriptors' range as the limit (VertexDescriptorEnd), using the smallest end when a copy merges several attributes. The limit is cut at any color, depth, stencil or HTILE address past the read. Indirect draws and index copies do not grow.
  • A grown copy's device mirror (#16760) mirrors the whole copy, so it takes the same extra bytes in device memory.

Why a quarter. It bounds the extra bytes when the descriptor is much larger than the read. In the earlier Sky Garden runs below, the limit, not the quarter, capped the growth: the second copy grew by about 9 %, which was enough for 22 copies of 32 MiB or more to become 3. A range that grows by more than its headroom on every draw gets copies longer than on main that are never reused. That costs memory and gains nothing.

This PR claims no speed change. PPSA21564 (ASTRO BOT) stopped on these copies in Sky Garden on Windows with NVIDIA (traced below); two more levels stop on main on a full host heap and reach the cap with this change.

Tested

Windows only: Windows 10 Pro 10.0.19045, Ryzen 5 7600X, 31893 MiB of RAM, RTX 5070 Ti, NVIDIA 621.24, WinLibs GCC 15.2.0 (UCRT), Release, BUILD_TESTING=ON. Head e78ae2ee05 on main 3c07e1d05e; every result below is from this head and that main. Both build trees carried the same local test-only edit, not committed: a Windows _putenv_s in UploadCacheReadOnlyFlush.cpp, which does not build on Windows on this main (#19899, #22373).

Others ran older heads: relativespace2K (RX 6800 XT) and JJenkx (RX 6700 XT) on Windows, and blawesom on Linux with RADV (comment). In blawesom's run the unit-shadow check skipped itself, since its block was not imported and watched; it ran here.

main has since moved to e35c90cfe3. Among this PR's files it changed only tests/Graphics.cpp and tests/Recorder.cpp, and the branch merges with it without a conflict. I did not rerun the tests on that merge.

Tests

  • tools/select_tests.py with the 19 files that differed from upstream/main at the time (the 9 of this PR and 10 from a newer main) selects 6171 tests; the 9 alone select 3245 of them. With tools/select_tests.py ctest build, the same 3 fail on both sides: agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch and agc_driver_bda_device. On main, agc_driver_image_table_packed_guards also failed once; it passed 3 of 3 runs alone on each side. After every build, the staged .prx copies next to the test executables matched the rebuilt libraries.
  • growingVertexCopyTests, in agc_driver_recorder, uses a real device and a write-watched block. It checks that:
    • a first copy takes no headroom;
    • a longer read past an unchanged shorter copy gets a quarter more;
    • a later read inside the headroom reuses the grown copy, both as a host read and as a draw's read, which may get a device mirror, although a store landed in the headroom before that copy was made (only the grown collect saw it);
    • a read whose headroom holds a pending GPU write does not grow;
    • a read past the headroom grows again;
    • the limit caps the growth;
    • a changed shorter copy, a zero limit and an index copy take none;
    • a kept copy that starts past its address lets a longer one grow after a store below its start.
  • grownVertexCopyShadowTests, in agc_driver_recorder: a copy whose headroom ends before a fresh unit shadow grows; one whose headroom reaches it does not.
  • validationTests, in agc_graphics_profile_draw, checks without a device: VertexDescriptorEnd; GrownVertexCopyBytes (the quarter, the limit, the DrawInputBudget cap); VertexCopyGrowEnd (color, depth, stencil and HTILE cuts).
  • VertexPlanScratchEmptiesEveryList, in agc_exclusive_scratch, covers the two new plan lists.
  • 16 breaks of the change, one at a time, with the tests kept: 14 fail agc_driver_recorder, agc_graphics_profile_draw or agc_exclusive_scratch; the unchanged head passes before and after. Two pass:
    • prepareDrawInputs passing no limit. No unit test draws through that call; the title runs below do.
    • The guarded read also covering the headroom. It gives the same bytes as the direct copy, so no test can tell them apart; the direct copy only skips the flush and read guard over bytes the draw does not read.
  • Not tested one by one: the accessible, storage-image, resident-depth and host-only-sample checks on the headroom, and the registry and owned-input conditions of ShorterDrawSnapshotKept. The cut looks only at the address where a target starts; a target that starts below the read's end and reaches into the headroom is left to the pending-write and resident-depth checks.
  • Validation: agc_driver_recorder under ctest -V with VK_ADD_LAYER_PATH set to the layer, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_LAYERS_DISABLE=~implicit~ VK_LOADER_DEBUG=layer and the Khronos Windows layer 1.4.368. On both sides it passes, the loader inserts the layer and no implicit layer:
    [Vulkan Loader] INFO | LAYER:   Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\AnyPS5Dev\tools\vvl-nightly-13e1d19f\layer\VkLayer_khronos_validation.dll)
    
    Neither log has was not found but was requested by env var VK_INSTANCE_LAYERS or a VUID- line. The same settings over the 25 tests matching ^(agc_driver_recorder|agc_draw_inputs_.*|agc_owned_draw_inputs.*|agc_driver_vertex.*|agc_driver_draw_offset.*|agc_draw_snapshot.*)$ give the same on both sides: no VUID- line, 24 pass and agc_driver_vertex_elected_atomic_max skips. The loader inserts the layer in 22 of them; agc_driver_vertex_table_read_order, agc_driver_vertex_table_read_order_counts_off and agc_draw_inputs_in_place_driver print no loader line. The other new checks run without a device: agc_graphics_profile_draw uses MockVulkan.

Title. PPSA21564 01.007.000, no input, muted, 300 s cap, 2 runs per level and side. One run dir and relinked executable from main 3c07e1d05e; the sides differ only in libSceAgcDriver.prx. Runs alternate main, PR, main, PR, and share one shader cache, which was empty before the first hero_ape_escape run. No local print lines. The same two levels behaved the same on an older head, with pad input (comment).

level main 3c07e1d05e this PR e78ae2ee05
hero_ape_escape stop at 75 s and 33 s 300 s cap, both runs
path_maker_mana_tree stop at 52 s and 34 s 300 s cap, both runs

Times are the launcher's wall time. Every main run ends on a failed buffer allocation in heap 1, then terminate called on a MemoryAllocationError. The first hero_ape_escape run:

[gpu] driver failure: AGC graphics: vkAllocateMemory buffer: allocation=117440512 memoryType=3 reclaimed=0 released=229900288 initialResult=-2 attempts=2; heap 0 5217/15229 MiB; heap 1 15359/15085 MiB; heap 2 129/84 MiB: Vulkan result -2

At every stop, heap 1 (the host heap, 15947 MiB here) was over its budget of 15084 to 15085 MiB. No run of this PR printed a failed allocation. I did not trace the copies in these two levels; the A/B shows only that the stop goes away with this change. Not tested with more RAM.

Earlier runs: Sky Garden, on older heads

PPSA21564 01.007.000, -lvl underwater_aerial_garden, no input, 3840x2160, 600 s cap, shader cache warmed by one discarded run. B1 is main + #18356 (4a69efb803). Every arm carried a local print line, not committed, that logs each draw input copy of 32 MiB or more. "End" is the launcher's wall time.

main arm end copies of 32 MiB or more
d4d6b64710 B1 stop at 348 s 22
d4d6b64710 B1 + this PR (067d9cb616, a local commit, not pushed) 600 s cap 3
d91bb06af9 B1 stop at 353 s 22
d91bb06af9 B1 + earlier version 600 s cap 3
d91bb06af9 B1 + earlier version 600 s cap 3
d91bb06af9 B1 stop at 326 s 22
d91bb06af9 main stopped; launcher time not recorded (log last written 572 s after start) 20
d91bb06af9 main + earlier version 600 s cap 0

The "earlier version" rows are 77f76c2429, a local commit, not pushed: no unit-shadow check, a multisample query in place of HostOnlySampleRanges, and the whole range read through GuestMemory::Read. The main + earlier version run made no copy of 32 MiB or more, so that pair shows nothing either way. Local print lines on main 3c8b74996f + #18356 showed that all 23 copies of 32 MiB or more start at 0x1078e68ca0 and grow from 76 to 133 MiB, about 2.9 GiB in all, within 1.48 s before the stop. In a later run they came from ordinary draws, and every lookup after the first found the previous copy kept, from the current registry and unchanged, but shorter.

Overlap. tools/pr_overlap.py --branch on this head finds three open pull requests that change the same lines, each for another purpose: #9915 (vertex out-of-bounds range checks), #19620 (unbounded indirect vertex inputs) and #21923 (queue worker lock contention). None gives a copy headroom; whichever merges second can rebase. It could not compare 65 others, which conflict with main. A search of their diffs for the copy, keep and lookup functions and the vertex copy plan finds three; the diffs of #7642 and #9508 (308 and 366 files) could not be fetched. #9712 and #15570 change the line in CopyDrawInput that creates the copy's buffer, and the draft #20315 adds a GPU copy before CopyDrawInput for ranges with a pending GPU write.

#16879 replaces a kept snapshot's registryGeneration, which ShorterDrawSnapshotKept reads, with a forgetSerial; winstrex agreed that it goes first, and this PR takes that change when it rebases onto it.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: #16879
  • Fixes: none
  • Unblocks: PPSA21564 #357
  • GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 621.24, Windows 10 Pro 10.0.19045
  • AI-assisted: yes. Claude Code traced the stop with local print lines (not committed), wrote the change and the tests, rebased them, and ran the tests, mutation checks, validation runs and title A/B above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5283849133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19100). Originally posted by [videogamer10293](https://github.com/videogamer10293) on 2026-11-12T19:27:12Z. --- ### What A draw whose vertex range starts at the same address as a kept copy, but reaches a little further, cannot reuse that copy. A vertex lookup takes only a kept copy at least as long as the read ([Recorder.cpp#L3700](https://github.com/boykopovar/AnyPS5/blob/3c07e1d05e545cb5988041da0fa63ea8dd36673e/core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp#L3700)). So draws that walk through one large vertex buffer in consecutive windows copy the whole range again on every draw. Where vertex input is copied rather than read in place, each copy is a new host buffer, and a burst of them can push the host heap over its budget. NVIDIA's Windows driver is such a case: `DrawInputsInPlaceUsable` is false for it, so only inputs of up to 1024 bytes with few reads are bound in place. With this change, when a vertex copy misses only because the kept copy at the same address is unchanged but shorter, the new copy is made longer than the read. The next draws in the sequence then reuse it. - `Recorder::ShorterDrawSnapshotKept` tells whether such a copy is kept. It must have the same address and use, be shorter, come from the current allocation registry, not be an owned-input copy, and be unchanged since it was made, from where its bytes start (a copy can start past its address, #9875). - `CopyDrawInput` takes a `growLimit`. It grows only vertex copies, only past such a kept copy, by at most a quarter of the read, never past the limit, and never past `DrawInputBudget` (a longer copy would not be kept). The grown range is collected with the read, so the kept copy's generation covers all of it. - The draw does not read the extra bytes, so they are taken only when nothing has to be done first. They must be accessible. They must have no pending GPU write, label or queued store (`Recorder::GuestWritesPendingIn`), no storage image with pending results, and no unpublished unit shadow. They must not overlap a resident depth surface or host-only samples (`HostOnlySampleRanges`). These checks are queries only. The read itself still goes through `GuestMemory::Read`; the extra bytes are then copied directly, without its flush and read guard. - The vertex path passes the end of the attribute descriptors' range as the limit (`VertexDescriptorEnd`), using the smallest end when a copy merges several attributes. The limit is cut at any color, depth, stencil or HTILE address past the read. Indirect draws and index copies do not grow. - A grown copy's device mirror (#16760) mirrors the whole copy, so it takes the same extra bytes in device memory. **Why a quarter.** It bounds the extra bytes when the descriptor is much larger than the read. In the earlier Sky Garden runs below, the limit, not the quarter, capped the growth: the second copy grew by about 9 %, which was enough for 22 copies of 32 MiB or more to become 3. A range that grows by more than its headroom on every draw gets copies longer than on `main` that are never reused. That costs memory and gains nothing. This PR claims no speed change. PPSA21564 (ASTRO BOT) stopped on these copies in Sky Garden on Windows with NVIDIA (traced below); two more levels stop on `main` on a full host heap and reach the cap with this change. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows only: Windows 10 Pro 10.0.19045, Ryzen 5 7600X, 31893 MiB of RAM, RTX 5070 Ti, NVIDIA 621.24, WinLibs GCC 15.2.0 (UCRT), Release, `BUILD_TESTING=ON`. Head `e78ae2ee05` on `main` `3c07e1d05e`; every result below is from this head and that `main`. Both build trees carried the same local test-only edit, not committed: a Windows `_putenv_s` in `UploadCacheReadOnlyFlush.cpp`, which does not build on Windows on this `main` (#19899, #22373). Others ran older heads: relativespace2K ([RX 6800 XT](https://github.com/boykopovar/AnyPS5/pull/19100#issuecomment-6834077887)) and JJenkx ([RX 6700 XT](https://github.com/boykopovar/AnyPS5/pull/19100#issuecomment-6837180414)) on Windows, and blawesom on Linux with RADV ([comment](https://github.com/boykopovar/AnyPS5/pull/19100#issuecomment-6874785541)). In blawesom's run the unit-shadow check skipped itself, since its block was not imported and watched; it ran here. `main` has since moved to `e35c90cfe3`. Among this PR's files it changed only `tests/Graphics.cpp` and `tests/Recorder.cpp`, and the branch merges with it without a conflict. I did not rerun the tests on that merge. **Tests** - `tools/select_tests.py` with the 19 files that differed from `upstream/main` at the time (the 9 of this PR and 10 from a newer `main`) selects 6171 tests; the 9 alone select 3245 of them. With `tools/select_tests.py ctest build`, the same 3 fail on both sides: `agc_driver_stencil_plane_memory`, `agc_driver_msaa_dcc_unwatch` and `agc_driver_bda_device`. On `main`, `agc_driver_image_table_packed_guards` also failed once; it passed 3 of 3 runs alone on each side. After every build, the staged `.prx` copies next to the test executables matched the rebuilt libraries. - `growingVertexCopyTests`, in `agc_driver_recorder`, uses a real device and a write-watched block. It checks that: - a first copy takes no headroom; - a longer read past an unchanged shorter copy gets a quarter more; - a later read inside the headroom reuses the grown copy, both as a host read and as a draw's read, which may get a device mirror, although a store landed in the headroom before that copy was made (only the grown collect saw it); - a read whose headroom holds a pending GPU write does not grow; - a read past the headroom grows again; - the limit caps the growth; - a changed shorter copy, a zero limit and an index copy take none; - a kept copy that starts past its address lets a longer one grow after a store below its start. - `grownVertexCopyShadowTests`, in `agc_driver_recorder`: a copy whose headroom ends before a fresh unit shadow grows; one whose headroom reaches it does not. - `validationTests`, in `agc_graphics_profile_draw`, checks without a device: `VertexDescriptorEnd`; `GrownVertexCopyBytes` (the quarter, the limit, the `DrawInputBudget` cap); `VertexCopyGrowEnd` (color, depth, stencil and HTILE cuts). - `VertexPlanScratchEmptiesEveryList`, in `agc_exclusive_scratch`, covers the two new plan lists. - 16 breaks of the change, one at a time, with the tests kept: 14 fail `agc_driver_recorder`, `agc_graphics_profile_draw` or `agc_exclusive_scratch`; the unchanged head passes before and after. Two pass: - `prepareDrawInputs` passing no limit. No unit test draws through that call; the title runs below do. - The guarded read also covering the headroom. It gives the same bytes as the direct copy, so no test can tell them apart; the direct copy only skips the flush and read guard over bytes the draw does not read. - Not tested one by one: the accessible, storage-image, resident-depth and host-only-sample checks on the headroom, and the registry and owned-input conditions of `ShorterDrawSnapshotKept`. The cut looks only at the address where a target starts; a target that starts below the read's end and reaches into the headroom is left to the pending-write and resident-depth checks. - Validation: `agc_driver_recorder` under `ctest -V` with `VK_ADD_LAYER_PATH` set to the layer, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_LAYERS_DISABLE=~implicit~ VK_LOADER_DEBUG=layer` and the Khronos Windows layer 1.4.368. On both sides it passes, the loader inserts the layer and no implicit layer: ``` [Vulkan Loader] INFO | LAYER: Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\AnyPS5Dev\tools\vvl-nightly-13e1d19f\layer\VkLayer_khronos_validation.dll) ``` Neither log has `was not found but was requested by env var VK_INSTANCE_LAYERS` or a `VUID-` line. The same settings over the 25 tests matching `^(agc_driver_recorder|agc_draw_inputs_.*|agc_owned_draw_inputs.*|agc_driver_vertex.*|agc_driver_draw_offset.*|agc_draw_snapshot.*)$` give the same on both sides: no `VUID-` line, 24 pass and `agc_driver_vertex_elected_atomic_max` skips. The loader inserts the layer in 22 of them; `agc_driver_vertex_table_read_order`, `agc_driver_vertex_table_read_order_counts_off` and `agc_draw_inputs_in_place_driver` print no loader line. The other new checks run without a device: `agc_graphics_profile_draw` uses `MockVulkan`. **Title.** PPSA21564 01.007.000, no input, muted, 300 s cap, 2 runs per level and side. One run dir and relinked executable from `main` `3c07e1d05e`; the sides differ only in `libSceAgcDriver.prx`. Runs alternate `main`, PR, `main`, PR, and share one shader cache, which was empty before the first `hero_ape_escape` run. No local print lines. The same two levels behaved the same on an older head, with pad input ([comment](https://github.com/boykopovar/AnyPS5/pull/19100#issuecomment-6859796079)). | level | `main` `3c07e1d05e` | this PR `e78ae2ee05` | |---|---|---| | `hero_ape_escape` | stop at 75 s and 33 s | 300 s cap, both runs | | `path_maker_mana_tree` | stop at 52 s and 34 s | 300 s cap, both runs | Times are the launcher's wall time. Every `main` run ends on a failed buffer allocation in heap 1, then `terminate called` on a `MemoryAllocationError`. The first `hero_ape_escape` run: ``` [gpu] driver failure: AGC graphics: vkAllocateMemory buffer: allocation=117440512 memoryType=3 reclaimed=0 released=229900288 initialResult=-2 attempts=2; heap 0 5217/15229 MiB; heap 1 15359/15085 MiB; heap 2 129/84 MiB: Vulkan result -2 ``` At every stop, heap 1 (the host heap, 15947 MiB here) was over its budget of 15084 to 15085 MiB. No run of this PR printed a failed allocation. I did not trace the copies in these two levels; the A/B shows only that the stop goes away with this change. Not tested with more RAM. <details><summary>Earlier runs: Sky Garden, on older heads</summary> PPSA21564 01.007.000, `-lvl underwater_aerial_garden`, no input, 3840x2160, 600 s cap, shader cache warmed by one discarded run. B1 is `main` + #18356 (`4a69efb803`). Every arm carried a local print line, not committed, that logs each draw input copy of 32 MiB or more. "End" is the launcher's wall time. | `main` | arm | end | copies of 32 MiB or more | |---|---|---|---| | `d4d6b64710` | B1 | stop at 348 s | 22 | | `d4d6b64710` | B1 + this PR (`067d9cb616`, a local commit, not pushed) | 600 s cap | 3 | | `d91bb06af9` | B1 | stop at 353 s | 22 | | `d91bb06af9` | B1 + earlier version | 600 s cap | 3 | | `d91bb06af9` | B1 + earlier version | 600 s cap | 3 | | `d91bb06af9` | B1 | stop at 326 s | 22 | | `d91bb06af9` | `main` | stopped; launcher time not recorded (log last written 572 s after start) | 20 | | `d91bb06af9` | `main` + earlier version | 600 s cap | 0 | The "earlier version" rows are `77f76c2429`, a local commit, not pushed: no unit-shadow check, a multisample query in place of `HostOnlySampleRanges`, and the whole range read through `GuestMemory::Read`. The `main` + earlier version run made no copy of 32 MiB or more, so that pair shows nothing either way. Local print lines on `main` `3c8b74996f` + #18356 showed that all 23 copies of 32 MiB or more start at `0x1078e68ca0` and grow from 76 to 133 MiB, about 2.9 GiB in all, within 1.48 s before the stop. In a later run they came from ordinary draws, and every lookup after the first found the previous copy kept, from the current registry and unchanged, but shorter. </details> **Overlap.** `tools/pr_overlap.py --branch` on this head finds three open pull requests that change the same lines, each for another purpose: #9915 (vertex out-of-bounds range checks), #19620 (unbounded indirect vertex inputs) and #21923 (queue worker lock contention). None gives a copy headroom; whichever merges second can rebase. It could not compare 65 others, which conflict with `main`. A search of their diffs for the copy, keep and lookup functions and the vertex copy plan finds three; the diffs of #7642 and #9508 (308 and 366 files) could not be fetched. #9712 and #15570 change the line in `CopyDrawInput` that creates the copy's buffer, and the draft #20315 adds a GPU copy before `CopyDrawInput` for ranges with a pending GPU write. #16879 replaces a kept snapshot's `registryGeneration`, which `ShorterDrawSnapshotKept` reads, with a `forgetSerial`; winstrex [agreed](https://github.com/boykopovar/AnyPS5/pull/16879#issuecomment-6839477604) that it goes first, and this PR takes that change when it rebases onto it. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.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: #16879 - [x] Fixes: none - [x] Unblocks: PPSA21564 #357 - [x] GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 621.24, Windows 10 Pro 10.0.19045 - [x] AI-assisted: yes. Claude Code traced the stop with local print lines (not committed), wrote the change and the tests, rebased them, and ran the tests, mutation checks, validation runs and title A/B above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-12 19:51:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T19:51:57Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head d5257453547598b651ce41f02b7ca4b5e4caaf03 (PR 19100 against main). Read the title and description, the commit, the manifest, and the full diff.
  • Checked the code at the head around each changed hunk with the reader:
repo_read.py search "CopyGuestBytes" core/libs/prx/libSceAgcDriver
repo_read.py search "DrawInputBudget" core/libs/prx/libSceAgcDriver
repo_read.py search "GuestWritesPendingIn" core/libs/prx/libSceAgcDriver
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp 1462 1500
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp 1940 2030
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp 3300 3345
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp 112 140
repo_read.py cat core/libs/prx/libSceAgcDriver/tests/Graphics.cpp 12262 12276
  • No build and no test was run in this review.

Results

Check Result Note
Diff read passed All hunks in the 7 reviewed files
Names and signatures the diff uses passed Found at head
Description claims against the code passed Caps, cut addresses and guards match; see Findings
Build not run
Unit tests not run Author reports them on Windows only

Findings

Blocking

None.

Non-blocking

  1. core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:2018 — The cut at render-target, depth, stencil and HTILE addresses (lines 2018–2024) has no test. The author's mutation checks say the same. If the cut were dropped, the two new tests would still pass. The DrawInputBudget cap (Draw.cpp:1485), the unit-shadow check (Draw.cpp:1453) and the tail copy (Draw.cpp:1496) are untested too.

Sources

Not verified

  • Build and tests were not run. The author's results (agc_driver_recorder and agc_graphics_profile_draw on the rebased head d525745354, and the ctest run of 2732 passes) are author reports, not runs by this review.
  • The performance figures and the title A/B table in the description are not checked. The PR claims no speed change.
  • The tail copy at Draw.cpp:1496 skips the GuestMemory::Read guard. Its safety depends on the generation collected at Draw.cpp:1486 before the copy. I did not check the write-watch timing.
  • The cut at Draw.cpp:2016 covers only addresses at or above the read end. A depth, stencil or HTILE surface that starts lower and reaches into the headroom relies on ResidentDepthGuardOverlaps_nid_no_patch and the pending-write checks. Not verified.
  • Files read: the changed hunks of all 7 reviewed files, and head ranges through the reader. tests/Graphics.cpp and tests/Recorder.cpp were read only as diff hunks; their full text is too large for the review folder and was not read.
  • The overlapping PRs named in the description (#9712, #16760, #18287, #9875, #9915, #13809, #15570) were not checked.

To get this to a good state

Nothing is required. The test-coverage point in Findings is optional.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5881063128 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19100#pullrequestreview-5881063128). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T19:51:57Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. ## What I ran - Head `d5257453547598b651ce41f02b7ca4b5e4caaf03` (PR 19100 against `main`). Read the title and description, the commit, the manifest, and the full diff. - Checked the code at the head around each changed hunk with the reader: ``` repo_read.py search "CopyGuestBytes" core/libs/prx/libSceAgcDriver repo_read.py search "DrawInputBudget" core/libs/prx/libSceAgcDriver repo_read.py search "GuestWritesPendingIn" core/libs/prx/libSceAgcDriver repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp 1462 1500 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp 1940 2030 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp 3300 3345 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp 112 140 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/Graphics.cpp 12262 12276 ``` - No build and no test was run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff read | passed | All hunks in the 7 reviewed files | | Names and signatures the diff uses | passed | Found at head | | Description claims against the code | passed | Caps, cut addresses and guards match; see Findings | | Build | not run | | | Unit tests | not run | Author reports them on Windows only | ## Findings ### Blocking None. ### Non-blocking 1. `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:2018` — The cut at render-target, depth, stencil and HTILE addresses (lines 2018–2024) has no test. The author's mutation checks say the same. If the cut were dropped, the two new tests would still pass. The `DrawInputBudget` cap (`Draw.cpp:1485`), the unit-shadow check (`Draw.cpp:1453`) and the tail copy (`Draw.cpp:1496`) are untested too. ## Sources - [`CopyDrawInput` growth step](https://github.com/boykopovar/AnyPS5/blob/d5257453547598b651ce41f02b7ca4b5e4caaf03/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L1478-L1496) - [Limit from the descriptor end and the cut](https://github.com/boykopovar/AnyPS5/blob/d5257453547598b651ce41f02b7ca4b5e4caaf03/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L1981-L2025) - [Kept shorter copy and pending-write query](https://github.com/boykopovar/AnyPS5/blob/d5257453547598b651ce41f02b7ca4b5e4caaf03/core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp#L3316-L3326) - [`VertexDescriptorEnd`](https://github.com/boykopovar/AnyPS5/blob/d5257453547598b651ce41f02b7ca4b5e4caaf03/core/libs/prx/libSceAgcDriver/Graphics/include/VertexInput.hpp#L307-L315) ## Not verified - Build and tests were not run. The author's results (`agc_driver_recorder` and `agc_graphics_profile_draw` on the rebased head `d525745354`, and the ctest run of 2732 passes) are author reports, not runs by this review. - The performance figures and the title A/B table in the description are not checked. The PR claims no speed change. - The tail copy at `Draw.cpp:1496` skips the `GuestMemory::Read` guard. Its safety depends on the generation collected at `Draw.cpp:1486` before the copy. I did not check the write-watch timing. - The cut at `Draw.cpp:2016` covers only addresses at or above the read end. A depth, stencil or HTILE surface that starts lower and reaches into the headroom relies on `ResidentDepthGuardOverlaps_nid_no_patch` and the pending-write checks. Not verified. - Files read: the changed hunks of all 7 reviewed files, and head ranges through the reader. `tests/Graphics.cpp` and `tests/Recorder.cpp` were read only as diff hunks; their full text is too large for the review folder and was not read. - The overlapping PRs named in the description (#9712, #16760, #18287, #9875, #9915, #13809, #15570) were not checked. ## To get this to a good state Nothing is required. The test-coverage point in Findings is optional.
MarcZX10 commented 2026-11-13 23:00:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-13T23:00:39Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the source inspected supports the copy headroom guards, and the author reports focused tests and validation on this head.

What I ran

Read the prepared diff and source context at head 20d136c3379fd699fd01d8996e94dc3798748e02. No commands or tests were run.

Results

Check Result Note
Source review passed Core copy and recorder logic inspected
Tests not run Test results are author reported
Changed tests not verified Full test files excluded from review folder

Findings

Blocking

None.

Non-blocking

None.

Not verified

tests/Graphics.cpp and tests/Recorder.cpp were excluded from the prepared review folder because they were too large. Their diff hunks were read, but their surrounding test code was not. No build, tests, or title run was performed by me. The description reports focused tests, mutation checks, and Vulkan validation on this head; those results were not independently verified. description.md, commits.md, manifest.json, diff.patch, Draw.hpp, Recorder.hpp, VertexInput.hpp, Draw.cpp, and Recorder.cpp were read; no changed files were omitted from the manifest.

To get this to a good state

Nothing is required. Optional: add or retain call-site coverage for the render-target cut and budget cap, which the description says are not exercised by tests at the draw call.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5899255034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19100#pullrequestreview-5899255034). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-13T23:00:39Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the source inspected supports the copy headroom guards, and the author reports focused tests and validation on this head. ## What I ran Read the prepared diff and source context at head `20d136c3379fd699fd01d8996e94dc3798748e02`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Core copy and recorder logic inspected | | Tests | not run | Test results are author reported | | Changed tests | not verified | Full test files excluded from review folder | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `tests/Graphics.cpp` and `tests/Recorder.cpp` were excluded from the prepared review folder because they were too large. Their diff hunks were read, but their surrounding test code was not. No build, tests, or title run was performed by me. The description reports focused tests, mutation checks, and Vulkan validation on this head; those results were not independently verified. `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `Draw.hpp`, `Recorder.hpp`, `VertexInput.hpp`, `Draw.cpp`, and `Recorder.cpp` were read; no changed files were omitted from the manifest. ## To get this to a good state Nothing is required. Optional: add or retain call-site coverage for the render-target cut and budget cap, which the description says are not exercised by tests at the draw call.
MarcZX10 commented 2026-11-19 04:50:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T04:50:06Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change based on the code inspected; approval is not justified because two changed test files were not fully read and no checks were run.

What I ran

  • Reviewed head e78ae2ee05b9de7e0146afcb5e14af11aa1412ab using the pinned repo_read.py reader.
  • Read the prepared description, commits, manifest, diff, and all seven changed files included in the review folder. Read targeted ranges from the two excluded test files.
  • No build or test commands were run.

Results

Check Result Note
Diff and source review passed Core change and targeted context inspected
Build and tests not run Author reports test results in the description
Excluded test files not run Targeted ranges only; full files not read

Findings

Blocking

None identified in the code inspected.

Non-blocking

None.

Not verified

  • The full contents of tests/Graphics.cpp and tests/Recorder.cpp were excluded from the review folder; only relevant ranges were read through the reader. The remaining portions of those files were not reviewed.
  • Build, tests, validation-layer checks, and title runs were not performed by this review. Results described by the author were not independently verified.
  • No merged-preview check was performed against the newer main head mentioned in the description.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969487167 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19100#pullrequestreview-5969487167). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T04:50:06Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change based on the code inspected; approval is not justified because two changed test files were not fully read and no checks were run. ## What I ran - Reviewed head `e78ae2ee05b9de7e0146afcb5e14af11aa1412ab` using the pinned `repo_read.py` reader. - Read the prepared description, commits, manifest, diff, and all seven changed files included in the review folder. Read targeted ranges from the two excluded test files. - No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | Core change and targeted context inspected | | Build and tests | not run | Author reports test results in the description | | Excluded test files | not run | Targeted ranges only; full files not read | ## Findings ### Blocking None identified in the code inspected. ### Non-blocking None. ## Not verified - The full contents of `tests/Graphics.cpp` and `tests/Recorder.cpp` were excluded from the review folder; only relevant ranges were read through the reader. The remaining portions of those files were not reviewed. - Build, tests, validation-layer checks, and title runs were not performed by this review. Results described by the author were not independently verified. - No merged-preview check was performed against the newer `main` head mentioned in the description. ## To get this to a good state Nothing is required.
Superseabas commented 2026-11-22 12:58:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-22T12:58:53Z.

Review: APPROVED


Windows check of head e78ae2ee05 with GCC 16, on an NVIDIA GPU and on an AMD one. The AMD runs in the thread are of older heads. Merged onto main e493612311 (clean merge).

Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release full build, run from PowerShell with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. GPUs, each picked with ANYPS5_GPU: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (1002:164e, Adrenalin 26.10.2). This was built together with #24906, which touches other files.

  • agc_driver_recorder (with growingVertexCopyTests), agc_driver_graphics and agc_exclusive_scratch: all pass on both GPUs, on main and with this PR, in 3 of 3 runs, with no VUID- lines.
  • Red check: with GrownVertexCopyBytes never growing (if (growLimit <= bytes) return bytes; → return bytes;), agc_driver_recorder fails on the Radeon with "a vertex copy past an unchanged shorter one took no headroom".

The growth conditions read well to me. It only grows a vertex copy past an unchanged, shorter kept copy at the same address, by at most a quarter, within DrawInputBudget and the attribute descriptors' end. It stops at any color, depth, stencil or HTILE address, and only when the extra bytes have no pending write, storage result, unpublished unit shadow, resident depth or host-only samples. The extra bytes are collected with the read, so the kept copy's generation covers them.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012384592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19100#pullrequestreview-6012384592). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-22T12:58:53Z. **Review:** APPROVED --- Windows check of head `e78ae2ee05` with GCC 16, on an NVIDIA GPU and on an AMD one. The AMD runs in the thread are of older heads. Merged onto `main` `e493612311` (clean merge). **Setup:** Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release full build, run from PowerShell with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. GPUs, each picked with `ANYPS5_GPU`: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (`1002:164e`, Adrenalin 26.10.2). This was built together with #24906, which touches other files. - `agc_driver_recorder` (with `growingVertexCopyTests`), `agc_driver_graphics` and `agc_exclusive_scratch`: all pass on both GPUs, on `main` and with this PR, in 3 of 3 runs, with no `VUID-` lines. - **Red check:** with `GrownVertexCopyBytes` never growing (`if (growLimit <= bytes) return bytes;` → `return bytes;`), `agc_driver_recorder` fails on the Radeon with "a vertex copy past an unchanged shorter one took no headroom". The growth conditions read well to me. It only grows a vertex copy past an unchanged, shorter kept copy at the same address, by at most a quarter, within `DrawInputBudget` and the attribute descriptors' end. It stops at any color, depth, stencil or HTILE address, and only when the extra bytes have no pending write, storage result, unpublished unit shadow, resident depth or host-only samples. The extra bytes are collected with the read, so the kept copy's generation covers them. AI-assisted: yes (Claude Code)
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!19100
No description provided.