perf(agc): bind a vertex range under a pending GPU write in place where draw inputs are copied #20578

Merged
SP4C3B4R-8 merged 1 commit from upstream-pr/20578 into main 2026-11-16 06:35:23 +00:00
SP4C3B4R-8 commented 2026-11-15 10:17:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-11-15T10:17:51Z.


What

Where draw inputs are copied (NVIDIA's Windows driver, DrawInputsInPlaceUsable), a vertex range that GPU work still writes was copied too: CopyDrawInput first lands the pending write (GuestMemory::FlushGpuWrites) and then copies the range on the CPU, at every draw that reads it. The in-place path already binds such a range ordered behind the write on the GPU (behindGpuWrite, used where inputs are in place), so InPlaceDrawInput now takes that path there too:

  • a vertex range under a pending GPU write is bound in place behind it;
  • vertex ranges free of pending writes and all index ranges are still copied, as before;
  • every other refusal of the in-place path stays (pending label, queued store, copied writers, import alignment) and the read is noted with NotePendingRead.

APS5_NO_BEHIND_INPUTS_IN_PLACE copies those ranges as before, and so does APS5_NO_DRAW_INPUTS_IN_PLACE. The variable is listed in docs/dev/ENVIRONMENT.md.

Tested

Windows 11 Pro, Ryzen 7 7800X3D, GeForce RTX 5070 Ti (NVIDIA 610.88), a retail 3D title launched straight into a level, APS5_HOST_IMPORT_MIB=14336 APS5_TEXTURE_CACHE_MIB=3584, otherwise defaults (label readback store on), main 78276498ec against this PR on the same base (only libSceAgcDriver.prx differs), runs alternated A B B A, 10 s intervals from APS5_TRACE_SUMMARY_EVERY=10 after the level loaded:

heaviest level, 200 s runs main this PR
fps, run 1 / run 2 (mean of 10 s intervals, ~80-185 s) 4.59 / 4.63 5.35 / 5.30
interval range 4.36-4.90 5.09-5.48
Graphics.Draw ms per frame (draw committer) 145 / 143 115 / 113
of which vertex_upload 43 / 42 7.5 / 7.5
GPU busy ms per frame 165 / 165 163 / 164
lighter level, 150 s run main this PR
fps, steady intervals 12.4-12.5 12.4-12.5

The lighter level has no vertex reads behind pending writes (vertex_upload 3.5 ms per frame on both). The same change has been in my local build of this title since early November with no visible differences in either level.

Tests, same machine, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R '^(agc_draw_inputs_in_place_driver|agc_owned_draw_inputs.*|agc_draw_inputs_in_place|agc_draw_inputs_copied|agc_draw_input_reuse|agc_vertex_input.*|agc_driver_native_msaa_vertex_input|agc_driver_prepared_shaders_abi_deferred_vertex_inputs)$' -V: 13/13 passed, no VUID- lines. agc_draw_inputs_copied now also checks that, with inputs copied, a vertex range free of pending writes is still copied, an index range under a pending write is still copied, and a vertex range under a pending write is bound in place behind it with its read noted and released at Sync. Negative control: with Draw.cpp from main the test fails with a vertex input under a pending GPU write was copied where draw inputs are copied, instead of being bound in place behind the write.

tools/pr_overlap.py: #19445 (mine, large vertex ranges in place) and #20368 (small, rarely read inputs in place) change the same first line of InPlaceDrawInput, and #20368 also the copied-input test in tests/Recorder.cpp. The three conditions are independent (behind a pending write; large; small and rarely read); whichever lands first, I rebase this one 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
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 610.88, Windows 11 Pro
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01DuBfeX7nBanPGcc6DyPSXW

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5321728329 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20578). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-11-15T10:17:51Z. --- ### What Where draw inputs are copied (NVIDIA's Windows driver, `DrawInputsInPlaceUsable`), a vertex range that GPU work still writes was copied too: `CopyDrawInput` first lands the pending write (`GuestMemory::FlushGpuWrites`) and then copies the range on the CPU, at every draw that reads it. The in-place path already binds such a range ordered behind the write on the GPU (`behindGpuWrite`, used where inputs are in place), so `InPlaceDrawInput` now takes that path there too: - a vertex range under a pending GPU write is bound in place behind it; - vertex ranges free of pending writes and all index ranges are still copied, as before; - every other refusal of the in-place path stays (pending label, queued store, copied writers, import alignment) and the read is noted with `NotePendingRead`. `APS5_NO_BEHIND_INPUTS_IN_PLACE` copies those ranges as before, and so does `APS5_NO_DRAW_INPUTS_IN_PLACE`. The variable is listed in `docs/dev/ENVIRONMENT.md`. ### Tested Windows 11 Pro, Ryzen 7 7800X3D, GeForce RTX 5070 Ti (NVIDIA 610.88), a retail 3D title launched straight into a level, `APS5_HOST_IMPORT_MIB=14336 APS5_TEXTURE_CACHE_MIB=3584`, otherwise defaults (label readback store on), `main` 78276498ec against this PR on the same base (only `libSceAgcDriver.prx` differs), runs alternated A B B A, 10 s intervals from `APS5_TRACE_SUMMARY_EVERY=10` after the level loaded: | heaviest level, 200 s runs | `main` | this PR | |---|---|---| | fps, run 1 / run 2 (mean of 10 s intervals, ~80-185 s) | 4.59 / 4.63 | 5.35 / 5.30 | | interval range | 4.36-4.90 | 5.09-5.48 | | `Graphics.Draw` ms per frame (draw committer) | 145 / 143 | 115 / 113 | | of which `vertex_upload` | 43 / 42 | 7.5 / 7.5 | | GPU busy ms per frame | 165 / 165 | 163 / 164 | | lighter level, 150 s run | `main` | this PR | |---|---|---| | fps, steady intervals | 12.4-12.5 | 12.4-12.5 | The lighter level has no vertex reads behind pending writes (`vertex_upload` 3.5 ms per frame on both). The same change has been in my local build of this title since early November with no visible differences in either level. Tests, same machine, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R '^(agc_draw_inputs_in_place_driver|agc_owned_draw_inputs.*|agc_draw_inputs_in_place|agc_draw_inputs_copied|agc_draw_input_reuse|agc_vertex_input.*|agc_driver_native_msaa_vertex_input|agc_driver_prepared_shaders_abi_deferred_vertex_inputs)$' -V`: 13/13 passed, no `VUID-` lines. `agc_draw_inputs_copied` now also checks that, with inputs copied, a vertex range free of pending writes is still copied, an index range under a pending write is still copied, and a vertex range under a pending write is bound in place behind it with its read noted and released at `Sync`. Negative control: with `Draw.cpp` from `main` the test fails with `a vertex input under a pending GPU write was copied where draw inputs are copied, instead of being bound in place behind the write`. `tools/pr_overlap.py`: #19445 (mine, large vertex ranges in place) and #20368 (small, rarely read inputs in place) change the same first line of `InPlaceDrawInput`, and #20368 also the copied-input test in `tests/Recorder.cpp`. The three conditions are independent (behind a pending write; large; small and rarely read); whichever lands first, I rebase this one 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) - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 610.88, Windows 11 Pro - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DuBfeX7nBanPGcc6DyPSXW
MarcZX10 commented 2026-11-15 10:44:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T10:44:55Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation and its pending-read tracking support merging, while the added test source was not fully reviewed.

