perf(agc): share resources across indirect records with unchanged shader words #27686
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27686"
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 kteal on 2026-11-27T00:39:11Z.
What
A CPU-resolved indirect draw packet can request the values already in the vertex and instance offset registers for every drawable record. Today the driver still prepares and draws each record separately. With
APS5_UNIFORM_INDIRECT_RECORDS=1, the driver reads the packet once, proves the shader words stay unchanged, then submits the captured draws in order with one resource setup.Grouping covers ordinary vertex and fragment stages. Changed registers, a per-draw index, shader writes, buffer-backed pixel function LDS, primitive restart and split/replay passes use the existing individual-record path. After resolving the images, the renderer checks whether a draw samples a bound color target. When it does, the original CPU snapshot is passed back to the individual-record path before a grouped draw is recorded. This preserves pass boundaries and per-record resource refreshes. Grouping also preserves the effective vertex/instance range checks and index-slice alias checks. When a full vertex descriptor overlaps the color target, each record validates its own fetch range. The CPU argument reader stays independent of #21059.
Tested
On Windows 11 build 26200, seven existing indirect-draw, vertex-offset and draw-cache tests passed on both main and this commit on both physical GPUs. Two new Vulkan tests also passed with grouping off and on. They cover indexed and non-indexed packets, zero and nonzero starting shader values, identical writes that change the starting value, and records that disagree. Both draws are emitted in all cases and GPU color readback matches the expectation. Eligible pairs reduce per-record shader-stage rebuilds from two to zero. Ineligible pairs still rebuild twice. Both devices loaded Khronos validation 1.4.363, required Vulkan and ran with the shader cache disabled. Neither build logged a validation VUID.
The two GPU tests also exercise sampling the bound color target and sampling independent texture memory, indexed draws whose unused index-buffer tail overlaps the target, and a high-index pixel LDS read and write on devices that back that scratch space with a buffer. The tests check emitted draw counts, per-record rebuilds and color readback.
The vertex-offset test also checks a vertex descriptor ending exactly at the color target, one extending into it by one element and the direct draws from its valid prefix. The disjoint control groups two records. The overlapping tail falls back before issuing a grouped Vulkan draw.
The same test covers a readable vertex prefix followed by an inaccessible page, and a buffer whose unused last index exceeds a reduced device limit. Both grouped attempts return before recording a draw, the individual draws of the valid prefix succeed, and selecting the excessive index still raises the original validation error.
Planet Zoo, Goodwin House loading. PPSA18026 01.009.002, 1920×1080, RTX 4070 Laptop. Main and the review revision were run separately in the same session with the same executable, support libraries, save and byte-identical warm shader-cache seed. Only the graphics driver changed. Both native 140-second windows were armed 110 seconds after scenario loading was recognized and closed on the next present past the deadline. The normal console stayed attached with extra profiling off.
6d8fc6e47de6c93c9e0f6792The average interval between presents fell by 4.48 s (12.3%) in this pair. The host draw-and-resource-release scope went from 28.45 to 24.03 s per present. Both traces recorded the full window with zero dropped events. These short windows measure late loading on one machine. In-park frame rate and total scenario load time remain unmeasured for this revision. Scenario selection
Main evidence · Native trace · Digest · Loading screen
Feature evidence · Native trace · Digest · Loading screen
Original native summary lines
Earlier benchmark of the pre-review revision.
The overlap check on the opening revision scanned 2,450 open PRs. I compared 92 inconclusive peers directly against main and this branch. The scan found no confirmed line or export overlap. For #5925, #10193, #13928, #13929, the driver file already conflicts with main. Applying this patch to the projected peer changes introduced zero conflicts, and merging in the reverse order preserved the existing conflict count. The other projected shared-file changes were byte-identical in both merge orders. #1896 queues individual records, and #21059 changes how the CPU reads indirect arguments.
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
Summary
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T00:49:22Z.
Review: COMMENTED
Actionable comments posted: 2
f1a02b7d-9d9b-46af-a49e-5428ceb5784aReviewing files that changed from the base of the PR and between
54160814c9and82a3341cdc.core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_cache_reuse_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/DrawCacheReuse.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-27T01:04:47Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected implementation and tests show no verified blocking defect, but I did not run the checks needed to justify approval.
What I ran
Reviewed head
82a3341cdc21afbe7c9575efbe68b0c8f9835469from the prepared patch. I inspected the changed implementation, test, and documentation hunks and targeted draw-record handling context. No build or test commands were run.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The Vulkan tests and native performance captures described by the author were not run or independently checked. I did not read every line listed as changed in
manifest.json, so this review does not support approval. The six changed files are included in the review folder;files.jsonwas not available under that path.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T01:36:43Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
2282683f628b549a0540328cb68c9621eead5d1fagainstmain. No commands or tests were run. The PR description reports Windows GPU tests and paired performance captures; these are author-reported results.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The review bundle contained full text for
Pm4.hpp,VulkanDevice.hpp, driverDraw.cpp,Draw.hpp,ShaderResources.hpp, graphicsDraw.cpp, the CMake test configuration,DrawCacheReuse.cpp, andENVIRONMENT.md; these were read in targeted ranges as relevant.VulkanDevice.cppandShaderResources.cppwere excluded as too large and were read through the pinned repository reader at the changed ranges. No complete file was read. No tests, builds, hardware behavior, or performance traces were independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T01:37:06Z.
Review: COMMENTED
Actionable comments posted: 1
8f89ff99-e95e-40e8-a26d-d88526afee69Reviewing files that changed from the base of the PR and between
82a3341cdcand2282683f62.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/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/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/execution/DrawCacheReuse.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T01:52:06Z.
Review: COMMENTED
fe41e223-5d27-4e9e-b3ed-759ca8ac934bReviewing files that changed from the base of the PR and between
2282683f62and53d4a0ec7b.core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T02:00:25Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
53d4a0ec7b3fc76750aef3a96128c41627d55a6aagainst the prepared diff and targeted source context. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run. The author reports existing and new GPU tests passed, but I did not independently verify those results. The complete contents of
VulkanDevice.cppandShaderResources.cppwere excluded from the review bundle; I read only the changed ranges through the pinned repository reader. All changed lines in the other files listed asincludedin the manifest were read. The rest of those files was not read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T02:13:12Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the grouping path is guarded by eligibility checks and falls back to per-record processing when validation or feedback conditions require it.
What I ran
Reviewed head
c93c9e0f6792ea62c0039b851235446b6af70d4aagainst the prepared diff and pinned repository sources. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and runtime behavior were not independently verified. Read all changed files listed in the manifest, including
VulkanDevice.cppandShaderResources.cppthrough the reader; no changed files were excluded.To get this to a good state
Nothing is required.