shader: place vertex-pipeline push data at the top of the push block #2128
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2128
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2128/head"
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?
@Nawid3333 on GitHub · 2026-11-05 17:54 UTC · original
Nawid3333:shader/vertex-push-top→main· +240 −44 · 11 files · 4 commits · closed without mergingSummary
A vertex or mesh shader's push-data start depended on the pixel shader it was drawn with: the pixel stage's data was
placed first, and the vertex stage started after it. The same vertex program could therefore need another module for
each pushed pixel data size;
FindModulemissed and Kyty translated and compiled the shader again. In an ASTRO BOT(PPSA21564) run on upstream
23ed47ec6, 20 of the 35 new modules for an already-cached Program differed only in theirpush-data start (14 vertex, 5 mesh, 1 pixel). This PR places the shader data of the vertex-pipeline stages (vertex,
mesh, LS, HS, domain) at the top of the 32-dword push block, so the start of the first vertex-pipeline stage no longer
depends on the pixel shader as long as it fits.
Change
PushData::StartFor(stage, floor, size, ceiling)andCanFit(start, size, ceiling)(ShaderIR.h): pixel and computekeep the bottom-up rule (start at
floorifsize != 0and the data fits, elseNoStart). Vertex-pipelinestages start at
ceiling - sizewhensize != 0andfloor + size <= ceiling, elseNoStart.GetProgramgets apush_data_ceiling. The vertex loop in pipelineCache.cpp starts it atPushData::DwordCountand lowers it to the start of each vertex stage that uses push data; vertex-pipeline stages no longer advance the
push-data cursor. The draw prefix (mesh draw parameters, object id, user clip planes) keeps its bottom offsets.
FindModuleand the SPIR-V emitter (DefineDescriptors) compute the start with the sameStartFor. For otherwiseidentical module inputs, the first vertex-pipeline stage reuses its top-placed module across pixel data sizes
whenever it fits; later tessellation stages also need the same resolved ceiling.
A stage pushes its data exactly when it did before: with the prefix and the pixel and earlier vertex-stage data that
were actually pushed (spilled data takes no push space), the stage fits iff the sum is at most 32 dwords, in both the
old and the new layout. Only the position inside the block changes.
Limit: whether a vertex-pipeline stage fits still depends on the pixel data, as before, so the module of the first
vertex-pipeline stage has at most two forms: top-placed or not pushed (
NoStart). With tessellation, a later stage'sceiling depends on whether the earlier stages fit, so its start can still vary with the pixel data size.
Tests
TestGraphicsPushConstantFit(shaderCfgTests.cpp) walks prefix 0..32, pixel data 0..32, earlier vertex-stage data0..32 and stage data 0..32 for Vertex, Mesh, Local, TessellationControl and TessellationEvaluation, and checks that
pixel and compute keep the old start and that every vertex-pipeline stage pushes exactly when the old rule pushed,
at
ceiling - size.TestVertexPushConstantPlacementcompiles one vertex program next to 2 and 7 dwords of pixel data: the bindingsand the SPIR-V binary are identical, the start is
32 - size; with a ceiling of 16 it starts at16 - size, andit moves to the buffer path when the data misses the fit by one dword.
CheckVertexPushTopCache(ShaderRecompilerComputeTests.cpp, run by--shader-cache-onlyand thefull run): two
PipelineCache::GetGraphicsProgramslookups of one vertex shader with two pixel shaders that push2 and 7 dwords of shader data compile one vertex module, returned by both lookups, whose push data starts at
32 - size. On upstream the same test fails: the vertex module depends on the pixel shader-data size.32 - size(or no push when the prefix leaves no room), and the existing GPU fixtures place vertex data at the top.6fd43ac65(Windows 11, Radeon RX 9070 XT): shader_cfg_tests pass; the full ShaderRecompilerComputeTests run (with the cases this GPU lacks features for skipped) shows no failed check that the same build without this PR does not show too; the new VertexPushTopCache case passes.6fd43ac65): the Windows, macOS and Linux builds and tests pass.CheckVertexPushTopCacheperforms program lookups without executing a draw;TestGraphicsPushConstantFitchecksall five vertex-pipeline stage kinds arithmetically, without a complete tessellation-stage allocation sequence.
23ed47ec6and were not rerun on6fd43ac65.In-game
ASTRO BOT (PPSA21564), Radeon RX 9070 XT, Windows 11, upstream
23ed47ec6with and without this PR, same inputscript, compared at the same point of the run (225 distinct shaders):
#2119 (asynchronous shader compilation) also changes module lookup and compilation. Combining the two needs the
push-data ceiling passed through
RequestAsyncandCompileStage, a stage- and ceiling-awareFindCandidate, thedescending-ceiling loop kept, and in-flight module compiles keyed by the resolved start (or by both floor and
ceiling).
AI use: written with AI assistance (Claude Code and OpenAI Codex): the change, the tests, the fit check and the
measurements; reviewed, tested and run in the game by me.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-11-05 18:02 UTC · original · edited 2026-11-09 19:26 UTC
No actionable comments were generated in the recent review.
Walkthrough
Push-data placement now uses stage-specific rules and an optional ceiling. The pipeline cache passes the ceiling through module lookup and compilation, and lowers it when a returned graphics module uses push data. Tests cover placement bounds, spill behavior, mesh placement, and vertex-module reuse across pixel shaders with different push-data sizes.
Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Minimal · up to
41d16No actionable merge-blocking issue is established; the change is mergeable after normal checks.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 9 files. (2 skipped: 2 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
23aee441-e102-470a-9e5b-2e2bfc2cb79eReviewing files that changed from the base of the PR and between
a3e1b9abedand41d1693631.src/graphics/host_gpu/renderer/pipeline/pipelineCache.htests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@coderabbitai[bot] on GitHub · 2026-11-07 21:00 UTC · original · reviewed
057fdfc9-49da-4d3c-b150-6d04503160bcReviewing files that changed from the base of the PR and between
88e94686bband5b7ee45196.src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/ir/ShaderIR.htests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@Nawid3333 on GitHub · 2026-11-21 14:51 UTC · original
Superseded by
b48af59f6("shader: take pixel shader data from the end of the push constants"): the pixel stage now takes the end of the push block, so where the vertex-pipeline stages start no longer depends on the pixel data size. That is what this PR did from the other end of the block. Closing this one.Pull request closed