perf(graphics): retain vertex input layouts #1316
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1316"
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 TibixDev on 2026-10-07T23:26:44Z.
What
Retain validated vertex layouts for stable shader variants, while bypassing inputs that do not benefit from reuse. Rebased onto main
d146ec1b6, including the current vertex-fetch, null-descriptor and record-count behavior.formatComponentsand null-descriptor state. Live addresses are validated on each cache hit. Record counts, zero-fill decisions and copied guest bytes remain per-draw work. Draw recipes keep their existing value-owned layouts.Depends on: none.
Tested
Fedora 44, GCC 16.2.1, Release:
agc_vertex_input,agc_driver,agc_driver_pm4andagc_driver_graphicspass. The cache test also passes with AddressSanitizer and leak detection (ANYPS5_ENABLE_ASAN=ON,ASAN_OPTIONS=detect_leaks=1:halt_on_error=1). Contribution checks andgit diff --checkpass.Coverage includes 10,000 generated layouts compared with the original builder, live address rejection, null descriptors, format-component changes, record-count and zero-stride/OOB decisions, retained-layout lifetime after eviction, conservative bypass collisions, invalid bypassed inputs, concurrent reuse and concurrent eviction.
Isolated CPU measurements
Ryzen 5 5600, pinned to CPU 3, identical Release executable and format-property callback. The baseline calls
BuildVertexInputLayout, whose implementation is unchanged from maind146ec1b6; the cache mode uses the draw's revised layout-selection path. Three ABBA cycles, six processes per mode, one warm-up plus nine measured batches of 32,768 requests each. The table reports medians of process CPU nanoseconds per request; wall time is also printed by the harness. CPU time avoids charging unrelated scheduling delays to either implementation.All output checksums match. Measured reuse cases have 100% cache hits; the cyclic 2,048-variant cases settle at 50%; already-evicted and changing-shape cases take the bypass path with 0%. Empty layouts skip layout construction entirely. Fully bypassed cases are close to baseline: their measured median changes range from approximately -4% to +2%, with overlapping run ranges. The earlier empty-layout and eviction-every-reuse costs are removed.
These are synthetic layout-component measurements, not a saved title trace or frame-time claim. First-time admission still costs a lookup and cache insertion, and this does not establish a title-specific hit rate or a gain under contended multi-threaded draws. Windows runtime and full Linux/Windows CI still need validation.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T05:25:38Z.
Rebased again on
c8a2f063to preserve the new BDA test registration. The measured vertex code is unchanged. I compared the production headers at5850a6cdwith that upstream plus this PR alone, using the same CPU harness and a fixed format-property query. No other PR was included.Fedora 44, GCC 16
-O3 -DNDEBUG, Ryzen 5 5600 pinned to CPU 3. Six runs per variant in ABBA order; one warmup and nine measured batches per run. Values are medians of the six run medians.The saved 20,000-request layout trace fell from 165.5 to 19.8 ns/call, or 88.0% less time. Each timed batch repeated it eight times. Run medians ranged from 163.3–181.7 ns upstream and 19.7–20.0 ns with this PR.
Synthetic cases, ns/call (upstream → PR):
All output checksums match. The cache capacity is 1,024, so the 2,048-variant cases measure eviction on each reuse. Empty layouts and over-capacity workloads regress. These CPU measurements do not establish a frame-time gain.
The vertex-input, driver, graphics and PM4 tests pass. Windows was not tested.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T06:36:58Z.
Fixed the clean-build failure: the vertex-input test now includes the repository Vulkan headers explicitly. Rebased on
7a178e22. The production cache code is unchanged.Linux Release test and convention checks pass. MinGW compiles the test source. The local Windows link is blocked by unresolved SjLj symbols in libc, so Windows runtime validation is left to CI.
I checked #1426: it handles short vertex buffers and does not replace this cache.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:58:37Z.
Review: CHANGES_REQUESTED
Thanks. The code reads fine and
agc_vertex_inputpasses here (Linux, full ctest 420/420), but two things before this can land:mainincore/libs/prx/libSceAgcDriver/CMakeLists.txt(test list). Please rebase and rerunagc_vertex_inputandagc_driver_graphicsafterwards.Not verified on our side: Windows runtime and real-title performance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:53:54Z.
Review: CHANGES_REQUESTED
Thanks for the work. Following up on the earlier request, which has had no reply or push. Two things still block this:
shared_ptron every draw. Please post the cache hit rate and CPU/frame time on a title (title ID, host), or make the cache pay only where it wins: leave empty layouts on the old path and don't take the lock for a variant that keeps missing.maininGraphics/include/VertexInput.hpp,Graphics/include/Context.hppandlibSceAgcDriver/CMakeLists.txt(the vertex-fetch changes from #1769 and the null-V# / record-count fixes touched the same functions). When you rebase, check that the cached layout keeps honouring those: the zero-fill and null-V# cases must still be validated per draw, not frozen into the cached shape. Rerunagc_vertex_inputandagc_driver_graphicsafterwards.Not verified on our side: Windows runtime and real-title performance.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:20:35Z.
@adriadam10 addressed the rebase and cache-regression requests in
d7718f8d4, based on maind146ec1b6.Empty inputs now skip layout construction and the cache entirely. Evicted variants, and variants that change shape under the same ID, take an inline bypass before the mutex and use the original value-owned builder. The bounded bypass bitmap can conservatively suppress caching after a hash collision; that tradeoff and first-admission costs are documented in the body.
The rebase preserves per-draw address, record-count and zero-fill behavior, and adds
formatComponentsand null-descriptor state to shape matching. Regression tests cover those cases, retained lifetime, bypassed invalid inputs and concurrent eviction.Fresh isolated CPU measurements (same executable, main's unchanged builder versus revised selection; six processes/mode, ABBA, CPU 3): eight-attribute reuse 362.0 → 51.8 ns/call, and 2,048 cyclic variants 360.7 → 213.3 ns/call. Empty selection skips construction; fully bypassed cases are near baseline (roughly -4% to +2%, overlapping ranges). The reproducible harness, full table and synthetic hit rates are in the body. These are component timings; title hit rates/frame-time gains remain unmeasured.
agc_vertex_input,agc_driver,agc_driver_graphicsandagc_driver_pm4pass; the vertex-input suite also passes ASan with leak detection. Contribution checks pass. Ready for another review; full Linux/Windows CI still needs a maintainer run.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:23:36Z.
Conflicts with main in
Graphics/include/Context.hpp(c9e48e5ae2addedsampleLocationSampleCountson the line aftersinglePassStorage); please rebase.One question while you are there:
Graphics/src/Draw.cpp:1117now runsValidateVertexAddresseson the recipe path, whichmaindoesn't validate. That is a format decode per attribute on every recipe hit. What does it guard? If nothing, please drop it.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:01:45Z.
Review: CHANGES_REQUESTED
Thanks for the rework; the bypass for empty and evicted layouts addresses the earlier regressions. Still open:
Graphics/include/Context.hppconflicts with main (sampleLocationSampleCountswas added aftersinglePassStorage). Please rebase and rerun the PR's tests afterwards.Graphics/src/Draw.cpp:1117):ValidateVertexAddressesruns on every recipe hit, while main only copiesrecipe->vertexInputthere. That is a behaviour change plus a format decode per attribute per draw, and it is the question @oneandonlydean asked. Please drop it, or say which case it guards and add a test that fails without it.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T14:19:14Z.
Review: APPROVED
Picked this up from here since the branch had no push after the last review:
CMakeLists.txt,Context.hpp,Draw.cpp).ValidateVertexAddresses, a recipe hit copiesrecipe->vertexInputexactly as main does (@oneandonlydean's question).agc_vertex_inputand the scoped ctest (714 tests) pass on the rebased head;agc_driver_tessellationsegfaults inside RADV's pipeline-library link, as on main. Merging once the full build is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T14:26:52Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/CMakeLists.txtL1420