perf(agc): draws that only update a buffer atomically continue one render pass #9852
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9852"
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 EdouardSence on 2026-10-22T18:21:10Z.
What
In ASTRO BOT's Sky Garden, one vertex shader that most draws use updates a 32-record counter buffer with buffer atomics. The recompiler counts an atomic element as both read and written, so every draw after the first saw a read-after-write hazard on the open render pass and began a new pass. Since #15887,
mainalso stages that counter through a device-local buffer for draws; the staged copy-in and copy-back each end the open pass (PassBreak::Command). Onmainf42d8b4a44, about 45K of the 265K to 275K draws per 10 s begin a render pass, 37K of them for a command; with this change about 10.7K of 290K to 300K draws, 2.1K for a command.This is the atomic counterpart of #7340, which left atomic buffers out on purpose.
BufferResource::plainrecords any non-atomic access of a buffer (Merge).DescriptorBinding::bufferAtomicOnlymarks an element whose every access is an atomic: atomic, not plain, and not aliased by an image (imageAlias). The shader disk cache stores both.bufferAtomicOnlyelements of host imports in place (Region::inPlace, checked byGuestBufferMemory::stagingWanted) instead of staging them. Dispatches keep staging them (the histogram kernels atomic staging was added for have no render pass), and an element a draw also loads or stores stays staged.APS5_DRAW_ATOMIC_STAGING=1restores staging for draws.ShaderResources::AtomicOnlyRanges(): the guest ranges of atomic-only elements that no other allocation of the draw overlaps, built likeWriteOnlyRanges().recordDrawkeeps only the ranges whose every write by the draw lands in a host import bound in place (GuestBufferMemory::WrittenInPlace). A CPU copy already makes the drawunknownMemory, and a GPU copy or a staged copy keeps the previous behaviour.recordDrawtakes the kept ranges out of the draw's hazard reads and writes and passes them asPassAccess::atomics. The recorder's write tracking (NoteAccess, pending writes) still sees them as written.PassHazards:SealWriteOnly()also moves the open pass's atomic ranges into its writes. A flush packet between two draws still orders their atomics.recordDrawalso keeps the device read count up to date after the write-only erase, so the atomic erase stays within the draw's own device reads.APS5_NO_ATOMIC_PASSES=1restores the previous hazard rule.Overlaps (textual only; whichever lands second adapts):
mainf42d8b4a44and currentmaine917850d23are at 68; this PR writes 69. An open PR that bumps the sameFormatVersionline takes the next free version after whichever lands first.git merge-treeof this head against currentmaine917850d23is clean.tools/pr_overlap.pylists open PRs that touch the same files (mostly thedocs/dev/ENVIRONMENT.mdtable); none implements the same change.Tested
Exact revisions: this PR at
a4e218f8cd. Themainside isf42d8b4a44, themainthat this head last merged (its merge-base withmain), so the two builds differ only by this PR.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R <pattern> -V:agc_driver_buffer_atomics,agc_driver_global_atomics,agc_driver_recorded_draw_staging,agc_driver_graphics,agc_driver_recorder,agc_pass_hazards,agc_shader_disk_cache. This branch addsagc_driver_atomic_passesandagc_driver_atomic_passes_split, which do not exist onmain.mainpasses 6 and this branch 8;agc_driver_recorded_draw_stagingskips on both (this device does not keep host imports write-watched). Neither log has aVUID-line orwas not found but was requested by env var VK_INSTANCE_LAYERS, and in both the loader loadsVkLayer_khronos_validation.json. Logs: main, this PR.agc_driver_atomic_passes(tests/execution/AtomicPasses.cpp): a pixel shader adds 1 into one counter withbuffer_atomic_add. One draw adds Width×Height. Two consecutive draws into a host-imported counter add twice that, and the second continues the first's pass. Two draws into a copied counter (not a guest allocation) add twice that, and the second begins a new pass.agc_driver_atomic_passes_splitruns the same withAPS5_NO_ATOMIC_PASSES=1, where no draw continues and both sums still match.agc_driver_recorder: a 64-byte atomic counter added as a draw's atomic-only element is bound in place andWrittenInPlacereports it; added as a plain atomic element it is staged.testAtomicsinagc_pass_hazardscovers each hazard pair and the seal.agc_shader_disk_cacheround-tripsbufferAtomicOnlyand checks it in the binding plan.-lvl underwater_aerial_garden), headless gamescope 3840×2160, title defaults, no input, 180 s per run.APS5_NO_SNAPSHOT_CHECK=1 APS5_HOST_IMPORT_MIB=11815 APS5_PROFILE_DRAW=1 APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_EVENTS=4194304 APS5_TRACE_SECONDS=40:25on both sides.main, PR,main, PR.commandmainf42d8b4a44, round 1a4e218f8cd, round 1main, round 2The 25 s trace windows (
trace_digest.pyandperformance_compare.py):mainp50 / p90 ms, GPUThe PR's round 2 run took about 15 s longer to load, so its window starts with the level's first slow interval (155 ms GPU) and ends at 65 s; the 10 s intervals after it stay at 102 to 103 ms. Round 1's
mainwindow ends as that run's drop begins (one 3.4 s frame) and the PR's has one 5.2 s frame; p99 and max in those windows come from those single frames. No trace dropped events.Frame p50 drops by about 10 % and GPU time per present by about 29 %; render passes begun drop by about 76 %. The queue workers stay at ~99 % on both sides.
Artifacts for all four runs (release): traces,
aps5-summary.jsonl,trace_digest.pyoutput, and theperformance_compare.pyoutput of each round. Round 1 summary lines:APS5_DRAW_ATOMIC_STAGING=1(in the conversation) shows the same direction: about a quarter of the render passes and ~100 against ~177 ms GPU per present.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-29T06:25:21Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The performance report is substantial: it has matched traces/digests for the same scenes and machines, including an independent NVIDIA run, and the author reports validation-layer tests. The current exact head
470cbe5b01a3d55e2698086ecb47059f3ded6b73also records cache format 50, correctly above current main’s 49.The integration and performance evidence need one more refresh. This head is 318 commits behind current
main2960e9a6e7e1fc99c4ed180c71495b5eb83464c7; bothDraw.cppand the AGCCMakeLists.txtchanged on both sides since its merge base. The main-sideDraw.cppchanges affect draw preparation/recording, so the previous atomic-pass A/B and full test run onb9eafb0c49do not validate the current composition. Please merge current main, preserve the format-version ordering, run the focused atomic-pass/adjacent draw tests on both the integrated main and PR heads, and refresh the matched performance capture on any scene whose draw path changed.The author’s full CTest report on the previous head is 2738/2742; two failures match main on that tree, tessellation was previously observed on main, and image-table’s gamescope validation message is environment-specific. Please keep those results explicit and report a fresh baseline for any remaining failures. I did not run GPU tests locally.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T01:19:29Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The current head still lacks the matched
main/PR Vulkan evidence required for AGC changes and the complete performance artifacts required for aperfPR.What I ran
Reviewed head
a4e218f8cdb41149badf3e638759d01ef009e285; the no-build precheck used base4f7fbdb09575bf830ab3df93836a37057ecd5363and reported a clean merge preview. Environment: Linux 6.1, Python 3.11.2, Git 2.39.5, GCC 12.2.0.The author reports the focused Vulkan tests passing on this head. I did not run them locally or verify an equivalent
mainbaseline.Results
mainrun was provided.trace_digest.pyoutput and does not compare currentmainagainst the change.Precheck output
Negative control
Not run: I did not build the exact head locally, so I could not run a negative control against its new GPU execution test.
Findings
Blocking
perf, but the latest report fora4e218f8cdb41149badf3e638759d01ef009e285does not provide a matched capture of currentmainand this change from the same title, scene and machine, with bothaps5-summary.jsonllines, the two trace files andtools/trace_digest.pyoutput. The posted Windows comparison togglesAPS5_DRAW_ATOMIC_STAGINGon the PR head; it is useful A/B data, but it is not the requiredmain-versus-change capture. Please provide the matched artifacts for this head.mainand the change, with Vulkan validation enabled, to identify new validation errors. Please provide both logs and the comparison, or explain which focused cases cannot run onmainand why.Non-blocking
agc_add_default_testregistration shows those warnings are false positives; they are not findings against the PR.Sources
Not verified
To get this to a good state
Provide current matched
main/PR performance captures and the required focused Vulkan test logs for both revisions. I will re-check those artifacts against the same head before changing this review.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T18:30:38Z.
Review: COMMENTED
Reviewed — comments
The changed hazard tracking and in-place atomic binding paths were inspected at head
353c2960b77db373b419f1ddb5989e8477536251; material parts of the change remain unverified because several changed files were too large to include in the review folder.What I ran
No tests or build commands were run. I read the prepared description, commit list, manifest, diff, and targeted source ranges with
repo_read.py.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
Full text was available and inspected selectively for
GuestBufferMemory.hpp,PassHazards.hpp,ShaderResources.hpp,Draw.cpp,PassHazards.cpp,PassHazards.cpptests,ShaderDiskCache.cpptests, the atomic-pass CMake test, and the newAtomicPasses.cpptest. Targeted ranges were read for the excluded full-text filesGuestBufferMemory.cpp,ShaderResources.cpp, andRecorder.cpptests; their complete contents were not read. The remaining changed files listed in the manifest were not read. The reported test runs, performance results, other GPUs, and other titles were not independently verified.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed files and run the focused tests on this head before treating the review as approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T18:29:50Z.
Review: COMMENTED
Reviewed — no blocking findings
The review artifacts and repository files could not be read in this environment, so the change is not verified and a formal decision is not justified.
What I ran
No repository reader command was available to run.
Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The change description, commits, diff, manifest, changed-file contents, and files reviewed count were not available for inspection.
To get this to a good state
Provide access to
repo_read.pyand the prepared review artifacts so the change can be reviewed.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T09:27:52Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this review; the behavior claims and relevant code paths inspected support merging.
What I ran
Reviewed head
5c77b5d421f36c8b1be491f73af00c96d826a59athrough the pinnedrepo_read.pyinterface. No build or tests were run in this review; the focused test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
GuestBufferMemory.cpp,ShaderResources.cpp, andRecorder.cppwas not read; only relevant ranges and callers were inspected. The changed test files were not all read, and no tests were run. Performance measurements, other GPU vendors, and other titles were not independently verified. Files excluded by the prepared review manifest wereGuestBufferMemory.cpp,ShaderResources.cpp, andRecorder.cppas full-text artifacts; their relevant changed ranges were read via the pinned reader. All other changed files listed in the manifest were included in the review folder, but not every full file was read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:48:24Z.
Review: COMMENTED
Reviewed — no blocking findings
The review is incomplete because the prepared review materials could not be read in this environment.
What I ran
No commands run. The required reader and review folder were unavailable through the available tools.
Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The PR description, commits, diff, manifest, changed files, and repository context were not read. No findings can be substantiated.
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.