perf(agc): pipeline queue-0 draw commits behind the packet worker #1201
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1201"
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 MichonGoddijn231849 on 2026-10-07T17:28:58Z.
What
With
APS5_PIPELINED_DRAWS=1, queue 0's worker decodes, captures and recompiles a draw, and hands it to a committer thread that records it (Graphics::Drawunder the GPU lock). The two now run in parallel instead of one after the other. Work the committer has not reached yet is tracked by the guest ranges it will write. A later packet that reads or writes those ranges, or one the pipeline cannot order, drains it.These are ordered as commit items instead of drains:
APS5_PIPELINE_DRAIN_LABELS=1drains instead);APS5_PIPELINE_DRAIN_SUBMISSIONS=1drains);APS5_PIPELINE_DRAIN_FILLS=1drains);APS5_PIPELINE_DMA=1).A draw's write ranges include the storage images it writes and its exact color and depth target ranges (
APS5_EXACT_DRAW_WRITES=1), not estimates.Draw-path costs the pipeline exposed:
ShaderMemorymoves, so a commit owns its capture's pages.APS5_SUBMISSION_EPOCH_EACH=1bumps at every submission). A thread remembers the ranges it walked for the whole epoch.std::mutex(winpthreads contention showed up as kernel events).ScanPendingskips the registry walk when no pending image can overlap.The pipeline is off by default in this PR; the next one in the series turns it on.
A predicated packet is left to the normal path while predication is active, so a false predicate still skips it.
Two fixes since the rebase, each its own commit: a null storage image in a draw's written set is skipped before it is decoded (gjonn and SleglJan's report, PPSA01317), and a pipelined
RELEASE_MEMwithINT_SEL3 raises no interrupt, as onmain(TheAggie's report).Note for #374 and #419: they note HTILE and CMASK fills in the DMA_DATA path. Whichever lands second also has to call
NoteDepthMetadataFillandNoteColorMetadataFillin the pipelined DMA commit (commitDmaStore).Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB, MinGW-w64 GCC 15.2.0.
gta-v/testingbranch (Performance mode, the prologue). GTA V Performance mode, the prologue's bank interior: about 11.7 to 20 fps together with the cheaper captures below it.ctestpasses. Not run here: the relinker's Python tests (my local Python does not find their helper modules) andguest_gameupdate.maina56c905df(2026-10-13), starting from gjonn's rebase of this series onto6ac63bf0c(thanks). On Windows (MinGW GCC 15.2, RTX 5080) the wholeagc_*suite passes on the top of the series: 483 tests, 1 skipped (agc_driver_stencil_ref_export).APS5_PIPELINED_DRAWS=1the same suite passes exceptagc_driver_pm4_failure, which expects a synchronous rejection (#1202 runs it with the pipeline off).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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-09T08:33:00Z.
Parked as a draft while I port the pipelined draw path onto #639 (the draw path now runs through prepared invocations). I'll mark it ready again when the port is tested.
Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-11T04:40:02Z.
Ran this with Hades II (PPSA36082) on my machine, rebased locally onto current main together with #419 and the other changes the game needs. With
APS5_PIPELINED_DRAWS=1the hub went from ~47 fps to the 60 fps cap, but the 3D characters (Melinoë, her shadow, the NPCs) flickered or showed up as dark silhouettes. Those are drawn into 4x targets and then resolved.The cause was in
precheckDraw: when the draw is a CB metadata pass (DecodeColorMetadataPass, i.e. the resolve from #419, or a CMASK/DCC pass), it runsColorMetadataPassright away on the worker, under the GPU lock, without draining the pipeline. So the resolve got recorded ahead of up to 8 queued draws, including the ones drawing into the 4x target it resolves. The drain/ordering switches (APS5_PIPELINE_DRAIN_*,APS5_EXACT_DRAW_WRITES) don't change anything here since this path never goes through the queue.Draining before the pass fixed it for me:
In the hub that's ~350 drains a second costing ~1.8% of the worker, so enqueuing the pass as a commit item would be the nicer version. With it the characters render correctly and it stays at 60 (worker 16 us per packet, committer 9.4 us per commit).
Since this only shows up when both this and #419 are in, just flagging it for whichever lands second. A few other spots I had to touch when rebasing onto current main, in case they're useful:
noteLabelStorenow takes the queue; theNoteDepthMetadataFill/NoteColorMetadataFillcalls you mentioned for the pipelined DMA commit; andNoteHtileDepthClearinDispatch.cppnow runs before the dispatch's drain on main, so I moved it after.LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-11T06:44:04Z.
With pipelined draws on Hades II, the committer often found the queue empty (~1.1 items queued on average), so nearly every
Enqueuepaid anotify_onefutex wake-up plus a reschedule. Letting the committer spin up to 50 µs onoutstandingbefore waiting on the condition variable cut wake-ups from ~680k to ~8.6k per 10 s, the worker's hand-off from 2.7 to 1.1 µs per draw, and took a pickup menu from 48.8 to 53.2 fps (one run each,APS5_PIPELINE_SPIN_US, 0 turns it off).Roughly what I did in
run(), right before the wait:LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-11T07:59:40Z.
@Raghav314 thanks, both are real. The CB metadata pass (#419's resolve, CMASK/DCC passes) running on the worker ahead of queued draws is an ordering bug of the pipelined path; it has to be a commit item (or drain) before it lands with #419. The spin-before-sleep on
outstandingis a nice win too. This PR is a parked draft while the pipelined stack is ported onto the prepared-shader path; when it comes out I'll take the metadata-pass ordering in. The spin is best as your own follow-up PR on top then, so it's credited to you.Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-11T16:44:14Z.
Tested this on Hot Shots Golf 2 (PPSA06699, the PS1 classic in Sony's PS1HD emulator) on Windows, RTX 4070 SUPER, with
APS5_PIPELINED_DRAWSoff vs on and everything else identical (2 runs each, 130 s demo loop).It takes the 3D course from visibly stuttering to almost flat 60.
(tldr I really like the performance gains from this)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T20:11:46Z.
@MichonGoddijn231849 where does the port of this stack onto the prepared-shader path stand?
Data point from current
main(a11c8f7fwith #425, #454 and #290), Linux, RTX 4090, in a 3D title we test with: a level with about 6,400 draws per present spends about 110 ms of a 345 ms frame in the queue-0 worker's draw front end (stage capture, materialize, draw entry insert), against about 32 ms inGraphics::Drawitself. 97% of its draw keys never repeat, so a draw cache doesn't help there; running the front end ahead of the worker is what's left.If the port is some way off, would you mind if I ported #1201 onto
mainand opened it with your commits kept?Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-11T21:53:54Z.
@oneandonlydean the port exists but isn't public yet. It's on our dev branch on top of current main (after #639), together with later work on the same path: prepare threads for the commit, the committer spin and the measured switches on by default. It renders correctly in GTA V, but on the prepared-shader path it gained much less than it did before #639 (about 22 to 23.5 fps in our test scene). So I haven't opened it, and my time is on Wolverine right now.
So yes, please go ahead and port #1201 onto main with the commits kept, and I'll close this draft in favor of yours. Two things to take along:
Graphics::Drawbehind the ~110 ms front end. Cutting the front end itself needs it on more threads. I tried helper threads keyed by draw sequence before #639; they were slower only because the committer was the limit then, which isn't your case.If it helps, I can push my port to a public branch so you can diff against it.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T22:48:11Z.
Yes, please push the port to a public branch; I'll start from it rather than from this head.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T04:26:39Z.
007 Windows data point for the front-end discussion, on our public runtime-image-table integration742449f6d (RTX5070Ti/7800X3D/32GiB, Release, SPIRV-Tools OFF). A10s interval had2932draw packets: capture570us/packet, materialize/recompile-hit557us, key/lookup/validate524us, Graphics::Draw713us. The draw-entry cache in another interval retained4096entries/8373variants (~3781MiB) for25full hits out of2986lookups;2780had no entry. Code currently copies every captured region into each inserted variant's words, even with that low key reuse.
I am comparing the existing APS5_NO_DRAW_SRT_ENTRIES option before changing that cache. #3655/#3656 native cross-tests passed and007 still renders the startup notices, but no clear frame-rate gain yet. We also need the front-end cost reduced; GPU timing in the earlier run was
0.8s per10s of wall time, at0.6FPS.Please point us to the public prepared-shader/pipelining port when ready; I will cross-test on Windows rather than create another full port. I am keeping the runtime-image-table integration separate from a current-main mergeability claim. No title data uploaded. AI-assisted: yes(Codex).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T04:31:21Z.
Existing-config comparison onbc46e2d6f, same warm cache/quiet settings: normal draw-stage cache showed the rendered MGM logo at0.73FPS/frame415 and ~24.1GBprivate memory. APS5_NO_DRAW_SRT_ENTRIES=1 showed the same MGM logo at0.98FPS/frame428 and17.1GBprivate, only1owned-process trim at that point. One run each, observed window FPS, not a controlled benchmark distribution; still not playable. All other graphics settings retained (compute128/LRUoff/memo512/resource64/texture2048/staging128). The cache-off run continues toward later screens.
I found @oneandonlydean's existing public astro-main/draw-key-admission-3, 77774a519899040aee6931144cea3d3f5a1d6e27, implementing second-sight admission rather than keeping every one-off key. It applied cleanly, with Dean Galvin's author retained: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-draw-admission-cross-test , 4e5c47e4893023d49a7e446baa4fc1d646d97bfe. Not built/staged yet. Native third-draw reuse/mutation checks next after the current run. No competing implementation or new upstream PR.
AI-assisted: yes(Codex). No title data uploaded.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-12T15:50:14Z.
@oneandonlydean here it is:
perf/pipelined-draws-porton my fork. It's one commit (913a29b20) on main57f96fd2b: a snapshot of our dev branch at3e4c9e867without its test data, so the history isn't there, only the code.The pipelined path is in
Execution/src/Driver/Draw/DrawPipeline.cppandExecution/include/Driver/Draw/DrawPipeline.hpp, with the worker side inDraw.cpp(draw/drawTail) andPacketExecution.cpp. In the order they were added on our branch:APS5_PARALLEL_DRAWS(helper threads that prepare draws ahead of the worker);APS5_RETIRE_ON_WORKER,APS5_PIPELINE_HYSTERESIS,APS5_COMMITTER_SPIN_US;APS5_SPLIT_COMMIT=<n>(a draw's commit prepared on n threads ahead of the committer, on by default with 3).The tests are
agc_driver_pipelined_*andagc_driver_draw_write_ranges. Raghav's metadata-pass ordering (above) is not in it. @Scramblrrrr this is the branch for your cross-test too.Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-12T19:39:19Z.
Code review location:
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp; line 81A null storage-image descriptor in the written set makes this throw.
DecodeTextureResourcedoesRequire(baseAddress != 0, ...)(GuestTextureResource.cpp:57), so theresource.baseAddress == 0check on the next line never runs. The draw/dispatch then fails instead of skipping the image.We hit this on PPSA01317: one of its draws has a null storage image bound in its written set.
Suggested fix: check the base-address words before decoding:
A null T# case in
tests/execution/DrawWriteRanges.cppwould also cover it.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-13T03:17:44Z.
@oneandonlydean @MichonGoddijn231849 a data point and an offer for the port, so we don't duplicate each other.
I wanted the pipeline for a workload it hasn't been tried on (RetroArch's Flycast core, which renders through RADV on the PS5 GPU: about 2,700 small draws a frame, nearly all draw-cache hits), so I cherry-picked the original #1201 commit (
6fe6c40a7, author kept) onto main2a55cfe1e. It took 10 conflicted files. Branch:perf/pipelined-draws-on-mainon my fork, three commits on main.What I changed on top of the cherry-pick:
BufferPoolsize-class change, and the #1193ShaderMemorypage pool (main'sShaderMemoryonly needed a defaulted move constructor).enqueueLabelPackettreated every nonzeroINT_SELas an end-of-pipe interrupt. Main excludes 3 (send data after write confirm), andagc_driverfails on it with the pipeline on.noteLabelStoretakes the queue now (Raghav314 mentioned this one), and the draw commit no longer capturesdataEntry.DMA_DATAthat stores nothing (source not immediate, and zero bytes or no destination) keeps the pipeline. RADV emits one between most draws. Without this, Crazy Taxi drained about 14,000 times a second on opcode 0x50, 5 s of every 10 s on the queue worker.Not done: the CB metadata pass in
precheckDraw(Raghav314's report above) still runs ahead of queued draws, and I have not comparedcommitLabel/commitDmaStoreline by line with main's current label code.Results, Windows 11, NVIDIA GeForce RTX 5070 Ti, MinGW-w64 GCC 15.2:
agctests on that branch (453): with the pipeline off 452 pass and 1 is skipped. WithAPS5_PIPELINED_DRAWS=1451 pass, 1 is skipped andagc_driver_pm4_failurefails, because it expects a synchronous rejection (#1202 runs it with the pipeline off). I did not run the rest of the suite on this branch.Two things from a narrower two-thread path I had been running locally, in case they are useful for the port:
I'm not opening a PR from it, since the port is yours. Take anything from the branch that helps, and I'm happy to cross-test your port on this workload.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-13T10:02:26Z.
Would you be able to rebase this onto current
main?On Minecraft Dungeons II (PPSA16064) gameplay (Windows 11, RTX 5070), queue 0 spends about 59 ms of a ~101 ms frame on draws:
Graphics::Drawunder the GPU lock);Overlapping the two halves looks like the biggest remaining win for that title. Merging the current head into a main-based build leaves conflicts in 21 files (the pipelining commit alone, 10), so I couldn't A/B it. Happy to test a rebased head.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-13T13:26:13Z.
@TideOPL I rebased the five commits onto current
main(6ac63bf0c): https://github.com/gjonn/AnyPS5/tree/rebase/pr-1201-pipelined-draws (head 077477553). I pushed it to my fork instead of force-pushing @MichonGoddijn231849's branch, so it can be A/B tested first. Michon can resetperf/pipelined-drawsto it if it holds up.Where
mainhad changed the same code, I adapted the PR to it:mainmade the decoder a free function with a static-ABI mode (DecodeGraphicsPrograms). The user-word re-read for data-only hits is now the free functionsReadUserWordsandInitializeMerged, which takestaticAbi.main's incrementalRegisterStateKeyalready fingerprints every register except the user words and merged pointers. That fingerprint is now the shape key, through a new optionalshapeKeyout-parameter, in place of the PR's separate hashing loop.eraseDrawEntry, which drops a draw whose unregistered program was rewritten, also drops the entry's shape mapping. A data-only hit is not taken from an entry whose programs are no longer current. The fragment's unexported-input defaults run before a stage compiles, as onmain.main's null-root and inaccessible-read reporting, signed min/less-than, and zero for out-of-range constant-buffer reads.EvaluateRuntimeSourcesImplpasses poison and null-root counts to both walks.mainsplits the bindings into a main set and a fragment set, so both are recycled per layout. Chain pools are reset as a whole and do not support freeing single sets, so a full recycle list now goes throughDescriptorCache::Freeinstead ofvkFreeDescriptorSets.main's flip hold, the dispatch-ahead gate andlandPendingWaits. A wait answered from the pipeline's pending labels opens the dispatch-ahead gate the way a real wait does. The pipeline drains beforeresolveGroupAhead, which reads guest memory. The drain before the copy kernel moved into the non-resolving dispatch branch.releasedTailsand theRegisteredReadableCoversmemo useHostThreadLocal, asprx_thread_local_destructorsrequires. Label stores pass their queue tonoteLabelStore, whose signaturemainchanged.It builds with MinGW in Release, and
ctestpasses 1073 of 1075. The two failures areagc_driver_pixel_ancillary_wordandagc_driver_pixel_fixed_point_position, whichmainadded after this PR was branched. Both draw into a linear target in arena memory, and the resident linear-target change (third commit) makes the next arena block fail the tests' "the color target is not write-watched" check. WithAPS5_NO_RESIDENT_LINEAR_TARGETS=1they pass. That needs a look from the PR side before it merges.APS5_PIPELINED_DRAWSis still off by default, as in the original head, so turn it on for the A/B.AI-assisted.
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-13T15:09:15Z.
Code review location:
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp; line 81Additions to your finding, from a stack where the same decode in #4724's
appendWrittenRangesended two 007 First Light runs, and where a unit test reproduces the throw in this walk:ShaderResources.cpp:3372at4008e68e3). It came with #639 (dccfa08de, merged 2026-10-08), after this PR's base; at 6fe6c40a7 the binder still decodes without it (ShaderResources.cpp:2657), so the difference appears once the branch is rebased past #639.WrittenBuffers.cpp:85-86).DispatchWriteRangesandDrawWriteRangeswithIsNullTextureDescriptor, which by default treats only an all-zero descriptor as null (a zero base alone counts only underAPS5_NULL_UNRESOLVED_IMAGES), while its binder keeps the rule (ShaderResources.cpp:3532), so a zero-base descriptor with non-zero remaining words still throws in the walks. #4779 would make the binder skip type-0 descriptors too, which a copied rule would still decode and throw on, so one shared predicate beats a copy.appendWrittenRangesends the process when the ahead resolver reaches such a dispatch, since that call has notryaround it: https://github.com/boykopovar/AnyPS5/pull/4724#issuecomment-6148352503.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-13T15:45:45Z.
Rebased onto current
main(a56c905df), starting from @gjonn's rebase (thanks, it saved a lot of work; you're co-author on the rebased commits). The series is now #494 → #1191 → #1193 → #1201, each PR its own commits on top of the previous one.agc_driver_pixel_ancillary_word,agc_driver_pixel_fixed_point_position) come from main's write-watch coverage: the resident linear target's host import unwatches a whole 64 KiB block, and a later sub-block allocation there is never watched again. Resident linear targets (#1191) are now opt-in,APS5_RESIDENT_LINEAR_TARGETS=1, so the default matchesmain. The fullagc_*suite passes on Windows (483, 1 skipped).DrawWriteRangesis fixed in its own commit with the binder's rule (base address words zero) and a null T# case inagc_driver_draw_write_ranges.mainwrites that rule inline in each binder path, so I used the same rule rather than a new shared predicate here; a shared one is a good follow-up formainitself.INT_SEL3 finding is in (own commit, co-author). WithAPS5_PIPELINED_DRAWS=1onlyagc_driver_pm4_failurefails, as you saw. I haven't taken the emptyDMA_DATAchange yet; it belongs with the DMA commit items in #1202, which I'm porting next.precheckDrawstill runs ahead of queued draws. That's still owed, as a commit item or drain before it lands.APS5_PIPELINED_DRAWS=1.Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-14T13:33:50Z.
The CB metadata pass is on a branch now, as commits on top of this head (31c9a0f2e) so you can cherry-pick them: https://github.com/Raghav314/AnyPS5/commits/fix/1201-ordering-drains
c50e23120fix(agc): a CB metadata pass drains the draw pipeline before it runs (the one that was owed; it fixes the 4x flicker I saw)a9c15be3efix(agc): entry validation drains queued draws that write its runs (a capture already drains first,validateVariantdid not)41f385acbfix(agc): note an HTILE depth clear after the pipeline drain (NoteHtileDepthClearran ahead of the queue-0 drain inDriver::dispatch)e19e113b0fix(agc): include HostThreadLocal outside the Windows block in GuestBufferMemory (this head doesn't build on Linux without it: 9c2ddf3a8 usesHostThreadLocalthere, but the include sits under#ifdef _WIN32)I ran the branch on my machine (Linux, CachyOS, GCC, RTX 4090): the full ctest passes, 1071 of 1071. With
APS5_PIPELINED_DRAWS=1theagc_*suite hasagc_driver_pm4_failurefailing ("pipelined commit failed: guest memory is not readable at 0x1000", so the rejection lands on the committer instead of the submit) andagc_driver_pixel_ldsfailing in some runs with a lost device (vkWaitForFences-4); both fail the same way on 31c9a0f2e without these commits. In Hades II with the same drains onmain98541c674(plus #494, #1193, #1202 and #5687), a hub run with all theAPS5_VERIFY_*switches shows no differing stages and the flicker is gone.One more for the next rebase: the memory-value fill from #4603 (on
main, not in this head yet) reads the fill value on the worker while the label store that writes it can still be queued.agc_driver_memory_value_fillfailed in 2 of 3 runs here with the pipeline on, and passes 20 of 20 with a drain before the read infillBuffer:LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by SoRadGaming on 2026-10-14T14:16:57Z.
A/B on Windows with an AMD GPU: ASTRO BOT (PPSA21564 01.007.000),
-lvl hub_crashsite(the full hub), no input, no profiler, warm shader and pipeline caches. FPS comes from the window's present counter over 120 s, after a 120 s settle onceLevel has started: hub_crashsiteis logged.Host: Windows 11 Pro 26200, Ryzen 7 5800X3D, Radeon RX 9070 XT (driver 32.0.23033.1002), 32 GB, WinLibs GCC 15.2.0, Release.
The base is
maina3aeaf884+ #5671 + #5679 + #5707 + revert of #5596 (its comparison cost, #5692) + #5640, withAPS5_NO_SNAPSHOT_CHECK=1 APS5_RESOURCE_CACHE_ENTRIES=4096. The change is this PR's head (31c9a0f2e) merged into that base, withAPS5_PIPELINED_DRAWS=1.fix/1201-ordering-drains(c50e23120, a9c15be3e, 41f385acb, e19e113b0) + the memory-value fill drain aboveIn this scene queue 0 is the limit. Profiled, the base spends ~130 us per draw packet over ~2,200 draws per present, with the GPU busy about half the time. With the pipeline the worker takes ~72 us per packet (capture 32, recompile 12, decode 10) and the committer ~48 us per commit. The worker still waits ~8 us per draw for room at depth 8, and there are ~3,500 packet drains per 10 s, most on DISPATCH_DIRECT.
Startup throw: 2 of the first 11 pipelined launches stopped at their first presents, before the hub loaded, with
[videoout] presentation failed: AGC graphics: a CMASK fast clear of a DCC color target, whose clear belongs in its DCC keys, was recorded. One run had the CPU frame dump on (APS5_NO_GPU_DUMP=1) and one had no dump settings at all. That comes fromrequireCmaskCodes(detiler->CmaskErrors())inmaterializeCmaskClear. 16 later launches without the drains did not throw, nor did 16 with them. So the rate is low (2 in ~27 without), and 16 clean launches with c50e23120 do not show that it fixes this. It does look like the CB metadata ordering it addresses. The base never threw.Two things broke in the merge with
maina3aeaf884and may hit the rebase:ShaderDiskCache.cppassertsfieldCount<IrResourcePlan>() == 21onmain, anddenseValueIdsandcompactmake it 23. Neither field is encoded, so a plan loaded from the disk cache comes back without the compact table and takes the old walk. Locally I rebuild it afterDecodePlan(denseValueIds = true; buildCompactPlan(plan), which drops the table again if an id does not match). A counter showed 1,024 of 1,047 cached plans got the table, and the rest were empty plans.BufferFill.cppthestorelambda must capturememoryFill, whichmainuses inside it since #4603.Hub frame captures (
APS5_DUMP_FRAMES, GPU readback) match between base and change. A 30-minute boot → title → NEW GAME → intro run with the pipeline on did not throw. Not tested: the full test suite on this merge.AI-assisted (Claude Code); the builds and runs are on my machine.
Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-14T17:01:46Z.
Hades II hub numbers for this branch, and three ordering cases in the pipelined path that I found while comparing it with the threaded-recording change in #5485.
Setup.
raghav-1201-drains(this head 31c9a0f2e plus @Raghav314's four commits, e19e113b0), Release, Linux (CachyOS), Ryzen 9 5950X, RTX 3080 Ti, NVIDIA 610.57.04. Hades II hub, warm caches, no profiling variables set. FPS is the mean of the window-title readings over a 60 s hold after the hub settles, three runs per arm, interleaved with the arms of #5485 so drift is spread across all of them:APS5_PIPELINED_DRAWS=1main), flag offAPS5_MT_RECORD=1The pipelined runs had no crashes and no
pipelined commit failedlines. Frames dumped every 60th present looked the same as the flag-off run; that sampling would not catch a flicker on a minority of frames. The bases differ by about 800 commits, so the flag-off rows are not a controlled comparison; each flag's gain over its own flag-off row is (+21.7 here, +18.1 for #5485). WithAPS5_PROFILE_DRAW=1set (and #5485'sAPS5_DRAW_PREPARE_AHEAD=2, which this branch ignores), both builds lose several FPS, this one less than #5485.Given that, I'd rather help this land than push #5485 as a competing design. The cases below are from reading the code at e19e113b0; I have not reproduced them in a test yet.
Pm4::PredicationPassesreadspredication.address(PacketExecution.cpparound line 197,Pm4.cpp:554).recordQueuedLabelsBeforeReadonly records the worker's own deferred labels. Sequence: SET_PREDICATION on P, WRITE_DATA P=1 (queued as a label commit), predicated DRAW: the worker reads the old P. A drain whenBusy() && (Overlaps(P, bytes) || PendingLabel(P, bytes))before the check would cover it.fillBufferreadsrange->controlandrange->sourceunder the GPU lock (BufferFill.cpp:160-170) with noOverlaps/PendingLabelcheck. It's the same shape as the memory-value fill @Raghav314 found for #4603, but for the pattern fill that is already on this branch. The drain has to come beforeinputLock.lock(), sinceDrainrefuses to run under the GPU lock.enqueueLabelPacketdoesn't checkdeferredLabels().labels.empty(), whileenqueueDmaPacketand the draw path do (PacketMemory.cpp:318vs:254). A predicated WRITE_DATA X=1 is never enqueued, so it is deferred on the worker. A following unpredicated WRITE_DATA X=2 is enqueued and committed, and the deferred X=1 is recorded later, so X ends as 1. The samelabels.empty()guard would make it drain and keep the order.Smaller:
DrawWriteRangesdoesn't addcolor.cmaskAddress, while a draw commit can write CMASK throughrefreshResidentTarget → materializeCmaskClear. The worker-side metadata passes drain anyway, so I expect little impact.#5485 has a per-job write checker (
APS5_MT_RECORD_CHECK=1): it records what each job actually wrote and compares that with the ranges published for it. Around(*commit)()inDrawPipeline::runit would map ontoitems.front().writesdirectly. On this base the write observer hooks would need porting with it. I can send any of the three fixes with a unit test each, and the checker, as commits on top of this head like @Raghav314 did, if that helps.LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-14T20:04:25Z.
Fixes for cases 1 and 3 from my earlier comment are on a branch, as commits on top of this head (31c9a0f2e) so you can cherry-pick them: https://github.com/eliyarson/AnyPS5/commits/fix/1201-predication-label-order
56b94480bfix(agc): a predicated packet drains queued writes to its predicate before reading it (case 1)1f894c9b6fix(agc): a label packet behind a deferred label is not enqueued ahead of it (case 3: thedeferredLabels().labels.empty()guard thatenqueueDmaPacketand the draw path already have)Each comes with a test that sets
APS5_PIPELINED_DRAWS=1itself:agc_driver_pipelined_predication_read(Vulkan; checks P 0 -> 1 runs the fill and P 1 -> 0 skips it) andagc_driver_pipelined_predicated_label_order(no Vulkan). Each failed 30 of 30 runs without its fix and passed 30 of 30 with it.Built on top of @Raghav314's e19e113b0 for Linux, Ryzen 9 5950X, RTX 3080 Ti. With the flag unset,
^agc_passes 487 of 487. WithAPS5_PIPELINED_DRAWS=1,agc_driver_pm4_failurefails as on this head, andagc_driver_pattern_buffer_fillfails in some runs both with and without these commits; that is case 2, which @oneandonlydean's c653e9ea1 on #1202 covers. Both commits also apply cleanly on c653e9ea1, and the new tests pass there.A correction to case 1: I suspected COND_EXEC and SET_PREDICATION too, but they aren't on the keep list, so they already drain before reading. Only predicated packets that stay in the pipeline needed the check. The check runs only for predicated packets while the pipeline is busy, and drains only when a queued item writes the predicate's bytes.
CMASK in
DrawWriteRangesand the write checker are still open; I can send those the same way if you want them.LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T03:31:18Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cppL17core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cppL11core/libs/prx/libSceAgcDriver/Execution/include/Driver/Draw/DrawPipeline.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Memory/DrawWriteRanges.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/SlimMutex.hppcore/libs/prx/libSceAgcDriver/tests/execution/DrawWriteRanges.cppcore/libs/prx/libSceAgcDriver/tests/execution/PipelinedDma.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppL1071-1072, L1157-1158, L1196core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppL3, L1193core/libs/prx/libSceAgcDriver/Graphics/src/UnitShadow.cppL100Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T09:40:38Z.
Rebased onto main (no merge commits; backup of 31c9a0f2e at
adriadam10/AnyPS5:backup/MichonGoddijn231849-perf-pipelined-draws) and folded in the fixes from this thread, plus what the tests turned up with the pipeline on. The branch no longer sits on #1191 (#494 and #1193 are on main, and the pipeline doesn't need #1191's resident images). Default stays off (APS5_PIPELINED_DRAWSunset = today's inline path). #6203 was a byte-identical copy and is closed in favour of this one.Picked from the threads (cherry-picked with
-x, authors kept):NoteHtileDepthClearresolved keeping main's version, moved after the drain).Found here and fixed:
BufferPool.cppback to main's: the PR dropped the erase of an emptied size class, soevictOldesthit a dangling class (double free inagc_buffer_pool, segfault inagc_driver_graphics).agc_driver_draw_cache_reuseaborted with the pipeline on).Driver::ReportFailurelike a failed worker (exceptProcessShutdown), instead of a log line; later commits are skipped. Without itagc_driver_pm4_failurehangs with the pipeline on.std::exceptionlike the inline draw path.ShaderMemoryis neither copyable nor movable; the draw holds it in aunique_ptrso the pipelined commit can own it.valueAddress) and buffer-pattern source drain queued writes before reading; theinputLockrelease moved intofillBuffersince main split outstoreBufferFill.New tests (each check proven by mutating the fix and seeing it fail):
agc_driver_pm4_failure_pipelined(times out withoutReportFailure),agc_driver_draw_cache_reuse_pipelined(aborts without the stage capture), CMASK rows inagc_driver_draw_write_ranges.Local results (Linux, Radeon 660M, RADV,
ANYPS5_ENABLE_SPIRV_TOOLS=ON),ctest -R 'agc|shader':APS5_PIPELINED_DRAWS=1 APS5_EXACT_DRAW_WRITES=1): 594/595--repeat until-fail:20over the pipelined/fill/predication/label/draw-cache/failure tests: 16 tests x 20, all passedThe only failure,
agc_driver_tessellation, segfaults on main too on this GPU. Windows full build dispatched next; merging with the pipeline off once it is green. #1202 (on by default) stays held on its open blockers.Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-15T10:24:09Z.
Thanks @adriadam10 for rebasing, folding in the predicate and deferred-label fixes, and chasing down the pipelined-commit lifetime and failure-path bugs, and to everyone whose fixes went in. I'll keep testing the pipeline on Hades II and report back on #1202.
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-16T11:42:46Z.
@MichonGoddijn231849 @oneandonlydean a question about where this goes next, so nobody does the same work twice.
On Windows (RTX 5070 Ti / 7800X3D), with #6763 (draw inputs copied instead of bound in place: the GPU time of the draws went 164 -> 45 ms per frame) and #6188, Astro Bot's Crash Site (~2200 draws per frame) is now bound by this PR's committer: it holds the GPU mutex 68% of the time at ~34 us per draw, and the packet worker spends 22.6 of its 33 us per packet waiting for it. Per draw: snapshots and descriptor sets ~7.6 us, pipeline/resource lookup ~8, vertex copies ~5, target refresh ~3, the Vulkan commands themselves ~3.
We are trimming those pieces one by one, but past that the single committer is the ceiling. Is anyone working on, or planning, recording draws on more than one thread (for example secondary command buffers per render pass, committed in order)? If it is on your list we will stay out of it and measure your branch on Windows; if not, we would like to know whether you would take it in that form before we start.