perf(agc): fall back to joined host imports in VulkanDevice::FillBuffer #27252
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27252"
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 birdmarty on 2026-11-25T15:46:41Z.
What
VulkanDevice::FillBufferlooks up the target range withGraphics::HostImportFor(context, address, bytes)and returnsfalsewhen it isnullptr. The caller (Driver::storeBufferFill) then callslocalDevice->WaitIdle()underGpuMutexand writes the fill from the CPU, draining the GPU pipeline on every fill.When a filled range spans two adjacent writable
GuestAllocationsranges that were imported separately (for example, a 224 KiB DCC metadata key buffer in Lies of PPPSA10621at0x209a7f0000+0x38000crossing a0x30000allocation and its adjacent0x8000neighbour),HostImportForreturnsnullptrbecause no single existing import covers the straddling range.Graphics::HostImportJoinedFor(context, address, bytes)already exists inGuestBufferMemory(used byShaderResources.cpp) to join adjacent writable allocations into a singleHostImport. Falling back toHostImportJoinedForwhenHostImportForreturnsnullptrkeeps the fill on the GPU in a singlevkCmdFillBuffer/vkCmdCopyBuffer, avoidsWaitIdle(), and preservesrepeatedFillselision.Note on open draft PR #22001: #22001 splits fills across already-existing imports via
ExistingHostImportFor, which still leftRecorder.Sync = 6.26 ms/fin Lies of P when tested on61250ca018.HostImportJoinedForimports and joins the range on first use so subsequent fills hitHostImportFordirectly on the GPU.Changes
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp: inVulkanDevice::FillBuffer, fall back toGraphics::HostImportJoinedFor(context, address, bytes)whenGraphics::HostImportFor(context, address, bytes)returnsnullptr(both before and afterSyncThrough).core/libs/prx/libSceAgcDriver/tests/execution/RepeatedFillElision.cpp: addFillSpanningAdjacentAllocations, importing two adjacent writable guest allocations separately and verifying that a fill straddling their boundary runs on the GPU without falling back.Tested
Windows 11 Pro (build 26300), i9-9900K, MinGW-w64 GCC 15.3.0, Release build, AMD Radeon RX 6800 (
vendor=0x1002,device=0x73bf), AMD proprietary driver26.10.1(Windows driver32.0.21045.16010, Vulkan1.4.315).Unit tests on
5163b0d90d(baseorigin/mainc032ba7c52) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK1.4.363.0),VK_LOADER_DEBUG=layer:ctest -R "^agc_driver_repeated_fill_elision$": passed,Insert instance layer "VK_LAYER_KHRONOS_validation"confirmed, 0VUID-errors.origin/main'sVulkanDevice.cpp: fails withAGC graphics: repeated fill elision: a fill spanning adjacent guest allocations fell back off the GPU.tools/check_conventions.py --base origin/main: passed.tools/debt_fold.py --check: passed.Lies of P (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza):61250ca018):1,704–3,800+CPUBufferFillfallbacks per run (11.6 scumulativeGpuMutexhold,Recorder.Sync = 4.0–6.6 ms/f,bufferfillcommit average529.2 µs).HostImportJoinedForfallback (measured in stack on61250ca018+ #20130 + #18757 + #27249):40,303fills (44,532 MiB) with only3CPU fallbacks over the entire run (25 mstotal hold),bufferfillcommit average81.3 µs(6.5× faster),Recorder.Sync = 0.00 ms/f,6,546repeated fills elided (631 MiB).Performance captures (
APS5_TRACE_SECONDS=120:30, clean warm shader cache, no extraAPS5_TRACE_*orAPS5_PROFILE_*switches)Same machine, title (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza), and flags (APS5_DRAW_PIPELINE=1 APS5_NO_DRAW_STAGING=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1 APS5_FAST_F32=1):main,c032ba7c52):9.00 FPS,p50 110.5 ms,p90 117.7 ms,max 151.1 ms,gpu 70.31 ms/f,Graphics.Draw 72.33 ms/f(aps5-trace-c032ba7c5273-23148.json.gz).5163b0d90d):9.09 FPS(+0.09),p50 107.6 ms(-2.8 ms),p90 117.9 ms(+0.2 ms),max 192.9 ms,gpu 69.06 ms/f(-1.25 ms/f),Graphics.Draw 75.40 ms/f(+3.07 ms/f) (aps5-trace-5163b0d90de3-33260.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(5163b0d90d):Series context & interleaved ablation
This PR is part of a general AGC/libc performance series measured on Lies of P (
PPSA10621,v01.012.000,3200x1800, UE4) covering #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, and #27273 (tested together with #20130, #18757, #26778, #27117, and now-merged #26581 and #26681). Combined on base61250ca018(plus remaining unsplit stack changes), steady-state performance rose from7.25 FPS(p50 135.6 ms,gpu 92.7 ms/f, default settings) to12.15 FPSaverage (12.00/12.30 FPS, peak12.33 FPS,p50 81.5 ms,gpu 57.12 ms/f,+67.6%to+70.1%).Because five of the smaller PRs (#27253, #27254, #27270, #27271, and #27273) looked like they slightly lost average FPS (
-0.03to-0.31 FPS) in single isolated runs onc032ba7c52, we ran an interleaved 4-run ablation (A1 -> B1 -> A2 -> B2,APS5_TRACE_SECONDS=120:30, identical warm shader cache and flags) on the full stack to test whether removing those 5 PRs helped or hurt:61250ca018(WITH all 11 PRs): #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, #27273 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes (per-64 KiB proof/pending tracking and ShapeRecipe).61250ca018MINUS the 5 PRs (#27253, #27254, #27270, #27271, #27273): keeps #27249, #27250, #27251, #27252, #27268, #27269 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes.DrawWithRecipe(ms/f)DrawFinish(ms/f)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)+0.39 FPS(+3.3%)-2.1 ms-4.6 ms-10.5 ms-3.21 ms/f-1.02 ms/f-0.88 ms/fRemoving those 5 PRs hurt every run (
A1 > B1andA2 > B2across all metrics), showing that their single-run isolated dips onc032ba7c52were within±0.25 FPSscene variance while larger bottlenecks (#27268, #27249, #27252, #20130, #18757) still dominated. Individual PR captures above remain isolated againstc032ba7c52.Not tested: Linux, NVIDIA/Intel GPUs.
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-25T17:02:51Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes blocks merging; the new fallback and regression test are consistent with the existing joined-import API.
What I ran
Reviewed head
5163b0d90de3660e129a2d81b811a48d8360ee84. No commands or tests were run; the author reports unit tests and convention checks in the PR description.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The PR description reports passing Windows/Vulkan tests and performance measurements; these were not independently verified. Linux and NVIDIA/Intel behavior were not tested. Read
VulkanDevice.cpp,RepeatedFillElision.cpp, andGuestBufferMemory.cpp; the manifest-listedfiles.jsonwas unavailable. The only file listed as excluded by the review inventory wasVulkanDevice.cpp, but its relevant sections were read through the pinned repository reader. No other changed files were excluded.To get this to a good state
Nothing is required.