Repository navigation
Conversation
…nder pass A guest buffer element the recompiler proves is only accessed through atomics (BufferResource::plain is false) and that no other allocation of the draw overlaps is passed to PassHazards as an atomic range. Atomic ranges of different draws over the same bytes do not conflict; they conflict with reads, read-write uses and write-only stores in both directions, and a flush packet seals them like write-only stores. APS5_NO_ATOMIC_PASSES=1 restores the previous behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting draws An atomic-only range joins the pass's atomics only when every write of the draw over it lands in a host import bound in place (GuestBufferMemory::WrittenInPlace). A copied region (a CPU copy, a GPU copy before its copy-back) keeps the previous behaviour. agc_driver_atomic_passes records two draws whose pixel shader adds 1 into one counter, once in a host import and once in a copied buffer, and checks the counter and how many draws continued a pass; agc_driver_atomic_passes_split runs it with APS5_NO_ATOMIC_PASSES=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing fields Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve Draw.cpp (keep AtomicPasses, take main's recordDraw trace argument and subdraw counter) and ShaderDiskCache.cpp (BufferResource 13 fields from this branch, ImageResource 43 fields from main). Main took format 47 for the resinfo change, so the combined layout is 48. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # core/libs/prx/libSceAgcDriver/CMakeLists.txt
# Conflicts: # core/shader/recompiler/ShaderDiskCache.cpp # core/shader/recompiler/ShaderDiskCache.hpp
Resolve the conflicts with main f42d8b4: - bufferAtomicOnly becomes ElementFlags like main's other per-element flags, and descriptorBindingBytes counts it. - The split test moves to tests/cmake/agc_driver_atomic_passes_tests.cmake. - Shader cache format 69 (main is at 68); DescriptorBinding 920 bytes, BufferResource 13 fields, ImageResource 50. - GuestBufferMemory keeps both WrittenInPlace and main's RunAccesses / MarkStagedWrites. Co-Authored-By: Claude <noreply@anthropic.com>
Main stages atomic elements of host imports in device memory. For a draw, the staged copy-in and copy-back each end the open render pass, so draws that only add into a small counter still break the pass, now as PassBreak::Command, and the atomic-pass rule has nothing to remove. Draws now bind their bufferAtomicOnly elements in place; dispatches keep staging them (the histogram kernels it was added for have no render pass), and elements a draw also loads or stores stay staged. APS5_DRAW_ATOMIC_STAGING=1 restores staging for draws. ASTRO BOT (PPSA21567 01.019.000), Sky Garden, RX 9070 XT / RADV, APS5_HOST_IMPORT_MIB=11815, 60 s of steady fly-in: about 11.1K render passes begun per 10 s against 47.3K with APS5_DRAW_ATOMIC_STAGING=1, GPU busy about 95 against 137 ms per present. Co-Authored-By: Claude <noreply@anthropic.com>
…p rule addGuestBuffer: main sweeps write-only elements of any record stride on discrete GPUs (the stride test is now Stride() != 0 and the 16-byte constant is gone). This change's in-place argument to AddWritable and its APS5_DRAW_ATOMIC_STAGING switch follow that line unchanged. Sweeping applies to compute dispatches and the in-place flag to draw builds, so the two do not meet. ShaderDiskCache: 13 BufferResource fields from this change and 51 ImageResource fields from main.
Main added imageUintStorage to DescriptorBinding and moved the shader disk cache format to 88; this branch adds bufferAtomicOnly. Keep both flags in descriptorBindingBytes, set the DescriptorBinding size check to 976 (both sides had moved it from 864 to 920 for one flag each), and move the format to 89.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 boykopovar#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 boykopovar#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:{"commit":"f42d8b4a447f","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"11815","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PROFILE_DRAW":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"40:25","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.5-arch3.1","os":"Linux 7.3.1-1-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31227,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 40:25","first_present":502,"ms":25391.530},"presents":97,"frame_ms":{"p50":218.978,"p90":223.867,"p99":3449.562,"max":3449.562},"gpu_busy_ms_per_present":143.887,"worker_busy_pct":{"queue worker 0x0":98.617,"queue worker 0x48":87.305,"queue worker 0x40":98.323,"queue worker 0x46":0.352},"top_phases_ms_per_frame":{"Driver.Packet":743.569,"Driver.Packet.memory_wait":436.728,"Driver.Packet.draw":212.982,"Driver.Draw":211.468,"Graphics.Draw":165.893,"Graphics.Draw.draw_and_resource_release":144.631,"Driver.Draw.shader_compile_and_link":97.187,"Driver.Draw.draw_enqueued":94.765},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-f42d8b4a447f-339619.json.gz"} {"commit":"a4e218f8cdb4","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"11815","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PROFILE_DRAW":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"40:25","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.5-arch3.1","os":"Linux 7.3.1-1-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31227,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 40:25","first_present":466,"ms":26013.739},"presents":107,"frame_ms":{"p50":195.816,"p90":199.718,"p99":205.315,"max":5212.140},"gpu_busy_ms_per_present":101.648,"worker_busy_pct":{"queue worker 0x0":98.592,"queue worker 0x48":80.709,"queue worker 0x40":99.905,"queue worker 0x46":0.316},"top_phases_ms_per_frame":{"Driver.Packet":678.196,"Driver.Packet.memory_wait":425.483,"Driver.Packet.draw":195.238,"Driver.Draw":193.727,"Graphics.Draw":164.756,"Graphics.Draw.draw_and_resource_release":143.956,"Driver.Draw.shader_compile_and_link":95.814,"Shader.DrawStage":80.336},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-a4e218f8cdb4-343655.json.gz"}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)