perf(agc): let a draw that only reads through the BDA table continue its render pass #7184
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7184"
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 EagleBearerYS on 2026-10-17T15:22:26Z.
What
At Resident Evil Village (PPSA01556)'s title menu, render passes begun per 10 s fall from 158 to 4, and the menu images don't change. Recorded time per draw falls from 32.1 to 28.7 ms. Menu frames came faster in both pairs we ran, though at these frame counts that isn't yet a measured +10% (see Tested).
recordDrawpassed every address-based draw to the render-pass hazard tracker (PassHazards) as both an unknown reader and an unknown writer of guest memory.A program can only write guest memory through the BDA table with an instruction that writes through a
PhysicalStorageBufferpointer.SpirvStoresThroughAddresses), with the result kept by module content hash.PassHazards::Check'sUnknownRead). So such a draw continues a pass whose earlier draws wrote no guest ranges.APS5_NO_ADDRESS_READ_PASSES=1restores the old behaviour.DrawPassTotals(), and the address-based share in theAPS5_PROFILE_DRAWtotals), which the new test reads.Render targets reach guest memory only by explicit write-backs, so a read through the table sees the same bytes whether or not the pass breaks. A linear target over a host import (#6892) is stored back right after its draw, and that ends the pass either way. The change is driver-only: the recompiler and its disk cache don't change, so shader caches stay warm.
Credit:
perf(agc): GPU descriptor heap (APS5_GPU_HEAP)), with the read-only fact from #6946's recompiler fieldbdaReadOnly, which #6946 now also sets per build for its draw pipeline. This PR takes that change alone and keeps it in the driver, so it needs no shader cache format change. Once #6946 lands, its field replaces the SPIR-V scan, and that is how the two merge.wip/new-gpu-path, "order address-based builds by their known access ranges". This PR takes the read-only half of it, without his run-time pre-pass bounds.Related: #6947, #6946, #6175.
How to test
APS5_PROFILE_DRAW=1and wait at the title menu.[draws]line's "render passes N begun, M draws continued one" should show far fewer passes begun than withAPS5_NO_ADDRESS_READ_PASSES=1, with matching frames.Tested
agc_driver_bda_device,tests/BdaContracts.cpp) run the scan on the backend's own BDA test modules:MakeBdaTestShader,MakeBdaDwordReadTestShader) report no stores;MakeBdaStoreTestShader,MakeBdaWriteTestShader,MakeBdaDwordWriteTestShader) report stores;Modfwriting through a physical pointer;4ff3b0545: "store scan: a store through an untyped physical pointer was missed", "… an extended instruction writing through a physical pointer was missed", "… a cooperative matrix store was missed". Today's recompiler emits none of these forms.agc_pass_hazards: "unknown reads after unknown reads", "a ranged read after unknown reads", "a write after unknown reads (WAR guard)" and "unknown reads after a write".agc_driver_address_passes(tests/execution/AddressPasses.cpp, lavapipe):--readers, two draws reading through the table: fails without this change ("a draw reading through the table after another did not continue its pass: 2 address-based draws, 2 began a pass, 0 continued one"), both on the scanner commit alone and withAPS5_NO_ADDRESS_READ_PASSES=1; passes with it ("1 began a pass, 1 continued one").--store-after-read(a storing draw after a reader begins its own pass) and--read-sees-store(a draw reading what the previous draw stored sees it: "stored 1, brightest color byte 255") pass both ways.--read-sees-descriptor-store: a draw stores through a V# from user data, and the next draw reads it through the table. The reader begins its own pass and sees the store.--descriptor-store-after-read: the reverse order. The storing draw begins its own pass.--targets: a draw renders a color into a tiled or a linear target, and a read-only draw then reads the target's first dword through the table.agc_driver_address_passes_targets_splitruns the same cases withAPS5_NO_ADDRESS_READ_PASSES=1, and both must read the same bytes.guest_datagram_*,guest_tcp), which fail onmainthere too.4796eac2d: 1,338 tests, 1,268 passed, 65 skipped, 5 failed.main984e5d720, which has #6892: 1,353 tests, 1,282 passed, 66 skipped, 5 failed.agc_driver_address_passes,_targets_split,agc_driver_presentation_pass,agc_driver_native_multisample_depth,agc_pass_hazards,agc_driver_bda_device, and on the merge #6892'sagc_driver_linear_target_resident) passed 10 of 10 on both.agc_driver_address_passesand_targets_split×20 plus^agc(https://github.com/EagleBearerYS/AnyPS5/actions/runs/39040623423):^agc638 of 639, the failure beingagc_driver_preparation_scope_settle,main's load-sensitive flake; the libc and libkernel suites pass.^agc632 of 634:agc_shader_replay_toolandagc_driver_pm4_replay_toolexit with 0xc0000139 (a DLL entry point the sweep's runner doesn't find), and itsguest_kqueuesuite fails. That harness fails these onmaintoo.b31b95d5d) as-is, Release, Windows 10 Pro 22H2, WinLibs GCC 15.2.0 r7 (comment):1002:164e, driver 32.0.21045.5002), chosen withANYPS5_GPU:agc_driver_address_passespasses 5 of 5 (not skipped),agc_driver_address_passes_targets_split3 of 3, andagc_driver_bda_deviceandagc_driver_bda_span_reads3 of 3 each.agc_driver_address_passes_targets_split,agc_driver_bda_deviceandagc_driver_bda_span_readspass 3 of 3 each.ShaderInfo::bdaWrites) agrees on every one, so all of them qualify.4ff3b0545): no verdict changes, over the 4,616 address-based artifacts of the cache's current 41,183.mainplus the open fixes the title needs, ours and others') with this change. Each run was compared with the same build underAPS5_NO_ADDRESS_READ_PASSES=1.Settings: a warm shader cache and
APS5_LAZY_SHADER_PREPARE=1, which the test tree needs to run the title on this PC. The GPU's clocks weren't held. The menu is CPU-bound, with a frame every ~40 s, so the GPU doesn't set its pace.Profiled pair: about 11 minutes at the static title menu per run, with
APS5_PROFILE_DRAW=1. Medians of the last 60 windows of 10 s:APS5_NO_ADDRESS_READ_PASSES=1Unprofiled pair: 0.0117 against 0.0200 fps. The run without the change also compiled and linked pipelines inside its frames, so that pair overstates the gain.
At these frame counts the menu is faster, but not yet by a measured +10%. The menu images match.
APS5_NO_ADDRESS_READ_PASSES=1on one build: the same frames, and no errors (Animal Well's save was unchanged too).python3 tools/check_conventions.py --base origin/main: passes.Checklist
main; #6947 (a draft) contains the same rule inside its GPU heap, and #6946 sets the same read-only flag from the recompiler, as described under Credit; no other open PR implements these 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 github-actions[bot] on 2026-10-17T15:30:37Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderAddressResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderAddressResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderAddressResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-17T16:16:13Z.
AMD data point, since the description lists lavapipe and NVIDIA: head
b31b95d5das-is, Release, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, AMD Radeon Graphics (RDNA 2 iGPU,1002:164e, driver 32.0.21045.5002) chosen withANYPS5_GPU.agc_driver_address_passes: 5 of 5 pass (not skipped).agc_driver_address_passes_targets_split: 3 of 3 pass.agc_driver_bda_deviceandagc_driver_bda_span_reads(theBdaContracts.cppexecutable): 3 of 3 each.The last three tests also pass 3 of 3 on an RTX 3080 (617.42) in the same build.
Not checked: other tests, titles.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T16:22:51Z.
Thanks @TheSovietWaffle. GitHub's Windows runner has no Vulkan device and skips the new tests, so this is their first Windows run on a GPU in this PR, and the first on AMD. I've added both GPUs to Tested and GPUs tested.