perf(agc): skip CPU index range scan for in-place draws without vertex attributes #27271
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27271"
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:57Z.
What
In
prepareDrawInputs, indexed draws bound in place from a host import always calledInPlaceIndexRange(...)to scan the guest index buffer on the CPU for[lowest, highest]vertex indices so vertex attribute buffer bounds can be sized and validated.When the draw's front shader declares no
vertexAttributes(for example, programmable vertex-pulling shaders that fetch vertex data through shader buffers rather than Vulkan vertex input bindings), primitive restart skipping is not active (!skipRestart), the draw is not a mesh shader,draw.indexCount != 0, and the maximum representable index fits withinmaxDrawIndexedIndexValueanddraw.firstVertexwithout overflow, the CPU index scan is unnecessary.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: inprepareDrawInputs, bypassInPlaceIndexRange(...)and use[0, largestIndex]whenshaders.front().program->vertexAttributes.empty() && !skipRestart && !state.stages.mesh && draw.indexCount != 0 && largestIndex <= context.limits.maxDrawIndexedIndexValue && draw.firstVertex <= UINT32_MAX - largestIndex.core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp: add an all-restart (0xffff) vertex-pulling strip regression test assertingTakeVkDrawCounts().indexed == 0and untouched output.Tested
Windows 11 Pro (build 26300), i9-9900K, MinGW-w64 GCC 15.3.0, Release build, AMD Radeon RX 6800 (
vendor=0x1002,device=0x73bf), AMD proprietary driver26.10.1(Windows driver32.0.21045.16010, Vulkan1.4.315).Unit tests on
a54624e100(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_draw_offset_indices,agc_driver_draw_offset_indices_poisoned,agc_driver_draw_offset_indices_poisoned_in_place,agc_driver_list_restart,agc_driver_scalar_swappc_fetch,agc_driver_target_memo: 6 / 6 passed,Insert instance layer "VK_LAYER_KHRONOS_validation"confirmed across all 6 tests, 0VUID-errors.83800e1313,3 / 3agc_driver_draw_offset_indices*tests failed on the all-restart regression case; all pass ona54624e100.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):61250ca018, where UE4's vertex-pulling draws bind indices in place withvertexAttributes.empty()):10.83 → 10.97 FPS(p50 91.0 → 90.7 ms,p90 99.2 → 96.9 ms,gpu 62.9 → 59.8 ms/f), clean exit with 0 mismatches across 3-verifier live checks.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).a54624e100):8.92 FPS(-0.08),p50 111.4 ms(+0.9 ms),p90 117.5 ms(-0.2 ms),max 148.7 ms,gpu 69.04 ms/f(-1.27 ms/f),Graphics.Draw 73.58 ms/f(aps5-trace-a54624e1006c-33600.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(a54624e100):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:02:11Z.
Review: APPROVED
Reviewed — looks good
The change at head
83800e1313b9bfdbdcccedab09827dcd87d1685esafely bounds the optimization to in-place indexed draws without vertex attributes and preserves the existing scan for other cases; no checks were run by this reviewer.What I ran
Read the prepared diff and the changed function plus relevant index validation and draw submission code. No build or tests were run.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
Draw.cppwas not read; only lines 1650–1725, 2000–2210, and 2535–2570 were inspected. No build, unit tests, hardware, or console behavior was verified.description.mdreports unit tests and hardware measurements; these were not independently verified.files.jsonwas not available through the review reader; the manifest lists one changed file and says its full text is included. No other changed files were listed in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T21:26:58Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected code shows a blocking defect; the shortcut is guarded by the device index limit and vertex range overflow checks, and the regression test covers the all-restart case.
What I ran
Reviewed head
a54624e1006c5fe6a2773d3f7f710955d81beecd. Read the prepared description, commits, manifest, diff, and both changed files at the pinned head; usedrepo_read.pysearch for related index-limit and draw-input callers. No tests or builds were run during this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The test and performance results in the PR description were author-reported and not independently run. No repository files were excluded in the manifest;
files.jsonwas not available through the review reader.To get this to a good state
Nothing is required.