shader: key vertex shaders on the resolved fetch, not the raw format word #2127
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!2127
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2127/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:12 UTC · original
Nawid3333:shader/vertex-fetch-signature→main· +226 −39 · 9 files · 3 commits · closed without mergingSummary
ASTRO BOT (PPSA21564) translates many vertex shaders more than once. Kyty puts each embedded vertex fetch's raw format
word (
resource.fields[3] & 0x7ffff, shader.cpp) into the vertex ProgramKey, so format words that fetch the samevalues (for example 0x42fac and 0x4a3ac) produce separate Programs, and each is translated and compiled again. In an
ASTRO BOT run on upstream
23ed47ec6, 36 of the 38 new Programs for an already-seen shader hash were vertex shaderswhose keys differed only in these format words. This PR keys the vertex stage on what the fetch resolves to and
carries the exact host format in the graphics pipeline key instead.
Change
VertexFetchSignature(BufferFormat.h): the vertex ProgramKey stores the resolved fetch signature instead of theraw word: the scalar kind of the fetched value (float, uint or sint) plus the four resolved selectors. Formats without a
component count (raw 113/121) and invalid selectors keep the raw word.
ResolveVertexFetchSource(BufferFormat.h): when the guest format has fewer than four channels and the selectorasks for the constant Vulkan supplies for that missing channel (0 for components 1 and 2, 1 for component 3), the
channel becomes a memory read. Vulkan converts a vertex attribute like an image read and fills missing G, B and A
components with (0, 0, 1) (spec 28.4.1 "Vertex Input Extraction"), so the value is the same.
TranslateEmbeddedFetch(Attribute.cpp) uses it.PipelineVertexInputState::Attribute(the key'svertex_input) gainsvk::Format format;GetGraphicsPipelinefills it per attribute withInputFormat, and shaders.cpp builds the attribute descriptionsfrom the key.
ShaderModule::vertex_formats,VertexInputFormatsand their serialization inIoModuleare removed.Tests
TestEmbeddedVertexFormatSwizzle(shaderCfgTests.cpp): 0x4022c, 0x1722c, 0x42fac and 0x4a3ac share one signature;words whose constants differ from Vulkan's defaults keep distinct signatures, and so do float, uint and sint fetches
with the same selectors; raw formats 113 and 121 and invalid selectors keep the raw word. The expected fetch widths
now include the missing channels that read the attribute, and the test data holds Vulkan's defaults there.
CheckVertexFetchCache(ShaderRecompilerComputeTests.cpp): program and module reuse across theformat words of one signature group, the fetch width, identical SPIR-V per group, the per-draw pipeline format,
pipeline recreation when only the format changes, and the pipeline keys surviving a shader store reopen; formats
the device cannot use as vertex buffers are skipped.
all 524,288 format words at fetch widths 1-4 found no value difference.
b4c0731fc(Windows 11, Radeon RX 9070 XT): the 32 tests CI runs pass; shader_cfg_tests and resource_tracking_tests pass; ShaderRecompilerComputeTests (the full run, with the cases this GPU lacks features for skipped, and separately the shader-cache, push-constant, shader-data-storage and program-id groups) shows no failure that the same build without this PR does not show too (two existing cases fail on both: GpuSelectedFormattedRgba16Store, IndirectImageQueryDimensions); the new VertexFetchCache case passes.CheckVertexFetchCachecreates and recreates Vulkan pipelines and reopens the shader store; it does not executea draw or read back vertex-fetch results.
b4c0731fcand the game measurements use23ed47ec6; a read-only review against182161eb3found nothing that invalidates them, but they were not rerun there.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):
Vulkan pipelines still differ per vertex format (the format is now part of the pipeline key), so this PR saves
shader translations and SPIR-V modules, not pipeline creations.
#2119 (asynchronous shader compilation) moves the module's
vertex_formatsassignment intoCompileStage. If bothare merged, that assignment goes away with this PR, and the per-draw
InputFormatcalculation moves into #2119'sMakeGraphicsPipelineKey.AI use: written with AI assistance (Claude Code and OpenAI Codex): the change, the tests and the measurements;
reviewed, tested and run in the game by me.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-11-05 17:27 UTC · original · edited 2026-11-09 15:52 UTC
No actionable comments were generated in the recent review.
Walkthrough
Vertex-fetch translation now resolves sources using the format and component index, and vertex-stage static keys use format-aware fetch signatures. Graphics-pipeline attributes now store their Vulkan formats. Shader modules no longer store or serialize a separate vertex-format vector. Tests cover fetch signatures, pipeline format selection, cache reuse, recreation, and persisted keys.
Suggested reviewers:
nmzikChange: Refactor
Merge Risk:
Minimal · up to
261d6The change reduces duplicate vertex shader translations by keying on the resolved fetch signature, and the pipeline formats come from the pipeline key. No actionable merge-blocking risk was identified in the supplied context.
Pre-merge checks:
4 ·
1
Full details: Title check
Explanation
The title names the main change: vertex shader program keys now use the resolved vertex fetch signature instead of the raw format word. The raw-summary confirms this change in shader.cpp (VertexFetchSignature replaces the masked fields[3] word) and in BufferFormat.h. The title is specific and matches the primary objective in the PR objectives.
Full details: Description check
Explanation
The description is detailed and on-topic. It explains the duplicate vertex Program problem, the new VertexFetchSignature and ResolveVertexFetchSource functions, the vk::Format addition to PipelineVertexInputState::Attribute, the removal of vertex_formats and IoModule serialization, the new tests, and the in-game measurements. These match the file-level summaries.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% 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 2 functions across 1 files. (1 skipped: 1 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
f06fbc32-9cc0-45aa-a604-a6f70e5d0b6cReviewing files that changed from the base of the PR and between
e762dbc310and261d68a0a3.src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
@Nawid3333 on GitHub · 2026-11-21 14:51 UTC · original
Superseded by
2888ad28a("shader: move vertex fetch formats from the vertex shader key into the pipeline key"): the vertex key now holds the swizzle, channel count and type class instead of the raw format word, and the pipeline key holds the format, which is the main change of this PR. Closing this one.Pull request closed