perf(agc): reuse a cached resource build that samples a texture remade per use #10894
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10894"
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 WallisSkill on 2026-10-25T08:07:00Z.
What
A draw or dispatch that samples a texture refreshed on every use (
Texture::RefreshedPerUse: a depth plane copy, a stencil copy, a native multisampled depth view) was never kept in the resource cache, because the cached object's revalidation could not prove those textures current. Each such draw built its resources again.ShaderResources::noteReusablenow keeps such a build when every sampled texture has a validation record, so that its fast proof can succeed; a build without records (a BDA build) and a space-reusable build stay out of the cache as onmain. Its revalidation:revalidateFull), which refresh them and must return the textures the build holds, in the order the build appended them; any other result fails the revalidation and the draw takes the full build as before;fastRevalidate);The partial walk checks image tables entry by entry rather than taking a table reused from the cache, so a reused table cannot skip the refresh of a per-use entry.
With
APS5_VERIFY_PROOFS=1the full walk runs after the partial walk and the fast proof, and the process aborts if it returns another object; the message names the check, the binding and whether its texture is refreshed per use.Related: #10837 keeps the depth plane copies themselves resident (
Texture.cpp,DepthSurface.cpp); this change is about the resource build that samples them. The two touch no common file and apply in either order.APS5_NO_PER_USE_TEXTURE_TEMPLATESkeeps these builds out of the cache as before;APS5_NO_PER_USE_PARTIAL_WALKrevalidates them with the full walk.agc_driver_depth_plane_samplinggains a case where a dispatch over a D32 plane copy enters the resource cache and reads the new depth through the cached build after the surface is drawn again, after a guest slice changes, and when dispatched again unchanged.Tested
Windows 11 Pro 10.0.26200, AMD Ryzen 7 9800X3D, NVIDIA GeForce RTX 5070 (driver 616.92), MinGW Release build.
Update after merging
main090f57166a(headafbb4914d4), with the record check: the 41 AGC driver tests (the earlier 38 plusagc_driver_address_draw_space_reuse,agc_driver_image_table_reuseandagc_driver_lookup_log_fits_build) pass in plain and pipelined mode (82 of 82), and again withAPS5_VERIFY_PROOFS=1; 25 depth and multisample cases pass in each of four modes (plain,APS5_VERIFY_PROOFS=1,APS5_NO_PER_USE_TEXTURE_TEMPLATES=1,APS5_NO_PER_USE_PARTIAL_WALK=1: 100 of 100).agc_driver_depth_plane_samplinggains an image table of 1,500 entries, past the 1,024-record lookup log bound, whose first entry is a D16 plane copy: the build enters the cache and its hits take the fast proof, not the full walk, before and after the plane is drawn again. With the validation layer the tests report only the VUIDsmainreports (VkDeviceCreateInfo-pNext-pNextat device creation, andvkCmdCopyImage-srcImage-01548/01551three times inagc_driver_depth_plane_sampling, both present onmain). No new capture on this head; @mrfelek has been asked to repeat the pair.Update after merging
main1ffd2b81f5(head853b98d6c9): the 38 AGC driver tests pass in plain and pipelined mode (76 of 76), and again withAPS5_VERIFY_PROOFS=1; 25 depth and multisample cases pass in each of four modes (100 of 100); validation againstmain1ffd2b81f5matches test by test. I took no new capture on this head. The latest matched report is the D2R pair from mrfelek,main20d3cd84bcagainst thatmainwith12495d11d2merged locally: about +8.8 % presents. It measures a local merge of the previous head on an oldermain.Update after the rebase onto
main2227f1366(head0c6bca70d): re-measured with the same scene and settings, the two arms differing only inlibSceAgcDriver.prx, one warm-up run ofmain, then three interleaved rounds. Frame p50 is 55.3 / 54.8 / 54.7 ms onmainand 53.3 / 53.3 / 53.5 ms on this head (about 1.5 ms, 2.7 %); presents 181 / 178 / 183 against 187 / 187 / 187.Graphics.Drawon the committer drops from 45.7 / 46.0 / 45.2 to 41.2 / 41.3 / 41.2 ms per frame. The gain is smaller than oncf528e78cbelow, becausemainhas since removed much of the committer's cost on its own.Performance: Graveyard Keeper 2 (PPSA35943), the first dungeon room after New game, 1920x1080 window, captured with
APS5_TRACE_SECONDS=120:10andAPS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=256 APS5_PIPELINE_DISPATCH=1 APS5_MIMALLOC=1, no otherAPS5_TRACE_*orAPS5_PROFILE_*switch and no log redirection. Base ismaincf528e78cand the change is this head aa0d4f5ad; both use the same relinked executable and libraries, onlylibSceAgcDriver.prxdiffers. After one warm-up run ofmain, the captures ran interleaved (main, change, main, change, with other builds between them) on the same machine; the input came fromAPS5_PAD_INPUT_FILE(the libScePad command file), so the window was not focused. The trace buffer dropped events at its default size in m2-base-1, m2-base-2 (dropped: yes) and in no other capture; the frame times come from the presents.Summary lines (main, then this change):
Traces and summary lines of all four captures: https://github.com/WallisSkill/AnyPS5/releases/tag/gk2-perf-traces-2026-10-24 (files
gk2-m2-base-*andgk2-m2-peruse-*).Tests: 38 AGC driver tests (draw pipeline, finisher, label order, vertex fetch, vertex table read order, draw cache, depth and DCC cases) in plain and
APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1modes withANYPS5_NO_SHADER_CACHE=1: 76 of 76 pass.agc_driver_depth_plane_sampling,agc_driver_depth_plane_guest_layers,agc_driver_native_multisample_depthandagc_driver_image_table_reusealso pass in both modes withAPS5_VERIFY_PROOFS=1(8 of 8).Validation: the same 38 tests ran on
maincf528e78cand on this head withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1andVK_LOADER_DEBUG=layer. The layer is theVkLayer_khronos_validation.dllthat Steam ships inbin/cef/cef.win64, registered throughVK_ADD_LAYER_PATHwith its own manifest; every test that creates a device logsInserted device layer "VK_LAYER_KHRONOS_validation"(31 of 38; the other 7 make no Vulkan device), and no log containswas not found but was requested by env var VK_INSTANCE_LAYERS. All 38 pass on both. The only validation message on either side isVUID-VkDeviceCreateInfo-pNext-pNext, 132 times onmainand 132 times on this head with the same count in each test (this layer build predates some device-creation structures the driver chains); no VUID is new.Digests of a paired capture:
trace_digest.py of m2-base-1
seconds 120:10 from present 2617: 169 presents, frame p50 59.0 / p90 62.6 / p99 68.6 / max 69.0 ms, GPU busy 8.5 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.92, Windows 10.0.26200, 1920x1080, commit
cf528e78c6, dropped: yesSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 31.1, Driver.Packet 26.9, Graphics.Draw.draw_and_resource_release 25.2, Driver.Packet.dispatch 12.1, Driver.Dispatch 12.1, Driver.Packet.draw 11.8, Driver.Draw 11.3, batch 8.5, Recorder.Sync 6.7, Driver.DrawFinish 6.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py of m2-peruse-1
seconds 120:10 from present 2772: 192 presents, frame p50 51.9 / p90 55.1 / p99 59.8 / max 61.8 ms, GPU busy 8.6 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.92, Windows 10.0.26200, 1920x1080, commit aa0d4f5ad82a, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 20.1, Graphics.Draw 19.8, Graphics.Draw.draw_and_resource_release 13.1, Driver.Packet.draw 8.6, batch 8.6, Driver.Packet.dispatch 8.6, Driver.Dispatch 8.6, Driver.Draw 8.3, Recorder.Sync 6.2, Driver.DrawFinish 5.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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T08:18:05Z.
Review: APPROVED
The cache path retains the existing fast proof for ordinary bindings and refreshes the per-use textures in build order before accepting reuse; failed identity/order checks fall back to a full build. The verification mode compares the partial proof against the full walk, and the added depth-plane regression exercises surface redraws and guest-memory updates. The author reports GPU and validation coverage; hosted product jobs are skipped by repository policy. Static review and policy checks found no blocking issue.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:59:44Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The verifier fix is present at head
12495d11d2cdbe7324836a86ba7ac5e1d95d27ed, but thisperfPR still has no matched performance report for that head against currentmain.What I ran
12495d11d2cdbe7324836a86ba7ac5e1d95d27edagainst current basemaine7d8e353362935a1f00e893d901b1debc671f5ce; the merge preview was clean (096a1ffcf81e66f0d000f059eb8aea1a223432e1).Results
096a1ffcf81e66f0d000f059eb8aea1a223432e1git diff --checkmaincf528e78c6with earlier headaa0d4f5ad8; they do not measure currentmainor head12495d11d2Command output
Findings
Blocking
perfreport is stale for the reviewed change. The new fix changes the per-use revalidation path, while the attached comparison predates it. Please add a same-title, same-scene, same-machinemain/head pair using current basee7d8e353362935a1f00e893d901b1debc671f5ceand head12495d11d2cdbe7324836a86ba7ac5e1d95d27ed, with bothaps5-summary.jsonllines, traces, andtrace_digest.pyoutput.Sources
perfPRsNot verified
12495d11d2used basebb04a4f1ea; it does not validate performance against currentmainand does not replace the missing paired report.To get this to a good state
Add the matched capture artifacts and digest for current
mainand this exact head. I will recheck the report against the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-10T19:21:34Z.
Review: DISMISSED
Reviewed — changes requested
The paired performance evidence in the description measures older commits, and the requested reruns for this updated head are still missing.
What I ran
Reviewed head
88aee970d98386184d975ad9e690c29d0f7c5d59. I checked it against the currentmaintip89f8f1cbaa16710116312b6eaadb559b03c64eb2; the merge preview was clean (5430d04c619e5c6c948eb331b0123c25129eda82). The PR's recorded base is older (561fb7672f29e3cf1738b01f8b392a36b1a3b599).Environment: Linux 6.1, Python 3.11.2, GCC 12.2.0.
I read all four changed files, the description, the review history, the latest discussion, and the current hosted-check snapshot. No build or C++ test was run in this no-build pass.
Results
mainmaincf528e78c6c8andaa0d4f5ad82a, not currentmainand this headFull no-build precheck table and raw outputs
Commands and unedited output:
The heuristic warning is a false positive:
agc_driver_depth_plane_sampling_testsis registered in the test CMake files, and the modified test source belongs to that existing target.Hosted snapshot for this head:
windows,conventions,labels,eligibility,report, andlibrary-portabilitysucceeded.linux,relinker,relinker-asan,register-context,write-watch,pipe-write, andedge-watchwere skipped. Skipped jobs provide no test result.Negative control
The new table-over-bound and reused-array assertions were read, but no binary was built, so I could not alter the tested behavior and confirm that either assertion fails.
Findings
Blocking
perfclaim has no matched report for this head and current base. The attachedaps5-summary.jsonllines comparemaincf528e78c6c8with PR headaa0d4f5ad82a, while this review coversmain89f8f1cbaa16and head88aee970d983. The later code changes address a reported slowdown and alter when per-use builds are reused, so those old captures do not establish the performance of this version. Please attach matched captures, both summary lines, traces, andtrace_digest.pyoutput for the requested D2R and Age of Mythology scenes on currentmainand this head.Non-blocking
agc_driver_depth_plane_sampling_teststarget.Sources
Not verified
To get this to a good state
Add matched current-main/current-head captures for both requested scenes, including the two summary lines, traces, and digests. I will recheck the artifacts and rerun the same no-build checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T18:14:16Z.
Review: COMMENTED
Reviewed — comments
The cache revalidation changes and added depth plane tests were reviewed at head
6d1da44625dd9d6c0f5d048d75a0cea43856344e; no tests were run, and the latest performance capture described is from an earlier head.What I ran
Read the prepared description, commit list, manifest, diff, and changed file text where included. Used
repo_read.pyto inspect targeted source ranges from the changed implementation file. No commands or tests were run.Results
Negative control
Not run; no test commands were run.
Findings
Blocking
None.
Non-blocking
Sources
Reviewed
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp,core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp(targeted ranges),core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_depth_plane_sampling_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/DepthPlaneSampling.cpp, anddocs/dev/ENVIRONMENT.md.Not verified
No tests, build, or performance capture were run. The full text of
ShaderResources.cppwas excluded from the prepared folder; targeted ranges were read throughrepo_read.py. No other changed files were excluded by the manifest.To get this to a good state
Nothing is required. An optional matched performance capture on this head would confirm the stated performance result.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T03:38:25Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code demonstrates a blocking defect; the focused changes and test additions support the stated cache-revalidation behavior.
What I ran
Reviewed head
0ab78646e17358d70eee9f586f431885be247471using the prepared diff andrepo_read.pyfor targeted source context. No build or tests were run. The description reports author-run Windows tests and performance measurements; these were not independently verified.Results
Findings
Blocking
None identified in the code reviewed.
Non-blocking
None.
Not verified
Full text for
ShaderResources.cppwas excluded from the review folder because it was too large; targeted ranges around revalidation were read throughrepo_read.py. The prepared full file contents forShaderResources.hpp,DepthPlaneSampling.cpp,agc_driver_depth_plane_sampling_tests.cmake, andENVIRONMENT.mdwere not read. Their changed lines were inspected indiff.patch; behavior outside those hunks was not verified. No tests, build, validation-layer run, hardware behavior, or performance capture was run by this review.description.md,commits.md,manifest.json, anddiff.patchwere read;files.jsonwas unavailable through the reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T14:40:14Z.
Review: COMMENTED
Actionable comments posted: 1
30211327-8e14-41a1-86ec-cf39737ed82bReviewing files that changed from the base of the PR and between
4a5119349fand9af341e0bd.core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_depth_plane_sampling_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/DepthPlaneSampling.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-26T14:57:54Z.
Review: COMMENTED
Reviewed — comments
The reviewed source suggests the per-use refresh and proof path is implemented as described, but I could not run checks or inspect every file required for approval.
What I ran
Read the prepared change bundle and targeted source ranges at head
9af341e0bd8a6cd583cc2feb8dde6f7035b2d616; no commands or tests were run.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
Could not approve because the changed
ShaderResources.cppfull text is marked too large and was not read in full, and no checks were run. Targeted ranges were read from it, including caching, validation-record capture, fast proof, and partial/full revalidation. Read bundle files:description.md,commits.md,manifest.json,diff.patch; changed repository files read:ShaderResources.hpp, targeted ranges ofShaderResources.cpp,DepthPlaneSampling.cpp, andagc_driver_depth_plane_sampling_tests.cmakewas present in the bundle diff.docs/dev/ENVIRONMENT.mdwas present in the bundle diff but its full repository text was not read. The description’s reported test runs and performance captures were not independently verified.To get this to a good state
Nothing is required. Optional: run the reported regression tests on this exact head and complete review of the remaining changed source and documentation before approval.