fix(agc): keep a queued dispatch's captured memory until it is recorded #23722
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23722"
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 slopezjur on 2026-11-19T14:25:36Z.
What
With
APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1, a queued dispatch item carries the guest snapshots its capture took and the draw committer records the dispatch from them later. The snapshot bytes point into the dispatch'sShaderMemorypages, but the item didn't hold thatShaderMemory. A missed dispatch, or a hit without a recipe, records from its fresh capture; its cache variant copies the words it needs and lets the capture go. Its pages then return to the queue worker's page pool whenDriver::dispatchreturns, while the item still waits on the committer. Items for cache hits with a recipe read the variant's own words and were not affected, so this only bites withAPS5_PIPELINE_DISPATCH_MISSES.The next capture on queue 0 takes those pages and overwrites them. So when the committer records the queued dispatch, its snapshots hold another dispatch's words. A page the pool doesn't keep is freed instead, and the committer then reads freed memory.
On Ghost of Yōtei (PPSA26344) with
APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1, every run logged 23 or 24guest snapshot differs from registered memorylines. In one run the draw committer died with0xc0000005inShaderResources::Complete→GuestBufferMemory::AddSnapshot(memcpy of a freed page).The item now also holds the dispatch's
ShaderMemoryand its registered shader until it is recorded.Driver::SetDispatchItemHook(same pattern asSetCaptureCheckHook) lets a test see the snapshots an item records from.Tested
Windows 11, RTX 4080 SUPER.
kept capturerounds intests/execution/PipelinedDispatch.cpp(run byagc_driver_pipelined_dispatch_misses). Two missed dispatches queue behind a held committer and read different descriptor tables; when each is recorded, its snapshots must still hold the words it captured. Without the fix, round 0 fails:1 snapshots of the queued dispatches no longer held the guest words they captured. With it, all rounds pass.^(agc_|shader_)withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, base (this branch with the item capture reverted, hook inert) and change, 2014 tests each, 0was not foundlines, 0VUID-lines:stencil_plane_memory,store_over_untracked,msaa_dcc_unwatch(all three fail on base too) andstore_pending_identity, which passed 10 of 10 reruns on the change and does not turn dispatch items on; 1815 layer insertspipelined_dispatch_misses(the new kept capture rounds); 1814 layer insertsAPS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1on a test stack that includes this fix: 0guest snapshot differslines, no committer fault. Every earlier run with miss items had 23–24 of those lines, and one died on the committer.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T14:35:03Z.
Review: APPROVED
Reviewed — looks good
The reviewed change retains the captured shader memory and registered shader until the queued dispatch is recorded; the inspected ownership path supports the stated fix.
What I ran
Reviewed head
a56ad682f28ee6f57ba2d69a0d9391eae37aca90. Readdescription.md,commits.md,manifest.json,diff.patch, and all three changed files listed in the manifest using the pinned reader. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported Windows, Vulkan, and Ghost of Yōtei test results were not rerun. No build or automated tests were run. No files were excluded by the manifest.
To get this to a good state
Nothing is required.