perf(agc): read draw vertex and index buffers in place from host imports #2253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2253"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-09T13:14:02Z.
What
Every draw copies its index range and each of its vertex ranges out of guest memory into a new host buffer (
CopyDrawInput) before the GPU can read them. A range that lies in a host import is now bound from the import itself, at its offset in it. That's also how the console reads them: the input assembler fetches straight from guest memory, with no copy step.FlushGpuWritesthe copy does, which waits for such a write), no completion label, no queued label store, no copied buffer a dispatch or draw writes back. Otherwise it's copied as before.PlanVertexCopiesnow records that alignment per range (VertexCopyPlan::alignments).Recorder::ReadKind::DrawInput), so a CPU store into the range waits for the draw like the other in-place readers, and the barrier validation sees it. The import's buffer stays alive until the batch completes the same way it does for those readers (retireImport).VERTEX_BUFFERandINDEX_BUFFERusage.#1968 and #1769 changed the same loops in
prepareDrawInputsand have merged. The in-place index scan uses #1968'sHighestDrawIndex, so a primitive restart index is left out of the vertex range whether the indices are copied or bound in place. Attributes whose fetch is out of range still get #1769's zero buffers; only ranges that are actually read can be bound in place. #1969 (null V#s) changes the same loop, so whichever of the two lands second needs a rebase.PPSA36082
Hades II issues thousands of small draws a frame from vertex and index data in GPU-mapped memory. On main
f1451396with the fixes it needs to reach gameplay, it ran at about 2 fps, and the frame time went to copying draw inputs. With this change it ran at 27-30 fps in the same scene (MangoHud). The previous head of this PR (0e9769bd), on maind70b8998with the rest of what Hades needs (including #1810), ran gameplay at 40-45 fps with no skipped draws, so the alignment check doesn't cost it anything. The rebase onto current main changed only how the index and vertex paths fit #1968's and #1769's code, not what is bound in place.Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090.
agc_driver_graphics(new checks): a merged vertex range takes the strictest alignment of its attributes.agc_driver_recorder_tests(newdrawInputInPlaceTests, over a write-watched block registered and imported like the other draw input tests):agc_driver_recorder_testsruns in ctest only as--pipeline-cache-only, so I ran the whole binary by hand.drawInputInPlaceTestspasses. The binary then stops atstorageRefreshTests("the refresh's store of the results did not reach guest memory"), and current main without this change stops at the same check.build.yml, run locally on this head (current mainbc40a6b5plus this commit): 597/598. The one failure isagc_driver_dcc_keys_first_write, which fails the same way on main without this change on this machine (RTX 4090) and passes in GitHub's CI.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:25:05Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
0e9769bd, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.agc_driver_graphics. None of them reported skipping a case.agc_driver_recorder_tests(not in ctest), built explicitly: 10 of 10. #2248 and #2299 were merged too, becausemainfails that test for other reasons (#2155).PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:18:57Z.
Checked on current main (merges cleanly): libSceAgcDriver build and ctest 277/277, the new
agc_driver_graphicsalignment checks fail to build without the change, and the fullagc_driver_recorder_testsbinary run by hand passesdrawInputInPlaceTests(it stops later atstorageRefreshTests, as on main). Also covered by popcoder565's Windows run on the previous head.Not covered by tests: the offset/handle arithmetic in
prepareDrawInputsitself (onlyInPlaceDrawInputis pinned). Merging; whichever of this and #1969 lands second needs a rebase (same loop,tests/Graphics.cpp, TechnicalDebt).