fix(agc): synchronize open store runs prior to recording label writes #10318
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10318"
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 sohiporaby945-ai on 2026-10-23T17:33:22Z.
What
In
agc_driver_alias_copy_label, a CPU read immediately following a GPU completion label intermittently observed unwritten destination bytes on Intel Arc under Windows (e.g., finding 4096 of 262144 bytes unwritten in ~1 out of 3 runs).Root Cause
VulkanDevice::WriteLabelOnGpurecords the label store viaRecorder::RecordStore. Previously, pending store runs were not flushed prior to recording the label write.RecordStorejoins an open store run without inserting a new barrier, the prior alias copy destination store and the label store were placed into the same store run (or deferred until command buffer submit), leaving no intervening transfer barrier between them. On architectures with looser memory/transfer scheduling, the label write could land and be observed by the host before the alias copy store finished.closeStoreRun(atSubmit)) suffered from flawed causality (submit barriers cannot retroactively reorder already-recorded GPU commands) and caused pipeline stalls. Meanwhile,APS5_STORE_AT_LABEL=1masked the bug by flushing all pending texture stores before every label.Solution
Recorder.hpp, preservedHasQueuedStores()semantics (!open->run.queued.empty()) and added dedicatedHasOpenStoreRun()andHasPendingStores()helper methods.Recorder.cpp, updatedRecorder::FlushStores()to check!HasPendingStores()and close any open store run before proceeding.VulkanDevice.cpp(WriteLabelOnGpu), invokedrecorder.FlushStores()prior to queuing the label store. This ensures pending prior data stores (such as alias copy destination write-backs) are properly flushed and synchronized with transfer barriers before the label write is recorded, while subsequent back-to-back labels can still batch or flush based on label run configuration.Tested
Recorder.cppandVulkanDevice.cppcompiled cleanly with zero errors and zero warnings (-std=c++20).main:agc_driver_alias_copy_labelfails ~1 in 3 runs on Intel Arc (Meteor Lake0x7d55, driver 101.9150) under Windows 11.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-10-23T19:21:33Z.
Review: CHANGES_REQUESTED
I found two review blockers in the current change.
WriteLabelOnGpucallsrecorder.FlushStores()before every label, andRecordStoreputs each label inrun.queuedwhenLabelRunsPerBatch()is enabled. Therefore the next label call sees that preceding label as pending and closes the run before it can join the same batch. This appears to defeat the documented batching of back-to-back labels and can turn a run into one barrier pair per label. Please add a focused test/counter assertion for consecutive labels and preserve batching while separating prior data write-backs from label stores.The PR reports compilation only; it does not report running the failing
agc_driver_alias_copy_labelcase on Intel Arc with the change. This is an AGC-driver change, so CONTRIBUTING requires the same focused test on main and the change with validation layers,ANYPS5_NO_SHADER_CACHE=1, andANYPS5_REQUIRE_VULKAN=1, comparing VUIDs and naming the GPU/driver/OS. The issue now includes an independent Vulkan reproduction that specifically varies the barrier source-access mask; please validate this proposed store-run flush against the actual AnyPS5 reproduction before claiming it removes the race. The current report says it has only been compiled, so I cannot verify the claimed fix or its synchronization scope yet.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T00:46:20Z.
Review: CHANGES_REQUESTED
Thanks for the fix attempt. Two blockers:
main24/40 failures,main+ this head 21/40. In this test no store run is open or queued when the label is recorded (the destination is written by the image-to-buffer copy, the detile dispatch andvkCmdCopyBuffer, not by a store), soFlushStores()atVulkanDevice.cpp:2418returns without recording anything. The root cause described in the PR body does not match what the test does.WriteLabelOnGpunow flushes before every label, andRecordStoreleaves each label inrun.queued, so the next label closes the previous label's run. That defeats the batching of back-to-back labels (one barrier pair per label instead of one per group), as @MarcZX10 pointed out. There is no test or counter pinning consecutive labels.What was shown to work: giving the barrier in
Recorder::closeStoreRun(true)VK_ACCESS_MEMORY_WRITE_BITas source access took the test from 20/40 to 0/40 failures (see @BKlaasWerkman's comment and the standalone reproduction in #10199). Please revisit the fix in that direction, drop the per-label flush, and show the failure rate before/after on the affected GPU inTested.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T14:54:36Z.
Review: CHANGES_REQUESTED
Follow-up review of exact head
9d91e3ef0c60bdeae587df8d728077ce3dc80746with the newer controlled results on issue #10199. I agree with the collaborator’s reproduction: the currentFlushStores()call has no effect inagc_driver_alias_copy_label, because the destination is written by image/compute/copy commands and there is no open or queued store run at the label. The measured failure counts are 24/40 on baseline, 21/40 with this PR, and 0/40 when thecloseStoreRun(true)barrier source access includesVK_ACCESS_MEMORY_WRITE_BIT. That evidence shows this PR does not fix the reported race. The unconditional pre-label flush also prevents consecutive queued labels from sharing a run as intended. Please remove the per-label flush and investigate the barrier-mask change against the isolated Vulkan reproduction and AnyPS5 test, then report same-GPU focused Vulkan validation results and VUID comparison for the final head. Until then, theFixes #10199claim is not supported.Pull request closed