perf(agc): trap CPU reads of label readbacks and drawn linear targets on Windows #26699
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26699"
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 LeandroLP23 on 2026-11-24T16:14:11Z.
What
Label read traps now run on Windows too: at a label, a pending linear or small storage image over a host import gets a read trap (
GuestWriteWatchTrapReads) instead of a store, as on Linux since #19054, and so does a drawn resident linear target at a label, as on macOS. The first access stores the image. This removes the label store's wait for the GPU, which was 11.9 ms per frame ofRecorder.Syncin SuperTuxKart's race.ReadTrapsOverHostPointerImportsUsable), the same rule as on Linux.agc_read_trap_import_submitnow runs on Windows. On the RTX 5060 Ti (621.24), submissions kept working while a page of a host pointer import wasPAGE_NOACCESS. Other Windows drivers are not measured, so on them every image is still stored at the label. On this laptop's Radeon 860M nothing changes.ComparedHostImportCoversis false there). When a trapped image and the large image whose store reaches it were stored in the same batch, the 64 KiB block they shared was written by neither.agc_small_tiled_shadow_labelshowed it: the small image kept the bytes of an earlier store. On Windows a trap is therefore set only on an image that shares no 64 KiB block with any other pending image. Such an image is stored at the label instead, as without traps.Texture.cpp: the__APPLE__ || __linux__trap code also builds for_WIN32. The label readback takes the Linux path (ReadTrappableHostImportCovers). The drawn linear target takes the macOS path, withReadTrappableHostImportCoversin place ofHostImportCovers.TrapPageis 4096 on Windows.GuestMemory.cpp:TrappedPagesasks the write watch on Windows too.StoreDrawnLinear: the two-step block that #26273 added for macOS now also builds for Windows, withReadTrappableHostImportCoversin place ofHostImportCovers. The drawn targets' imports are checked outside the pending storage image mutex on both.DrawPipeline.cpp:CurrentThreadIdreturnsGetCurrentThreadIdon Windows, so the trap resolver can tell that the draw committer is waiting.ReadTrapImportSubmit.cppis ported to Windows (VirtualAlloc,VirtualProtect,vulkan-1.dll); the dma-buf part stays Linux-only.Recorder.cppgets a WindowsPageInaccessible. Its label trap block runs on Windows only where the driver allows traps over host pointer imports. The Windows variant of the large and small image steps expects the small image stored at the label.LinearTargetCompletionStores.cppexpects the drawn target trap on Windows as on macOS.LabelOrderedFlush.cppturns the traps off with_putenv_son Windows.docs/dev/ENVIRONMENT.mdlists Windows forAPS5_NO_LABEL_READ_TRAP.Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1.SuperTuxKart (PPSA69421) on an i5-10600K with an RTX 5060 Ti (621.24), run by
tools/title_run.pywith--to-intel. The scene is the tutorial race with a recorded pad timeline,--profile performance --trace-seconds 80:10 --seconds 110 --warmup-seconds 110, in the order change, base, base, change, rebuilding at each switch.main403fbe6fc1with #10442, #24445, #25280, #24869 and #26606 (2f03f53f37). #26606 NOPs the game's cache flushes; without it the firstclflushoptover a trapped target resolves the trap at once.1332992cf4).tools/trace_digest.py, seconds 80:10:Recorder.Syncper frameThe race played normally in all four runs. The traces are available on request.
Desktop tests (RTX 5060 Ti, 621.24), with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer:agc_read_trap_import_submit,agc_read_traps_over_host_pointer_imports_driver,agc_small_tiled_shadow_label,agc_driver_linear_target_completion_storesandagc_driver_label_ordered_flushpass; noVUID-lines.ctest -R "^agc_|read_trap"on the rebased headda36f0557a, 2128 tests: 2125 pass, including #26273'sagc_driver_linear_target_completion_stores_lock_order. The validation layer was inserted 1926 times, with noVUID-and nowas not foundline.agc_driver_linear_target_import_creation,agc_driver_store_over_untrackedandagc_driver_bda_devicefail the same way on the base, with and without this change.Laptop tests (Ryzen AI 7 350, Radeon 860M, where no trap is set over host pointer imports): the 95 tests matching
read_trap|label|linear_target|agc_small_tiled|agc_recorder|write_trackingpass exceptagc_driver_linear_target_import_creation, which fails the same way onmain. A full^agc_run on the commit before the last two changes (the import check outside the mutex and the debt fragments) had only that failure andagc_driver_store_over_untracked, which also fails onmain.tools/check_conventions.pyandtools/debt_fold.py --checkpass.Overlap: rebased onto
main5f04682cefafter #26273 merged; the only conflict wasStoreDrawnLinear, resolved as above.tools/pr_overlap.py --branchon the earlier head reported #18300 (inGuestArena.cpp, from #26643) and #26273.Not run: Linux, macOS. Their behaviour is unchanged:
SharesTrapBlocksandTrapShareBytesgive them the same checks as before.Summary lines (change 1, base 1, base 2, change 2)
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
New Features
Bug Fixes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T07:03:33Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes show no verified blocking defect, but this review is incomplete because several changed files were not read in full.
What I ran
Reviewed the prepared diff for head
da36f0557ab53b0a72f57b1ca71e5da0e671d27b; no commands or tests were run.Read:
description.md,commits.md,manifest.json, and the availablediff.patchsections. Read selected ranges ofGuestArena.cppandWindowsMappings.hpp. The full changed text was read for neither file. The diff was the only source used for other changed files.Results
Findings
Blocking
None verified in the inspected material.
Non-blocking
None.
Not verified
The full text of all changed files was not read. In particular,
Texture.cppandRecorder.cppwere excluded from the review folder as too large, and only selected ranges ofGuestArena.cppandWindowsMappings.hppwere read. The other changed files were inspected through the prepared diff, not their full head text. No tests were run; Windows and other platform behavior and the reported performance measurements were not independently confirmed.To get this to a good state
Nothing is required. Optional: complete review of the changed source files and independently run the relevant Windows checks before treating this as a complete review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T22:56:41Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code and supplied Windows results support enabling label read traps on Windows under the stated import and block-sharing rules.
What I ran
935ec1349ff5fc8458e3205000aa15e59dd96446usingrepo_read.py.description.md,commits.md,manifest.json, anddiff.patch. Read changed source regions inTexture.cpp,GuestMemory.cpp,DrawPipeline.cpp,ReadTrapImportSubmit.cpp,Recorder.cpp,LabelOrderedFlush.cpp, andLinearTargetCompletionStores.cpp; also read the changed CMake and documentation files.Texture.cppandRecorder.cppwere excluded from the prepared full-text bundle and read through the pinned reader. All changed files listed in the manifest were inspected at the relevant changes.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T23:06:42Z.
Review: COMMENTED
Actionable comments posted: 2
7d737ba4-d76d-4657-8d38-538367e03887Reviewing files that changed from the base of the PR and between
43815324f0and935ec1349f.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/ReadTrapImportSubmit.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_read_trap_import_submit_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/LabelOrderedFlush.cppcore/libs/prx/libSceAgcDriver/tests/execution/LinearTargetCompletionStores.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/perf-agc-linux-label-read-traps.mddocs/dev/debt/changes/perf-agc-windows-label-read-traps.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-28T23:14:48Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
c2f6009245e1e9213faaf4e2df319dd6cf79baceusingrepo_read.py's pinned file reader. No build or tests were run; test results below are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
Texture.cppandRecorder.cppwas excluded from the prepared snapshots; I read only relevant ranges through the pinned reader. Other changed files listed as included inmanifest.jsonwere not all read. Consequently, this review does not meet the stated completeness condition for approval. Linux and macOS behavior, and the author-reported Windows build, test, and performance results were not independently verified.Files read:
description.md,commits.md,manifest.json,diff.patch; relevant ranges ofDrawPipeline.cpp,GuestMemory.cpp,Texture.cpp,ReadTrapImportSubmit.cpp,Recorder.cpp,agc_read_trap_import_submit_tests.cmake,LabelOrderedFlush.cpp,LinearTargetCompletionStores.cpp, and the Windows label read traps debt fragment. Other included changed files were not read;Texture.cppandRecorder.cppfull snapshots were excluded as too large.To get this to a good state
Nothing is required.