perf(agc): record BDA stores in per-range granule bits and a page map instead of the note_bda_write hash table #22944
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22944"
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 Ketz7 on 2026-11-18T14:09:54Z.
What
note_bda_writeand its call sites are gone. It probed a 2048-slot hash table in the fault buffer after every BDA store (up to 8 atomic loads and CASes, an IAdd and an OR) and failed the dispatch past 2048 chunks.get_bda_write_pointer,probe_bda_write_pointer,get_bda_atomic_pointer) record a store where they already know its range and[address, address + bytes):Range::written(wasreserved). The assignment depends only on the ranges, so cached tables stay valid.writtenword and reportInvalidTablefor0xffffffff, which no table holds. Every lookup used to check this word against 0; dropping that check made LLPC compile vkQuake's 181k-word compute shaders about 20% slower once the write lookups held atomics.WrittenAddressLimitare removed;BdaAbi::Versionis 3, and the tests that set or check the BDA ABI version useBdaAbi::Versioninstead of1.APS5_BDA_WRITE_STATS=1prints:ENVIRONMENT.md.Tested
Windows 11 Pro 10.0.26300, AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (32.0.32015.7029, LLPC), Release builds, main
8dbb3bf68dand this branch1122de2b35.APS5_TRACE_SECONDS=10:20, same machine and session. It is GPU-light and stores little through BDA, so frame times are equal (p50 16.681 / 16.682 ms); the traces are attached.main:
this branch:
Compile time, the claimed gain: every vkQuake (PPSA99010) compute pipeline of 50k+ words, captured in game and compiled cold and alone with
agc_compute_pipeline_replay, 2 passes, base9dcf983with #21708's commits so the shaders get dispatched:Run time, measured on #22372 (Linux, RTX 4090, Release, main
9dcf983against this branch, alternating arms):Validation layer: the focused GPU tests (
agc_driver_bda_device,agc_shader_memory,agc_driver_graphics,agc_rect_list_position_invariant,agc_spirv_lds_atomic_lock,agc_bda_atomics,agc_lds_lock_budget) withctest -V,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, layer 1.4.368:Insert instance layer "VK_LAYER_KHRONOS_validation"and nowas not found but was requested;The branch's 89 BDA tests pass with
ANYPS5_REQUIRE_VULKAN=1.New test
RunBdaCoarseStoreTests, with two writable ranges at 2 MiB granules 512 MiB apart, so their pages share page-map bits, and one fault buffer kept across the stores:The store and dword-write tests require the exact set of written pages at 4 KiB granules, plus the dirty word.
The block tests cover:
tools/trace_digest.pyof the two traces:main
8dbb3bf68dseconds 10:20 from present 596: 1199 presents, frame p50 16.7 / p90 16.9 / p99 17.0 / max 17.1 ms, GPU busy 4.7 ms per present
AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
8dbb3bf68d, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 15.7, Driver.WorkerWait.idle_and_completion_poll 15.7, VideoOut.Flip 15.5, VideoOut.Flip.vblank_wait 14.3, batch 4.7, VideoOut.Flip.present 1.1, Driver.Present 1.1, Driver.Packet 0.8, Graphics.Draw 0.7, Graphics.Draw.draw_and_resource_release 0.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
this branch
1122de2b35seconds 10:20 from present 595: 1199 presents, frame p50 16.7 / p90 16.9 / p99 17.0 / max 17.0 ms, GPU busy 4.5 ms per present
AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
1122de2b35, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 15.8, Driver.WorkerWait.idle_and_completion_poll 15.8, VideoOut.Flip 15.6, VideoOut.Flip.vblank_wait 14.4, batch 4.5, VideoOut.Flip.present 1.1, Driver.Present 1.1, Driver.Packet 0.8, Graphics.Draw 0.7, Graphics.Draw.draw_and_resource_release 0.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T16:08:21Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected implementation blocks merging; the reported test and performance results are author supplied and were not run in this review.
What I ran
Reviewed head
1122de2b35bcfdfcff82927e58ea7acf73ade073using the prepared diff andrepo_read.pyat the pinned head. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppwas excluded from the review folder; only the changedAddressTableKeycontext was read through the pinned reader. Other changed files were not individually read in full, including test-only ABI version updates. No build, automated test, CI run, console behavior, or performance measurement was verified. The description’s test and benchmark claims were not independently confirmed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:37:55Z.
Review: COMMENTED
Reviewed — no blocking findings
The draft review could not be completed because no reader command or review-folder contents were available in this session.
What I ran
Not run. The required
repo_read.pyreader was not accessible through the available tools.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The PR description, commits, diff, manifest, changed-file contents, and repository context were not read. No files can be claimed as read or compared with the reviewed list.
To get this to a good state
Provide access to the reader and prepared review folder so the requested review can be completed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T19:15:46Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
ac8141c76ccd60eb4b40ce73b5371382ef1c71a3using the prepared diff and the pinnedrepo_read.pyreader. I inspected the changed hunks for all 37 reviewed paths, with targeted source context for the BDA ABI, lookup, page gathering, and host bookkeeping. No build or tests were run.Results
Negative control
Not run; no tests were run during this review. The description reports that removing either last-page bitmap bit makes the focused test fail.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Author-reported focused test results, validation-layer results, and performance measurements were not independently rerun. The manifest lists 37 reviewed paths and no excluded files; the changed hunks were reviewed, with targeted head context read for the core implementation paths.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T19:20:38Z.
Review: COMMENTED
Actionable comments posted: 5
Architecture findings (2)
Advisory architecture findings (2)
71495d6d-a48b-4719-b3db-2ab77c6fb98bReviewing files that changed from the base of the PR and between
76d0a4a7dcandac8141c76c.core/libs/prx/libSceAgcDriver/Graphics/shaders/StorePageGather.compcore/libs/prx/libSceAgcDriver/Graphics/src/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/BdaContracts.cppcore/libs/prx/libSceAgcDriver/tests/BdaDevice.cppcore/libs/prx/libSceAgcDriver/tests/BdaExecution.cppcore/libs/prx/libSceAgcDriver/tests/BdaShader.hppcore/libs/prx/libSceAgcDriver/tests/ControlFlow.cppcore/libs/prx/libSceAgcDriver/tests/DenormalFlushElimination.cppcore/libs/prx/libSceAgcDriver/tests/F32DenormPreserve.cppcore/libs/prx/libSceAgcDriver/tests/F32NanResultSelects.cppcore/libs/prx/libSceAgcDriver/tests/Float16Conversion.cppcore/libs/prx/libSceAgcDriver/tests/GotoJunctionDescriptor.cppcore/libs/prx/libSceAgcDriver/tests/LdsLockBudget.cppcore/libs/prx/libSceAgcDriver/tests/NanPayloadElimination.cppcore/libs/prx/libSceAgcDriver/tests/RedundantValueElimination.cppcore/libs/prx/libSceAgcDriver/tests/RunReportShaderFailure.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderReplayRequests.cppcore/libs/prx/libSceAgcDriver/tests/SpirvBranchTargets.cppcore/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cppcore/libs/prx/libSceAgcDriver/tests/SpirvSubvectorLoopBegin.cppcore/libs/prx/libSceAgcDriver/tests/SubgroupBarrier.cppcore/libs/prx/libSceAgcDriver/tests/VectorWindow.cppcore/libs/prx/libSceAgcDriver/tests/WaveControlDecode.cppcore/libs/prx/libSceAgcDriver/tests/execution/F16ToF32Unpack.cppcore/libs/prx/libSceAgcDriver/tests/execution/F64FmaSubnormals.cppcore/libs/prx/libSceAgcDriver/tests/execution/Float16ConversionProbe.cppcore/libs/prx/libSceAgcDriver/tests/execution/Float16NanProbe.cppcore/shader/recompiler/BdaAbi.hppcore/shader/recompiler/CMakeLists.txtcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cppcore/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cppcore/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.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-11-30T22:04:05Z.
Review: COMMENTED
Reviewed — no blocking findings
No blocking defect was verified in the prepared patch at head
6c246d9678b80978eaf07fe2deaf16d30eb42b39, but the omittedGuestBufferMemory.cppprevents a formal approval.What I ran
Reviewed the prepared diff and targeted included source ranges. No base or merged preview was used. I did not run tests or compile anything. The pinned reader failed because it could not write its read log in the read-only run folder.
Results
Negative control
Not run; no changed behavior was tested in this review.
Findings
Blocking
None.
Non-blocking
None verified.
Sources
Not verified
The prepared description, commits, manifest, file list, and diff were read. Relevant included text ranges were read for
BdaAbi.hpp,BdaResources.cpp,StorePageGather.comp,SpirvBdaLookup.cpp,BdaContracts.cpp, andBdaDevice.cpp; other included files were inspected through their diff hunks.GuestBufferMemory.cppwas listed as a changed file but its full text was not included, and the pinned reader could not read it. The author-reported tests and performance measurements were not independently run or confirmed.To get this to a good state
Nothing is required. For a complete review, make
GuestBufferMemory.cppavailable through the pinned reader and inspect its changed context; no tests or build need to be rerun for that follow-up.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T22:06:21Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
ea19009d-6d1d-4495-8213-d7be9d4008b1Reviewing files that changed from the base of the PR and between
ac8141c76cand6c246d9678.core/libs/prx/libSceAgcDriver/tests/SampleBitDescriptor.cppcore/libs/prx/libSceAgcDriver/tests/execution/F64LdexpDirectedRounding.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-01T08:08:16Z.
Review: APPROVED
Reviewed — looks good
The BDA write tracking changes are consistent across the ABI, shader, host processing, and updated tests; I found no blocking defect at head
2e167bfb01a6e3e301b45a029b7c1b701176e134.What I ran
Reviewed the prepared diff and changed hunks in all 43 files listed as reviewed in
files.json; inspected targetedGuestBufferMemory.cppcontext withrepo_read.py. No tests or builds were run.Results
Negative control
Not run; no tests were executed in this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Reviewed code at the pinned head: BdaAbi.hpp, SpirvBdaLookup.cpp, and StorePageGather.comp.
Not verified
The author-reported test results, performance measurements, and attached traces were not independently reproduced.
files.jsonreports no excluded files; changed hunks were reviewed for all 43 files listed underreviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T08:21:23Z.
Review: COMMENTED
🏛️ Architecture findings (3)
Advisory architecture findings (3)
💬 Code review
4a3f7c41-e308-4b7b-88db-27cc00fdab97Reviewing files that changed from the base of the PR and between
6c246d9678and2e167bfb01.core/libs/prx/libSceAgcDriver/Graphics/include/BdaResources.hppcore/libs/prx/libSceAgcDriver/Graphics/shaders/StorePageGather.compcore/libs/prx/libSceAgcDriver/Graphics/src/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/BdaExecution.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_bda_device_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_bda_store_heap_mirror_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/BdaStoreHeapMirror.cppcore/shader/recompiler/BdaAbi.hppcore/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.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-01T09:44:06Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
d6eaec1b9e284f598b5bc0e066a4baf8ebcc24c1. I inspected the prepared diff and sampled source throughrepo_read.py; I did not run tests or builds. The reader returned source content, then reported that it could not append its read log because the workspace is read-only.Results
Commands
Findings
Blocking
None identified in the sampled code.
Non-blocking
No code findings. The review is incomplete because most changed files were not read.
Sources
Not verified
The manifest lists 45 changed files. I read source context in 7 of them:
BdaAbi.hpp,SpirvBdaLookup.cpp,SpirvBdaRead.cpp,StorePageGather.comp,BdaResources.cpp,GuestBufferMemory.cpp, andRecorder.cpp; those reads were targeted, not full-file reviews. The other 38 changed files were not read.ShaderResources.cppwas also not read. No automated checks were run; test, validation-layer, and performance results in the description were not independently confirmed.To get this to a good state
Nothing is required. Optionally complete review of the remaining changed files and run the relevant checks on this head before relying on a formal approval.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T09:50:25Z.
Review: COMMENTED
🏛️ Architecture findings (2)
Advisory architecture findings (2)
💬 Code review
4cb9a9cb-81cb-4643-8769-9f20a223cd0eReviewing files that changed from the base of the PR and between
2e167bfb01andd6eaec1b9e.core/libs/prx/libSceAgcDriver/Graphics/include/BdaResources.hppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.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 ligmaSec on 2026-12-03T22:00:54Z.
Review: COMMENTED
When a reported write overlaps an image table,
BdaResources.cpprefuses it for a precise block but only warns for a coarse block. Coarseness allows page-map aliases. It does not show that an observed overlap is one, so a real table write can also lose the old refusal. Please preserve exact accounting for image-table ranges or keep the refusal when they cannot be distinguished. The paired BDA controls and alias regression are queued on lavapipe. I did not repeat the title benchmark.AI-assisted: yes.
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.