perf(agc): store an unimported label at once when unfinished work leaves guest memory alone #10442
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10442"
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 Dripl1x on 2026-10-24T00:30:33Z.
What
An unimported queue-0 label (#7464's path) synced the recorder before its CPU store, so every batch had finished first. Only what that work does to guest memory can tell the two orders apart: a batch that reads guest memory in place (a store landing first would be read), writes it (the guest would read the old bytes after seeing the label), or has completion actions. Work that leaves guest memory alone, such as draws from copied inputs into host-side targets, cannot be observed by the guest before or after the label.
Recorder::UnfinishedGuestTouchreports what the open batch and the in-flight batches whose fences have not signaled still do: in-place reads, noted writes and labels, stores or sample dumps still to record, pending validations and completion actions (also of signaled batches and of batches another thread is finishing).WriteLabelOnGpusubmits any open batch and returns reason 7 so the caller can store the label before GPU completion. It syncs as before otherwise. #8180's completion gate still comes first.APS5_NO_EARLY_LABELS=1always syncs;APS5_PROFILE_DRAWprints an[early-labels]line with the counts by reason.ReapAfterEarlyLabelthen reaps finished batches if a reap was deferred.MarkGpuWritesno longer notes as read a region that only snapshotted allocations overlap (PrepareDrawBindingsbinds read-only direct elements to copies, which the GPU never reads in place). A BDA build gets no draw bindings and keeps noting every region.Where the gate stays closed, labels sync as before: draws whose vertex or index inputs are bound in place (every driver except NVIDIA's on Windows,
DrawInputsInPlaceUsable), BDA builds (whole leased heaps are noted as read), and anything with completion actions.Rebased onto
main13aa5703b3. The earlier head9c7a3226f9introduced Leandro's sampled-texture fix. The fix records a pendingStorageUploadread when a texture is copied from host imports, andsampledImportPiecesTestschecks that the read stays pending until the copy runs.SuperTuxKart (PPSA69421), main menu without the tutorial prompt (about 33 draws a frame), Windows 11, RTX 3070 Laptop (NVIDIA 621.01), Ryzen 7 5800H. Stack:
main9d4fb4fb70+ #7464 + #9402 + this + three local changes (idle spin, settle at import over 64 KiB, in-place refresh spans); protocol runs interleaved, the switch on the same runtime:APS5_NO_EARLY_LABELS=1With early labels the longest idle gap of queue worker 0 and the committer per frame goes from 0.4 ms to 6.7–7.0 ms (median).
APS5_PROFILE_DRAW, cumulative over a run: 27090 labels stored at once, 58 waited (42 for an in-place read, 1 for a write, 15 for completion actions). #7464's branch alone on the samemain: 48.75–49.89 FPS.Earlier, on a stack based on
maina0900b9d99and in the menu with the tutorial prompt (about 59 draws a frame), the same switch measured the parts of this change while they were separate commits: the store at once alone 31.8 / 32.0 → 48.3 / 46.2 FPS (p50 31.3 → 20.6 / 21.6 ms), with the submit after the store 55.0 / 54.6, with the reap after it about 56. One dumped menu frame each, switch on against off: mean |diff| 0.012, no pixel over 30.Overlap: #9898 and #9445 also change
VulkanDevice.cpp; #9898 changes the imported-label path ofWriteLabelOnGpuand #9445 the completion checks ofCompletePendingCpuWritesandFillBuffer, not the unimported path.Tested
On
24da8d9aaemerged ontomain484b0368d3, compared with thatmain(details).tools/vulkan_validation_gate.pyexits 0 on Windows 11 (RTX 5070, NVIDIA 621.47, WinLibs GCC 15.2.0 r7, Khronos validation 1.4.335) and on Linux (WSL 2 Ubuntu 26.04, lavapipe Mesa 26.2.4, Khronos validation 1.4.341). It ran 9 tests, 3 iterations per build, with noVUID-on either side. Every ctest entry of 16 related AGC test executables was also run with the layer. On Windows 277 entries onmainand 279 on the branch all passed. On Linux 253 and 255 entries passed except the same 18 skips on both sides. No entry changed status and no validation ID is new.agc_driver_draw_allocationspasses on Linux.The injected submit-failure case failed on
f479c5f69because the CPU label changed and passed on51f87d9ee3with the label left untouched.On the earlier
9c7a3226f9head, Leandro reported in #25787 19/19 focused AGC checks on bothmain45c209da71and the branch, on Windows 11 (10.0.26300), NVIDIA RTX 5060 Ti (621.24), WinLibs GCC 15.2.0 r7, Release. Khronos validation 1.4.363 loaded in every log, with noVUID-lines. The older Linux and title runs below were on earlier revisions.Earlier revision: #7464
d74ab1fd88+ this commit. Windows 11 Pro 26300, Ryzen 7 5800H, RTX 3070 Laptop GPU (NVIDIA 621.01), WinLibs GCC 15.2.0 r7, Release: every ctest entry ofagc_driver_recorder_tests(86),agc_driver_unimported_label_order_tests(2),agc_driver_same_queue_label_wait_tests(3),agc_driver_graphics_tests(30),agc_driver_pass_input_hazard_tests,agc_driver_storage_flush_ordering_tests,agc_driver_pipelined_dma_tests(2),agc_driver_indirect_arguments_pending_producer_testsandagc_driver_alias_copy_label_testspasses.Linux (Ubuntu 26.04 in WSL, llvmpipe), on the measurement stack above:
agc_handoff_spin,agc_driver_unimported_label_order(2),agc_driver_copied_writer_label_order(2),agc_driver_same_queue_label_wait(2) andagc_driver_recorderpass.Titles: SuperTuxKart menu as above. vkQuake (PPSA99010), on the earlier stack: never takes this path (no
[early-labels]line), 82–85 FPS with this series and without it. A SuperTuxKart race takes it (about 7000 labels stored at once per 10 s) but was not measured with and without. Not run: the full CTest suite, other titles, other GPUs.Checklist
main13aa5703b3, thenmain6ef4f2f73bmerged in (e5e086ff27). Merges cleanly intomain484b0368d3and was tested on that merge.NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)SuperTuxKart trace summaries
First matched tutorial-race pair from Leandro's runs. The benchmark comment has the full run table and trace analysis.
main (
45c209da71)this PR (
9c7a3226f9)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T22:01:04Z.
Review: CHANGES_REQUESTED
Reviewed exact head
77fe6e4d65af36605aa4be5d7b2ab3e8b8f3165bagainst refreshed upstreammainc8d34aa8f4d8058d57169cc1e423ba6db00faaf0.The
UnfinishedGuestTouchgate is conservative across completions, writes/stores, in-place reads, and signaled in-flight batches;SubmitAfterEarlyLabelkeeps the open batch/submission and reap ordered after the label store. The added test categories cover early-label ordering and the relevant writer/recorder paths. The Windows/Linux suite and SuperTuxKart measurements in the description are useful, but they were run on a stack based on9d4fb4fb70with several local changes. Current main has 20 commits not present in this branch, including subsequent AGC changes.A current-main merge-tree preview has a content conflict in
core/libs/prx/libSceAgcDriver/CMakeLists.txt(other changed C++/docs files auto-merge). Please update this branch to current main and resolve the test-registration conflict while preserving both the new tests and current-main registrations. Then rerun the focused Windows and Linux suites on that exact composition, includingagc_driver_unimported_label_order, copied-writer label ordering, same-queue waits, recorder/graphics, and guest-memory lifetime tests. Report exact executed tests and skips; refresh the title/performance comparison on the final stack if the current-main interaction changes the measured path.Local current-main conventions and diff-check pass, but do not establish integration correctness. Hosted eligibility, intake, labels, report, and conventions pass; hosted build/product jobs are skipped. I did not run Windows/GPU tests locally. This request is based on the concrete merge conflict and stale test base, not a claim that the label-order implementation is incorrect.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T22:21:23Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed label and recorder paths inspected at head
73dac6c1e7a78e9045d0763f38c7980f56204308show no verified blocking defect; several changed files were only inspected at targeted ranges, so this review does not establish a complete basis for approval.What I ran
No commands or tests were run. I read the prepared description, commit list, manifest, and diff, then used
repo_read.pyto inspect changed code and related recorder behavior.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
The full contents of every changed file were not reviewed. In particular, only targeted ranges were read from
VulkanDevice.cpp,ShaderResources.cpp,Texture.cpp,tests/Recorder.cpp,PacketMemory.cpp,Recorder.cpp, andDraw.cpp; the remaining changed files were not fully read. The manifest marksVulkanDevice.cpp,ShaderResources.cpp,Texture.cpp, andtests/Recorder.cppas excluded from the preparedfiles/bundle because of size; their targeted ranges were obtained throughrepo_read.py. No build, tests, or runtime checks were performed by this review.To get this to a good state
Nothing is required. Optional: complete review of the changed-file contents and run the relevant tests before making a formal merge decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T17:55:30Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the code reviewed; the author-reported focused checks and title measurements were not run by me.
What I ran
Reviewed head
9c7a3226f9bf2b8bbdaa13e94314f767d7831b59usingrepo_read.pyto inspect the prepared diff and selected source ranges. No tests or builds were run.Results
Findings
Blocking
None identified in the code reviewed.
Non-blocking
None.
Not verified
Full text was read for the 9 included changed files:
VulkanDevice.hpp,PacketMemory.cpp,DeferredLabels.cpp,Recorder.hpp,ShaderResources.hpp,Draw.cpp,Recorder.cpp,UnimportedLabelOrder.cpp, andENVIRONMENT.md. Targeted ranges were read for the 3 excluded changed files:VulkanDevice.cpp,ShaderResources.cpp, andTexture.cpp; their full text was not read.tests/Recorder.cppwas listed in the manifest but excluded from the review folder; its changed hunks were inspected in the diff, but the file at head was not read. Other behavior outside the inspected ranges, the full test suite, builds, and runtime behavior were not verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T02:56:40Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected code supports the early-label ordering described, but several changed files were not fully reviewed, so a formal approval is not justified.
What I ran
Reviewed head
cea29fd651f43708acf4e03bbe79586e839d6a32using the prepared description, commit list, manifest, diff, and pinned repository reader. No build or tests were run. The description reports focused AGC checks on Windows; those results were not independently verified.Results
Negative control
Not run; no tests were executed.
Findings
Blocking
None found in the code inspected.
Non-blocking
VulkanDevice.cpp,ShaderResources.cpp,Texture.cpp, andtests/Recorder.cppbecause they were too large. I inspected relevant ranges in the first three through the pinned reader, but not the full files;tests/Recorder.cppwas not inspected. The core touched behavior merits a full review of those changes before treating this as approved.Not verified
VulkanDevice.cpp,ShaderResources.cpp,Texture.cpp, andtests/Recorder.cpp.Execution/include/VulkanDevice.hpp,Execution/src/Driver/Packets/PacketMemory.cpp,Execution/src/Driver/Synchronization/DeferredLabels.cpp,Execution/src/VulkanDevice.cpp,Graphics/include/Recorder.hpp,Graphics/include/ShaderResources.hpp,Graphics/src/Draw.cpp,Graphics/src/Recorder.cpp,Graphics/src/ShaderResources.cpp,Graphics/src/Texture.cpp,tests/Recorder.cpp,tests/execution/UnimportedLabelOrder.cpp, anddocs/dev/ENVIRONMENT.md.Execution/src/VulkanDevice.cpp,Graphics/src/ShaderResources.cpp,Graphics/src/Texture.cpp, andtests/Recorder.cpp(too large for the review folder). The remaining changed files were included there; several were inspected only through their diff or targeted ranges.To get this to a good state
Nothing is required. Optional: complete review of the uninspected changed-file content and run the focused checks on this head before requesting approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T14:22:26Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code blocks merging; the performance evidence is incomplete for a formal approval.
What I ran
Reviewed head
f479c5f6903ddec006563344baab15bdc9ae5def, based onmain; no merged-preview check was run. I inspected the changed ranges and relevant source context withrepo_read.py. No compiler or build toolchain was used.Reviewed changed ranges in all 14 manifest files, including the four whose full text was omitted from the review folder:
VulkanDevice.cpp,ShaderResources.cpp,Texture.cpp, andtests/Recorder.cpp.files.jsonlists no files excluded by rule.Results
Negative control
Not run; no tests were executed or modified during this review.
Findings
Blocking
None.
Non-blocking
No code-level findings.
Sources
Not verified
The description reports test and runtime results, but I did not run them. The review materials contain performance summary records and trace filenames, but not the raw traces or digest output; those performance artifacts are not verified here. The full test suite and other GPU or title behavior were not verified.
To get this to a good state
Nothing is required. Optionally provide the raw performance traces and digest output to complete the performance evidence.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T14:24:31Z.
Review: COMMENTED
Actionable comments
fb5c7937-d5d7-436b-a325-36a60b5b1ef5Reviewing files that changed from the base of the PR and between
8968347f3eandf479c5f690.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/DeferredLabels.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/UnimportedLabelOrder.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T15:23:18Z.
Review: APPROVED
Reviewed — looks good
The change at head
51f87d9ee303d6f250487108a4a8178d90700fcapreserves the guest-memory ordering checks while allowing labels to be stored after safe batches are submitted.What I ran
Read the prepared description, commits, manifest, diff, and changed source context using
repo_read.pyat the pinned head. No tests or builds were run.Reviewed all 14 files listed under
reviewedinfiles.json; no files were excluded.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The focused checks and performance measurements described by the author were not run during this review. Full CTest coverage, other titles, and other GPUs were not verified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T15:28:32Z.
Review: COMMENTED
Actionable comments
c5a4726b-b3f3-4c22-b794-2efc1a803509Reviewing files that changed from the base of the PR and between
f479c5f690and51f87d9ee3.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/DeferredLabels.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/execution/UnimportedLabelOrder.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T15:43:21Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at
b53ff1ad0b2bf28c756d5f10c6bd894273abc79ahas no verified blocking defects; the inspected code supports merging.What I ran
Inspected the prepared diff and changed code at the exact head above using
repo_read.pysearch and cat. I ran no build, tests, or runtime checks. The author reports focused tests on an earlier revision,51f87d9ee3.Files read:
core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp,Execution/src/Driver/Packets/PacketMemory.cpp,Execution/src/Driver/Synchronization/DeferredLabels.cpp,Execution/src/VulkanDevice.cpp,Graphics/include/Recorder.hpp,Graphics/include/ShaderResources.hpp,Graphics/src/Draw.cpp,Graphics/src/Recorder.cpp,Graphics/src/ShaderResources.cpp,Graphics/src/Texture.cpp,tests/Recorder.cpp,tests/cmake/agc_driver_recorder_tests.cmake,tests/execution/UnimportedLabelOrder.cpp, anddocs/dev/ENVIRONMENT.md. The four files whose full text was not included in the review folder were inspected in relevant ranges throughrepo_read.py.files.jsonlists no files excluded by rule.Results
Negative control
Not run; no tests were executed in this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I did not run tests, builds, console behavior, or performance measurements on this head. The performance and test results in the PR description are author-reported; the described focused test run is on an earlier revision.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T15:48:59Z.
Review: COMMENTED
Actionable comments
5ca454db-32b1-4f85-9e87-b97ea3afca47Reviewing files that changed from the base of the PR and between
51f87d9ee3andb53ff1ad0b.core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/execution/UnimportedLabelOrder.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:23:27Z.
Review: COMMENTED
I tested
b53ff1ad0bagainstmainat9d362fb088on Linux with Mesa lavapipe. The GCN scalar-buffer case and all three unimported-label-order cases passed on both revisions, including the draw-pipeline and plan-verification modes. The branch'sagc_recorder_unfinished_guest_touchcase also passed. All runs required Vulkan and disabled the shader cache. The loader insertedVK_LAYER_KHRONOS_validation1.4.369, with no missing-layer warnings orVUID-messages. This comparison used software Vulkan.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T20:59:29Z.
Review: COMMENTED
Actionable comments
83813b71-48a2-4275-9b93-4765e11f5fc3Reviewing files that changed from the base of the PR and between
b53ff1ad0bande5e086ff27.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T22:59:59Z.
Review: APPROVED
Reviewed — looks good
The reviewed change is sound at head
e5e086ff27e7ef2c0c2e9ba82a45f0c567ad9670, and I found no verified blocking defects.What I ran
Read the prepared diff and reviewed changed code at the pinned head with
repo_read.py. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Behavior claims were checked against the prepared diff and source at the pinned head, including WriteLabelOnGpu, UnfinishedGuestTouch, and MarkGpuWrites.
Not verified
No tests, builds, console runs, or GPU behavior were independently verified. All 14 paths listed under
reviewedinfiles.jsonwere covered through the prepared diff and targeted pinned-source reads; no paths were excluded by rule. Full head text was prepared for 10 changed files; the remaining 4 were reviewed through their diff hunks and relevant pinned-source context.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T12:38:39Z.
Review: COMMENTED
Actionable comments
ebb86cf3-9394-4a1b-a079-234cfef0c9cdReviewing files that changed from the base of the PR and between
e5e086ff27and29fd27976e.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/DeferredLabels.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_unimported_label_order_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/UnimportedLabelOrder.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T13:00:13Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at head
24da8d9aae176e4b2d29b22d21e5736f416dd709show no verified blocking defects.What I ran
Reviewed the prepared diff and changed hunks at the pinned head with
repo_read.py; no merged-preview check or executable checks were run.Results
Negative control
Not run; no executable checks were run during this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No runtime behavior, console behavior, or other hardware and operating system configurations were verified. The review folder supplied full text for 11 changed files; targeted head ranges were read for the four whose full text was not included:
VulkanDevice.cpp,ShaderResources.cpp,Texture.cpp, andtests/Recorder.cpp. The remaining changed paths were reviewed from the prepared diff and supplied file text.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.