perf(agc): reuse PreparedDraw across layered mesh output windows #27268
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27268"
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 birdmarty on 2026-11-25T17:31:39Z.
What
When a layered mesh draw targets more layers than the host device's
maxMeshOutputLayers(for example, UE4's48x48x483D Translucent Lighting Volume on RDNA2 wheremaxMeshOutputLayers = 8, splitting each draw into 6 windows),Graphics::Drawpreviously looped over each window and invokedDraw(...)recursively. Every window therefore repeated fullplanDraw,prepareDrawInputs,resolveDrawResources,prepareColors, andCachedPipelinework even though the inputs, shader resources, and resident targetStorageTextureare identical across all windows of the draw.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:prepareDraw(leavingprepared.shape = 0, matching the previous recursiveDrawcall).PreparedDrawacross the remaining windows, updating each color target's slice/layer view (AttachmentView),maskedstate (when present), per-windowCachedPipeline(for(meshLayerBase, meshLayerCount)specialization constants), and framebuffer.prepared.completionandprepared.outcome.waitedonto the final window only so completion work runs once after all windows are recorded, and fall back to recursiveDraw(...)for remaining windows when not shareable.core/libs/prx/libSceAgcDriver/tests/execution/LayeredVolumeDraw.cpp:windowLimit = 8u) under--mesh-executioncovering8, 8, 8, 8, 1windows over all 34 slices.Tested
Windows 11 Pro (build 26300), i9-9900K, MinGW-w64 GCC 15.3.0, Release build, AMD Radeon RX 6800 (
vendor=0x1002,device=0x73bf,maxMeshOutputLayers = 8), AMD proprietary driver26.10.1(Windows driver32.0.21045.16010, Vulkan1.4.315).Unit tests on
3867c1e89c(baseorigin/mainc032ba7c52) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK1.4.363.0),VK_LOADER_DEBUG=layer:agc_driver_layered_volume_draw,agc_driver_layered_volume_mesh,agc_driver_layered_volume_vertex,agc_driver_layered_volume_vertex_no_gpl,agc_driver_layered_volume_submit,agc_driver_layered_array_color_draw,agc_driver_target_memo: 7 / 7 passed,Insert instance layer "VK_LAYER_KHRONOS_validation"confirmed across all 7 tests, 0VUID-errors.c139321586,agc_driver_layered_volume_meshfailed at slice 9 (actual 255,expected 64); passes on3867c1e89c.tools/check_conventions.py --base origin/main: passed.tools/debt_fold.py --check: passed.Lies of P (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza):61250ca018with #27254 and thecompletion/waitedfinal-window fix):9.37 → 9.94 FPS(p50 103.9 → 99.9 ms,p90 117.1 → 108.9 ms,gpu 68.9 → 66.3 ms/f,Graphics.Draw 72.8 → 65.7 ms/f), clean exit with 0 write-back errors.Performance captures (
APS5_TRACE_SECONDS=120:30, clean warm shader cache, no extraAPS5_TRACE_*orAPS5_PROFILE_*switches)Same machine, title (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza), and flags (APS5_DRAW_PIPELINE=1 APS5_NO_DRAW_STAGING=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1 APS5_FAST_F32=1):main,c032ba7c52):9.00 FPS,p50 110.5 ms,p90 117.7 ms,max 151.1 ms,gpu 70.31 ms/f,Graphics.Draw 72.33 ms/f(aps5-trace-c032ba7c5273-23148.json.gz).3867c1e89c):9.89 FPS(+0.89,+9.9%),p50 99.8 ms(-10.7 ms),p90 107.4 ms(-10.3 ms),max 149.8 ms,gpu 65.30 ms/f(-5.01 ms/f),Graphics.Draw 64.40 ms/f(-7.93 ms/f) (aps5-trace-3867c1e89cef-29940.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(3867c1e89c):Series context & interleaved ablation
This PR is part of a general AGC/libc performance series measured on Lies of P (
PPSA10621,v01.012.000,3200x1800, UE4) covering #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, and #27273 (tested together with #20130, #18757, #26778, #27117, and now-merged #26581 and #26681). Combined on base61250ca018(plus remaining unsplit stack changes), steady-state performance rose from7.25 FPS(p50 135.6 ms,gpu 92.7 ms/f, default settings) to12.15 FPSaverage (12.00/12.30 FPS, peak12.33 FPS,p50 81.5 ms,gpu 57.12 ms/f,+67.6%to+70.1%).Because five of the smaller PRs (#27253, #27254, #27270, #27271, and #27273) looked like they slightly lost average FPS (
-0.03to-0.31 FPS) in single isolated runs onc032ba7c52, we ran an interleaved 4-run ablation (A1 -> B1 -> A2 -> B2,APS5_TRACE_SECONDS=120:30, identical warm shader cache and flags) on the full stack to test whether removing those 5 PRs helped or hurt:61250ca018(WITH all 11 PRs): #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, #27273 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes (per-64 KiB proof/pending tracking and ShapeRecipe).61250ca018MINUS the 5 PRs (#27253, #27254, #27270, #27271, #27273): keeps #27249, #27250, #27251, #27252, #27268, #27269 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes.DrawWithRecipe(ms/f)DrawFinish(ms/f)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)+0.39 FPS(+3.3%)-2.1 ms-4.6 ms-10.5 ms-3.21 ms/f-1.02 ms/f-0.88 ms/fRemoving those 5 PRs hurt every run (
A1 > B1andA2 > B2across all metrics), showing that their single-run isolated dips onc032ba7c52were within±0.25 FPSscene variance while larger bottlenecks (#27268, #27249, #27252, #20130, #18757) still dominated. Individual PR captures above remain isolated againstc032ba7c52.Not tested: Linux, NVIDIA/Intel GPUs.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:05:34Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: update the reused draw’s per-window mesh-layer push constants before recording each tail window.
What I ran
Reviewed head
c139321586ec121f8c7ca8c3c35ca9187821cdd5using the prepared review diff and the pinned repository reader. No build, tests, or hardware checks were run by this review.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:5156— Tail windows update attachment views and, when masked, state, but reuseprepared.inputsunchanged. For shaders using the mesh-window path,recordDrawcallspushDrawConstantswithinputs.meshLayerStride, while the window’smeshLayerBaseandmeshLayerCountare pushed through state.prepareDrawInputsis responsible for deriving draw inputs from the state; because the prepared inputs are reused, each tail window receives the first window’s mesh-layer input constants. Refresh the window-dependent mesh inputs for each window beforerecordPreparedDraw(or otherwise update the pushed constants). This can make layered mesh output windows render incorrect layers.Non-blocking
None.
Not verified
No tests or builds were run. The performance and validation results in the PR description are author-reported and were not independently verified. Read:
description.md,commits.md,manifest.json,diff.patch, andcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpplines 5060–5198, 3435–3495, 4076–4155, 4150–4360, 4480–4555, 4560–4625, 4630–4735, 2517–2618, 3030–3190, 3190–3375;core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpplines 1279–1390.files.jsonwas not available through the reader, so excluded files were not verified.To get this to a good state
Update the per-window mesh inputs before recording each reused window, then rerun the layered mesh draw tests and validation checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:56:43Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the new windowed draw path appears consistent with the existing preparation and recording lifetimes based on the code inspected.
What I ran
No commands or tests were run in this review. Reviewed head
3867c1e89cefe3e66fa99dc8188c268ee54d3be7; no merged-preview check was performed. The author reports Windows 11 / RX 6800 execution and Vulkan validation results in the PR description; these were not independently run here.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run here. Physical-console behavior, Linux, and NVIDIA/Intel GPU behavior were not verified. Read
Draw.cppandLayeredVolumeDraw.cpp; both changed files listed in the manifest were included and read. No files were excluded by the manifest.To get this to a good state
Nothing is required.