fix(agc): avoid CPU waits for GPU-ordered labels #9445
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9445"
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 Zenodeon on 2026-10-21T22:22:08Z.
What
Both
CompletePendingCpuWritesandVulkanDevice::FillBuffercombine a global count of pending host completions withPendingLabelInover the accessed range. An unrelated host callback can therefore make an ordinary GPU-ordered label triggerSyncThrough, even though that label needs no CPU completion.Use the existing
CompletionLabelInrange query at both sites. Resource reads and fills still wait for overlapping CPU completion stores and copied writers, and queued labels retain conservative handling. GPU label stores remain ordered before the fill by the existing store flush and transfer barriers.Add regressions for fresh and revalidated resource bindings and for uniform/patterned fills. The fill suite covers 16-byte and 4096-byte fills, 4/8/64/256-byte labels, labels crossing either fill boundary, disjoint labels, submitted batches, inline label runs and the in-place pattern-fill path. It checks that unrelated callbacks remain deferred, overlapping CPU labels finish before the fill, and completed bytes have the fill pattern. It also checks that overwritten labels are refused for later submissions with the optional late-label shortcut enabled, while earlier submission ordering remains intact. The seven fill test registrations exercise 324 scenarios.
agc_completion_label_waitis adapted from EagleBearerYS/AnyPS5@59fad38624, with contributor attribution preserved. The fresh/reused-binding regression remains.Related: #9858 independently changes the same resource-consumer predicate. This PR retains its original resource fix and includes the equivalent fill-path correction and its regressions. Neither PR is a dependency. No FPS or frame-time improvement is claimed without a matched gameplay benchmark.
Tested
November 2 rebase: head
03f66fe05fa1c6b8cf3e47fbfef7f18750661bfais based on main0580e5c951a8d436af2976a3f86a980c798ef5c2. Resolved the recorder test-registration conflict by placingagc_completion_label_waitin upstream’s newtests/cmake/agc_driver_recorder_tests.cmake; retained all four topic commits and contributor attribution. Fresh Release focused targets built with GCC 15.2 and SPIR-V Tools. The same 10 focused fill/recorder/resource-label tests on Windows RTX 4070 pass 10/10 on the rebased candidate; pinned main with identical fixtures and counter instrumentation fails the 8 intended false-wait cases. Overlapping CPU completion labels and existing recorder classification pass on both. Required Vulkan and disabled shader cache were used, Khronos validation actually loaded, no missing-layer warnings, skips or VUID errors; every test completed within 30 seconds. Earlier wider-suite results below are historical, not fresh results for this rebased head. No gameplay or Linux rerun is claimed. Conventions against this upstream base and diff checks pass; the required stale fork origin/main comparison still reports inherited findings.Rebased the combined branch onto upstream
mainb3b96098997751c89c32693ac67297f50f48a51d. The three commits retain the resource fix, attributed completion-wait regression and fill follow-up separately; candidate head iscdb2ff3f7426b588c6e09092272b59062fc43c2c.Built complete patched Release libraries and 33 focused test executable targets with GCC 15.2, CMake/Ninja and bundled SPIR-V Tools on Windows 11 build 26200, Intel Core i7-13700 and NVIDIA GeForce RTX 4070 (12 GiB), driver 610.88.
Ran the same 48 focused tests sequentially on the same machine/GPU with a 30-second timeout per test:
mainb3b96098997751c89c32693ac67297f50f48a51d, with this PR's regressions and registration overlaidcdb2ff3f7426b588c6e09092272b59062fc43c2cFor the main control, both changed production files were restored byte-for-byte from the pinned main commit. All remaining production files were already from that base. Both runs use identical test code, test names, environments and timeouts.
Main fails only
agc_copied_direct_ordering,agc_completion_label_waitand the six fill cases for GPU labels/disjoint CPU labels. The positive overlapping CPU-label case passes on both main and the change. The combined branch passes all eight regressions and all existing focused tests.Both runs set
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, with verbosectest. Khronos validation layer 1.4.335 actually loaded in both runs. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS; neither contains aVUID-validation error. No tests skipped and every test completed in under 30 seconds.The focused set covers resource binding/revalidation, CPU/GPU completion labels, uniform/patterned fills, stale-label lookups, copied/direct writers, pipelined fills and label waits, unimported-label ordering, host-import lifetime, BDA reads and shader-semantic regressions.
git diff --checkand conventions against the pinned upstream base pass. The requiredpython tools/check_conventions.py --base origin/mainwas also run: the fork's stale main causes 275 findings / 43 inherited errors; the isolated comparison against current upstream main passes.Ran
python tools/pr_overlap.py --branch codex/resource-fill-completion-labels --repo boykopovar/AnyPS5. The scan reported no confirmed collisions and 98 shared-file warnings from PRs that conflict with its base. Their topic patches were inspected for both changed predicates and the regression/test names. No duplicate fill-predicate change or fill regression was found. The independently verified parallel resource-predicate change in #9858 is disclosed above; the checker does not flag identical changes as a collision.Gameplay, cross-title stability and matched main-versus-PR game performance measurements are not completed for this combined branch. These tests establish removal of the false waits and preservation of the tested ordering/results. Logs are retained locally; no performance or stability gain is claimed.
Counter assertion follow-up (
db78f141cd5d620bd4b5be21a6fa489e91079849): the fill regression now directly checks that GPU-ordered labels leave the existing completion-label sync counter unchanged, disjoint CPU labels leave it unchanged, and overlapping CPU labels increment it exactly once. On the same Windows RTX 4070 setup with Vulkan validation loaded and shader caching disabled, all 9 focused fill/recorder tests pass; the same fixtures over pinned mainb3b96098997751c89c32693ac67297f50f48a51dwith counter instrumentation fail 7 intended false-wait cases, including the new counter assertions. The overlapping CPU-label and existing recorder classification tests pass on both. No missing validation layer, skips or VUID errors; each test finishes within 30 seconds. This follow-up does not repeat gameplay or Linux testing.Checklist
main; no other open PR implements the same functions — exception: #9858 independently changes the resource-consumer predicate, disclosed aboveNotImplemented_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 EagleBearerYS on 2026-10-22T02:30:13Z.
A data point for this change. fable-void made the same change on his fork (18b3bcaed9 on
wip/new-gpu-path; his recorder names the queryLabelStoredAtCompletionIn) and measured it on his tree. In a 110 s title check, this call site's sync waited 21.8 s in 376 syncs, about 58 ms each and roughly once per frame, all underGuestBufferMemory::UploadFinish. That was 22 % of queue worker 0's samples. After the change, frame time went from 222 to 204 ms, and the sync was gone from the samples.We had ported his fix to
main, and it comes to exactly this line, so we won't open ours. Its test is in 59fad38624 on our fork, in case it's useful:agc_completion_label_wait(--completion-wait-onlyof the recorder tests) carries his two checks.On GitHub's Linux runner it fails ×3 with
main's code ("a reader of a GPU-stored label waited for a batch whose only completion action writes no memory") and passes ×10 with the change (run).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:38:29Z.
Review: CHANGES_REQUESTED
The implementation narrows the wait predicate from any pending label to an actual completion label, and the regression proves that the unrelated callback remains deferred while the consumer gets the GPU-written value. The paired same-machine main/change run follows the repository’s required Vulkan-validation protocol: layer load is confirmed, no new
VUID-errors are reported, and the complete 31-test focused set passes on the changed head. Good evidence.The branch is still based on
a6dcea927, while current main is110a18ba01. I checked the intervening upstream history and found no commits to either changed file (ShaderResources.cpporRecorder.cpp), so this appears isolated; please nevertheless update the branch and rerun the focused validation comparison plus conventions/overlap so the report/checklist is current. Hosted product jobs are skipped. I did not run local GPU tests.Imported from boykopovar/AnyPS5. Originally posted by Zenodeon on 2026-10-22T09:33:29Z.
@MarcZX10 Rebased onto upstream main
7e2ba73e4c8c; the updated PR head isf7e0da24ca2e. The production predicate change is unchanged.Added
agc_completion_label_wait, adapted from EagleBearerYS's offered regression with co-author credit. It checks both the already GPU-stored label plus host-only callback case and the CPU completion label that must still make its reader wait. The original fresh/revalidated-binding coverage remains. The new test uses independent registration to avoid conflicts with other test additions.Reran the same 32 focused tests on Windows 11 build 26200, NVIDIA RTX 4070, driver 610.88:
7e2ba73e4c8c, with the regressions overlaidagc_copied_direct_orderingandagc_completion_label_waitfail at their intended false-wait assertionsBoth runs used
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationwith verbose ctest. Khronos validation 1.4.335 loaded in both; no missing-layer warnings, zeroVUID-errors, no skips, and every test finished within 30 seconds.Conventions against upstream pass, and GitHub's conventions check passed on the published head. The required
origin/maincomparison was also rerun; its stale fork base still includes 43 inherited errors, documented in the PR. The overlap scan completed with no confirmed collisions; its 49 shared-file warnings were reviewed for duplicate changes.The description and checklist now contain the refreshed commits, test set and results. Hosted product jobs remain skipped; these GPU results are from the local matched runs. Ready for another review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T14:01:43Z.
Review: APPROVED
Re-checked — new head, looks good
The new counter assertions and focused reruns address the remaining review request, and the current upstream base has no intervening changes to the reviewed implementation or tests.
At head
db78f141cd5d620bd4b5be21a6fa489e91079849against current base8948f1cec5b2a43f5da47ee2e581449acc3a02ca, the no-build precheck passed diff, conventions, and live mergeability; the hosted Windows job passed on this exact head. The author reports three passing runs of the focused tests on an AMD RX 9070 XT and reports paired Windows RTX 4070 baseline/change tests on the prior functional head; intervening upstream commits from tested baseb3b96098997751c89c32693ac67297f50f48a51ddo not change any reviewed implementation or test files. I did not run a local build or GPU tests; Linux hosted CI was skipped, and the AMD run did not have a Vulkan validation layer available.