perf(shader): emit vertex modules specialized instead of in registration form #14265
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14265"
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 Astronaut10 on 2026-11-01T05:17:23Z.
What
On devices with graphics pipeline libraries, vertex and pixel artifacts are emitted in registration form so that their libraries can be prebuilt at registration with a default state. For the vertex stage this form costs GPU time on every vertex: each vertex attribute reads its component selectors, and each buffer load the V# stride and swizzle (and the format and bounds mode when the load does not take the descriptor's format,
descriptorandformattedCallinSpirvRuntimeBuffer.cpp), from the shader data at run time, where a specialized module has them as constants.This emits vertex artifacts specialized from the start, as the existing fallback above
registrationWordLimitalready does. Pixel artifacts keep registration form, and nothing else changes (GPL, the set-1 pixel layout, fixed push slots, the pixel word limit).docs/dev/ARCHITECTURE.mdand the two technical debt entries on registration modules (debt/shader.md,debt/libSceAgcDriver.md) now describe pixel modules only.Tests: the prepared graphics, vertex fetch and zero-stride fetch tests asserted a vertex registration module and now expect a specialized one; their rendering checks are unchanged.
agc_driver_gcn_buffer_format_lookupandagc_formatted_buffer_oncechecked registration-form buffer code through a vertex shader; they now compile the same loads and stores as a pixel shader, which keeps registration form and shares that code, andagc_formatted_buffer_oncealso checks that each module has the form it was compiled for. Both still fail when the change they guard is undone: with the former private GCN format table (50e9cc4021reverted) and with a formatted V#'s format word read at run time in registration modules.Cost: a vertex stage's pre-rasterization library is no longer prebuilt at registration; it is built at its first draw. Counted with a build-origin counter (a local diagnostic, not part of this PR) on an older base (
main27ad7244d2with other changes) in a cold boot of the scene below: 19 more pre-rasterization libraries built at the draw after the level started (+0.7 s of draw-thread time, no added stall frame) and 80 fewer prebuilt. Warm boots built no library at the draw on either side, because the pipeline journal replays them. These counts were not repeated on currentmain.Relation to #9508: with its opt-in
APS5_GPU_HEAP,PreparedShaderInvocation::MaterializeHeaponly takes artifacts in registration form, so under that switch vertex stages leave the heap path for the per-draw path; #7642, #10193, #13928 and #13929 carry the same check. With the switch off, the default, nothing changes. For context only, not this PR's measurement: an earlier prototype run on an older #9508-based base with the heap on found this change 1.6 % slower in the same scene (95 % -2.2 to -1.0 %).The vertex half of the registration ABI (the vertex component selector state and its emission, and the pre-rasterization prebuild from a vertex registration result) becomes unreachable; this PR leaves it, and removing it is a follow-up.
Tested
CachyOS (Linux 7.3), Ryzen 7 5700X3D, RX 9070 XT (RADV, Mesa 26.2.5, GPU clock level forced to
high), 3840x2160. PPSA21564 (ASTRO BOT 01.007.000), started intounderwater_aerial_gardenwith-lvl, standing at the spawn with no input, warm caches (each side ran the scene before; the change needs its own shader cache).Base:
main029463ceb6; change: this branch atc46f7afcbe, measured before it was rebased ontomain3ab5a11d66without conflicts (the same diff; rebuilt and its focused tests rerun after the rebase). Plainmainneeds a larger host-import budget than its default to run this scene at a usable rate, so both sides setAPS5_HOST_IMPORT_MIB=11815. Switches on both:APS5_DEPTH_PLANE_COPY_MIB=512 APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1 APS5_NO_PAD_INPUT=1 APS5_HOST_IMPORT_MIB=11815.Clean runs, each measured from 40 s to 130 s after the level started, in the order A B B A B A A B, four per side, no run excluded; FPS from every frame of that window:
mainDriver.Draw.preparems per frameThe GPU saves 10.8 ms per present, and every B run is faster than the A run next to it. The frame is bound by the CPU chain (queue worker
0x0is about 87 % busy in both traces), so FPS gains less than the GPU time. Every run has one long frame about 86 s after the level started, when the title starts a video; B's was longer in three of four runs (mean 1,288 against 1,160 ms), which four runs do not separate from noise.Summary lines of the attached traces, captured as the Performance report form describes (no other
APS5_TRACE_*orAPS5_PROFILE_*switch; the runner reads the log through a pipe on both sides). The window is 4 s, 40 s after the level started, so the queue worker's default event buffer does not fill; 13 presents are too few to compare frame times, which the clean runs above do:tools/trace_digest.py:main13 presents, frame p50 313.5 / p99 327.7 ms, GPU busy 162.3 ms per present (gputrack 163.4 ms per frame); this PR 13 presents, frame p50 316.1 / p99 320.5 ms, GPU busy 150.8 ms per present (gputrack 151.3 ms per frame),dropped: noon both.A frame dump of the scene (
APS5_DUMP_FRAMES) on both sides shows the same image, apart from the animation phase.Validation: the 129 tests of
-R 'agc_.*(vertex|prepared_graphics|registration|pipeline_library|formatted_buffer|buffer_descriptor|graphics|draw|gcn_buffer_format|prepared_exports|image_plane|stencil_null)'withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandctest -V, onmain(029463ceb6) and on this branch: 129 of 129 pass on both, neither log reports the layer missing, and the validation messages are identical: the same 10VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605errors inagc_driver_prepared_exportson both sides, 30layerCount-compatibilityand 16ShaderOutputNotConsumedwarnings; this PR adds none. The full suite (ctest, 3,100 tests,ANYPS5_REQUIRE_VULKAN=1) passes apart fromagc_driver_tessellation(a crash inside RADV) andagc_idle_publish_wait, which fail onmainas well.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)aps5-trace-029463ceb62c-608475.json.gz
aps5-trace-c46f7afcbe28-608774.json.gz
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:42:47Z.
Review: COMMENTED
The GPU saving is clear (165.2 to 154.4 ms per present on a 9070 XT / RADV, every B run ahead of its neighbouring A run), and removing per-vertex descriptor reads is the right target. The cost side is stated but not measured on a cold start, which is where it lands.
1. The pre-rasterization library moves from registration to the first draw. On a cold pipeline journal each vertex stage's library is now compiled by the draw thread when it is first drawn, where today it is built at registration on a worker. The description counts 19 more libraries built at the draw after the level started (+0.7 s of draw-thread time) on an older base, "no added stall frame", and says the counts were not repeated on current
main. 0.7 s is the sum, but each library is a separate compile on the thread that bounds the frame, so a cold first-run player gets a hitch per new vertex shader. Please report the longest frame and the number of frames over 100 ms in a cold boot of the same scene,mainagainst this change, fromtools/trace_digest.py. The warm numbers hide this, because the journal replays the libraries.2. The longest frame is already longer on B in three of four warm runs (mean 1,288 against 1,160 ms around the video start). The description puts that down to noise. Four runs cannot separate it, which cuts both ways. Please add runs, or take the frame after the video start out of both comparisons, and say which.
3.
APS5_GPU_HEAPregresses. The description notes that an earlier prototype found this change 1.6 % slower with the heap on, and that vertex stages leave the heap path. The heap is opt-in today, but #9508, #7642, #10193, #13928 and #13929 all carry that path. Say which of those landing first changes the answer. Specialized vertex modules and the heap pull in opposite directions: one specializes per draw state, the other shares modules across it.4. Module count. A specialized module per vertex layout means more distinct SPIR-V and pipeline variants than the registration form, which has one. Please give the number of distinct vertex modules on the scene, before and after, since it drives shader cache size and cold compile time.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T07:00:55Z.
Review: COMMENTED
Reviewed — CI is red on the merged build, for the same base-code reason as #14264
The shader change emits vertex modules specialised instead of in registration form. The hosted relinker jobs fail on this head. The Ubuntu relinker job fails only on
check_skips_ctest, which fails in base code: the same failure is on #14264, and both share base7fad6837. The shader change itself was not read in this pass, so this review says nothing about its correctness.What I ran
9dfce2d76f9a734474e7e8c19097b3ca8c6b191d; base7fad6837767a4f0cb1636ff835cd42522aae8fac. The changed files are shader and libSceAgcDriver test files (FormattedBufferOnce.cpp,GcnBufferFormatLookup.cpp,PreparedGraphics.cpp,VertexFetch.cpp, and others intests/), plus the production shader files.check_skips_ctest(Test #63, 1 of 557 failed). That is the same assertion failure as #14264:test_notrun_without_ctest_skip_marker_is_rejectedexpects aValueErrorthe basecheck_skips.pydoes not raise. The macOS (clang++ and x86_64) and Windows relinker jobs also fail; their logs were not read.tools/check_skips.pyand its test have the same blob at the base and at this head, and this PR does not change them.100% tests passed, 0 tests failed out of 1).Results
check_skips_ctest(hosted, Ubuntu relinker)ShaderTable, vertex module emission)Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed, one warning. ABI audit: not applicable. Stack check: passed, no errors. Hosted:
gh api repos/boykopovar/AnyPS5/commits/9dfce2d76f9a734474e7e8c19097b3ca8c6b191d/check-runs, and the Ubuntu relinker job log (125007976445).Negative control
Not run here. A negative control needs a local build, and code from this head is not run here.
Findings
Blocking
check_skips_ctest) that this PR does not change. The base needs the fix first; see #14264, which has the same failure.Non-blocking
Sources
check_skips_ctest)github.com/boykopovar/AnyPS5@9dfce2d76f/tools/tests/test_check_skips_ctest.pyNot verified
To get this to a good state
check_skips_cteston the base (see #14264), then re-run this head's relinker jobs.