perf(agc): record buffer fills across several host imports on the GPU #22001
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22001"
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 talha-devp on 2026-11-17T01:14:23Z.
What
A buffer fill (CP DMA fill or a recognized fill kernel,
VulkanDevice::FillBuffer) whose range no single host import covers was refused, even when existing imports cover it contiguously: two adjacent registered ranges, each imported on its own. The caller then waited for the GPU to go idle (WaitIdle) and stored the fill on the CPU.FillBuffernow plans the fill over the existing imports first: when the range has no single import, it walks the imports that hold it (ExistingHostImportFor), one piece per import, and refuses unless every piece has an import and every piece boundary stays 16-byte aligned to the fill (so the pattern phase is kept). Nothing is recorded before the plan is complete. The pieces are then recorded between the same barriers as a single fill (uniform fills withvkCmdFillBuffer, 16-byte patterns from the cached pattern buffer or, withAPS5_FILL_CHAIN=1, seeded and doubled per piece). The pending-write checks,SyncThrough, key and label flushes, the pending-write note and the write stamp cover the whole range as before. After a sync the plan is made again, as the single import is looked up again today. A range with a part that has no import is still refused and stored by the caller as before. A fill split this way is not elided as a repeat: the repeat check compares one import serial, and a split fill has none.Seen in Astroneer (PPSA27623, #21967): the per-frame 640 KiB fill straddles two GPU-mapped ranges (0x90000 imported at map time during loading and the next range imported later) in some launches; in a profiled one, 798 of 5237 fills went to the CPU at about 7.4 ms each.
No import is made or replaced. A joined import (
importJoined, which #6197 exposes asHostImportSpanningfor storage surfaces) could cover this layout too, but it retires the two existing imports and imports the joined range anew, andjoinedRuntakes only some layouts (a run that starts where the access starts, or ranges larger than the 8 MiB window). Recording per existing import leaves the import table as it is. #17255 walks existing imports the same way for sampled texture uploads (ExistingHostImportCopies, not merged); this PR uses only the existingExistingHostImportForand does not touchGuestBufferMemory.Tested
Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 4060, driver 621.14.
GPU tests, same build directory,
main(258ab7b6bdplus the new test) and this PR (then on258ab7b6bd; rebased ontoab5089590a, whose new commits change no file oflibSceAgcDriver),ctest -R <50 fill, copy, import and label tests> -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(validation layer 1.4.363):main: 48 of 50 passed; the two failures are the newagc_driver_fill_across_importsand_chain("a uniform fill across two imports was not stored on the GPU"). 0VUID-lines, the layer inserted 77 times,was not found but was requested0 times.VUID-lines, the layer inserted 77 times,was not found but was requested0 times.The new test registers two adjacent ranges of 0x90000 and 0x50000 bytes and checks the import layout it needs (each range imported on its own, no import over both). A fill across the boundary is refused and leaves the memory unchanged while the second range has no import. With both imported, a uniform fill and a 16-byte pattern fill are recorded on the GPU (the recorder holds work after the call) and the bytes are checked across the boundary, with the bytes before and after the fill left alone.
_chainruns the same withAPS5_FILL_CHAIN=1.Astroneer (PPSA27623), opening cutscene, no input, 120 s per launch, cold and warm launch pairs in the order base, change, change, base (the second round's warm launch crashed in the title's
FAsyncLoadingThreadat 15 s, before any fill was split, and that round was run again),APS5_PIPELINE_STATS=1only. Base:main459f4f8c22with #16053 reverted, because plainmainaborts or draws this scene wrongly (#21967); change: the same plus this PR. Both arms carry a counter of CPU-stored fills that is not part of this PR. Which layout a launch gets is decided by the title's memory layout, so not every launch splits the fill. FPS is the cutscene window 30-100 s of the summary clock, fill commit cost the[commits]line'sbufferfillmean over 30-90 s.The base arm got no split layout in this set, so this set has no FPS comparison of that layout. Earlier the same night, on the base without the counter, a warm launch with the split layout had fill commits of 1425-1568 us at 9.64 FPS, and a profiled one stored 1136 of 7434 fills on the CPU. With this PR the split fills are recorded on the GPU and cost what a fill through one import costs. The one split-layout warm launch (10.16 FPS) lies inside the spread of one-import warm launches on this machine the same night (10.16 to 12.81 FPS, 7 launches) but at its low end.
trace_digest.pyof the summary files (the 100:10 trace window ended after the 120 s launches, so no window trace was written):Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:11:55Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the targeted code review supports merging, while the reported test runs were supplied by the author.
What I ran
Reviewed head
06310d94758cb162afe4b2560a12476983a78312usingrepo_read.pyto inspect the prepared diff and changed code. No commands or tests were run in this review.Read:
description.md,commits.md,manifest.json,diff.patch,VulkanDevice.cpp(the changed fill path), andFillAcrossImports.cpp. The full source file was excluded from the review folder because it was too large, so it was read through the pinned repository reader. The CMake registration file was in the review bundle but not read. No other changed files were listed in the manifest.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run tests, build the change, or verify the reported GPU, game, and performance results. I did not inspect the test registration CMake file. The review did not cover the remainder of
VulkanDevice.cppor unrelated repository code.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:13:42Z.
Review: COMMENTED
The trial merge onto
a1b75b0947conflicts inVulkanDevice.cpp. When integrating the current fill path, preserve the preflight of the entire address range before any GPU command is recorded. Keep the 16-byte pattern phase continuous across adjacent imports and keep the gap case that rejects the fill without recording a prefix. Please rerunFillAcrossImportsand the existing buffer-fill controls on the merged head.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.