What I ran

Reviewed head 4218279d2efc97a37495ee2b90d0f9c80ba4eb29 using repo_read.py to inspect the prepared diff and targeted source ranges. I ran no build or tests; the test results in the PR description are author-reported.

Results

Check Result Note
Diff and source review passed Implementation and environment entry read
Build and tests not run Reported results are author-supplied
Changed test source not run Full file excluded from review folder

Findings

Blocking

None identified in the inspected implementation.

Non-blocking

None.

Not verified

The changed test file core/libs/prx/libSceAgcDriver/tests/Recorder.cpp was excluded as too large; its added lines were visible in the diff, but the full source and surrounding test setup were not inspected. No tests, build, hardware, or console behavior were run or confirmed. docs/dev/ENVIRONMENT.md and core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp were read; the test file was not fully read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5910300328 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20578#pullrequestreview-5910300328). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T10:44:55Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation and its pending-read tracking support merging, while the added test source was not fully reviewed. ## What I ran Reviewed head `4218279d2efc97a37495ee2b90d0f9c80ba4eb29` using `repo_read.py` to inspect the prepared diff and targeted source ranges. I ran no build or tests; the test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | Implementation and environment entry read | | Build and tests | not run | Reported results are author-supplied | | Changed test source | not run | Full file excluded from review folder | ## Findings ### Blocking None identified in the inspected implementation. ### Non-blocking None. ## Not verified The changed test file `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` was excluded as too large; its added lines were visible in the diff, but the full source and surrounding test setup were not inspected. No tests, build, hardware, or console behavior were run or confirmed. `docs/dev/ENVIRONMENT.md` and `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` were read; the test file was not fully read. ## To get this to a good state Nothing is required.
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!20578
No description provided.