shader: cache the tessellation stride analysis per shader pair #1167
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!1167
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1167/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?
@romainhedouin on GitHub · 2026-10-07 22:37 UTC · original
romainhedouin:perf/tessellation-stride-cache→main· +226 −3 · 2 files · 1 commits · closed without mergingPrepareTessellationPrograms runs AnalyzeTessellationPrograms on every patch draw. That decodes the LS and HS code again and walks every instruction, only to get the same two strides back.
The strides depend only on the two code blobs and the two control point counts (nothing else is read in Tessellation.cpp). So cache them, keyed on the content hashes from ShaderMapUserData plus both counts, behind a mutex. The analysis exits on failure, so only successes are stored. This is the same assumption ProgramCache already makes about shader code being immutable per hash.
Measured on an M series Mac with the small shaders from the existing test (6, 52 and 10 words): PrepareTessellationPrograms goes from 2.39 us to 0.45 us per call. A real HS is larger and the old cost grows with it, so this is a lower bound. Only games that draw patches are affected.
What I tested:
--tessellation-only): PrepareTessellationPrograms equals the uncached AnalyzeTessellationPrograms on the first call, on repeated calls, with two shader pairs interleaved, and with 8 threads first using 96 different pairs at once. Passes on main and on this branch.The shader builder of CheckTessellationProgram moved into BuildTessellationCode so the new check can reuse it.
AI tools were used for code review and drafting the tests. I reviewed the diff and ran the tests above.
Pull request closed