fix(agc): order deferred import settles with main-queue accesses #8527
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8527"
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 eliasbruno124-dev on 2026-10-20T15:12:32Z.
What
Order Windows deferred host-import settle reads with earlier and later main-queue accesses to the same memory. GTA III reports
SYNC-HAZARD-WRITE-RACING-READwhen a main-queue fill races the deferred four-byte copy on the separate settle queue.Allocate batch commands from the main pool and submit on the main queue, with barriers around the copies. Submission remains asynchronous on the CPU. Reuse the existing import buffer, removing the alternate-family alias from this path. Retirement checks a bounded 60-second fence wait and propagates failure before releasing the batch's resources.
The ordering tests cover both settle-family configurations and reject reported
SYNC-HAZARD-orVUID-messages when validation is enabled. Their byte assertions alone can pass on unfixed drivers. A separate regression injects timeout and device-loss results, checks error propagation and retained imports, then verifies exactly one release after a successful wait. The first-use check requires earlier main-queue reads to finish before rewatching. Both comparison arms include the scratch-copy barriers needed by the existing canaries.Rebased linearly onto
f40cdebce2, keeping both recorder selection flags from the conflict. Main queue/pool access is protected byGuestMemory::GpuMutex, including queue-0 commits, presentation and command allocation/free. Overlap refreshed on 2026-10-23: #9941 owns the separate synchronous initial-DCC settle change; #9670 adds a separate presentation queue. Neither is a dependency or a replacement for this correction.Tested
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, sequentialctest -V.GuestBufferMemory.cppfrom mainf40cdebce2versus candidatea0ecec3d3. Baseline: four failing cases, twoREAD-RACING-WRITEand threeWRITE-RACING-READreports. Candidate: 28/28 pass, no skips or validation errors; longest case 2.94 seconds. The set covers deferred settles, both ordering configurations, retirement errors, import lifetime, flip stores and VideoOut presentation.git diff --checkpass.cabd80f47andc64cfdee2: identical resources/settings, default deferred settles, empty private caches, no inputs or other unmerged PRs, all 61 observed runtime modules verified. Each observation was stopped after 300 seconds rather than reaching a normal guest exit.SYNC-HAZARD-WRITE-RACING-READVUID-VkImageViewCreateInfo-usage-02275Those races concern a main-queue
vkCmdFillBufferand the settlevkCmdCopyBuffer, over 4096-, 65536- and 12288-byte buffers. The separate image-view errors remain. Renderer exports show the opening logo, not gameplay. This title evidence belongs to the named pre-rebase commits; the new review correction has native comparison coverage, not a fresh title run.No FPS or loading-time gain is claimed. Main-queue batching latency, a real device-loss event, other GPU vendors, Linux and macOS were not measured locally. The earlier title observations had validation/profiling/readback enabled, and Git metadata work overlapped part of the candidate observation.
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 oneandonlydean on 2026-10-21T03:10:37Z.
@eliasbruno124-dev thanks, the barriers and the alias removal look right. Two questions before merge:
context.poolandcontext.queuemakes it share two externally synchronized objects with the main recorder.submitSettleBatchholdssettleQueueMutex, andsettleUnwatchedImportsonly runs it while this thread holdsGuestMemory::GpuMutex. Is every othervkQueueSubmittocontext.queue, and every allocation, reset or free oncontext.pool, also made underGpuMutex? Please point to where that holds for the queue-0 committer and the present path, or add the lock the main queue uses.waitSettleBatchnow waits withUINT64_MAX. A GPU hang during retirement would then block the thread holdingGpuMutexforever, where before it gave up after 10 s. Is that intended, or would a long bounded wait followed by a fatal error be better?