shader: reuse loop increment proofs for Ghost of Yotei #1878
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!1878
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1878/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?
@MrFr3di on GitHub · 2026-10-24 11:23 UTC · original
MrFr3di:perf/loop-proof-cache-upstream→main· +442 −20 · 8 files · 4 commits · closed without mergingSummary
Ghost of Yotei compute shaders repeatedly trigger the same expensive loop increment-guard proof for different resource uses. This adds substantial CPU shader-translation time.
Cache successful and unsuccessful proofs within each
Tracker, keyed by(phi, compare, increment_block)and invalidated on IR mutations. Use-specific, induction-step and lane checks remain outside the cache.Also replace the ordered lookup tables inside
LoopBoundProofwith hash tables.Performance
Paired A/B measurements on captured compute shaders, Windows x64. CPU compilation time before Vulkan pipeline creation.
The complete corpus shows a 17.43× median paired speedup. Ordinary inputs show a +0.77% median paired time change, with an observed interval of −1.03% to +1.66%.
Testing
resource_tracking_testspassed.Additional testing with other games and AMD GPUs would be appreciated to help identify any compatibility or performance regressions.
Development and testing were carried out with assistance from Codex and Claude. I independently reviewed the changes.
@coderabbitai[bot] on GitHub · 2026-10-24 11:33 UTC · original · edited 2026-10-28 17:15 UTC
No actionable comments were generated in the recent review.
b1ea3501-d1f0-4fc3-a8ac-8fdf8df95178Reviewing files that changed from the base of the PR and between
372cfb14a9and2e591c2c9f.CMakeLists.txtsrc/graphics/shader/recompiler/ir/Value.cppsrc/graphics/shader/recompiler/ir/Value.hsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cpptests/ResourceTrackingTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Walkthrough
The changes add a thread-local IR mutation epoch and record selected instruction, branch, dead-code-elimination, and resource-tracking mutations.
BoundedInductionnow uses an epoch-checked cache for increment-guard proofs. The test target adds cache tests for invalidation, proof agreement, and Boolean truth-table results.Suggested reviewers:
nmzikPriority:
Normal
Change: Refactor
Merge Risk:
Minimal · up to
2e591No merge-blocking issue was established for the proof cache.
Pre-merge checks:
5
Full details: Title check
Explanation
The title names the main change: reusing loop increment-guard proofs (a cache) in the shader recompiler, motivated by Ghost of Yotei. The raw summary confirms the Tracker-level proof cache with invalidation on IR mutations, and the description describes the same change. The title is specific and concise, so the check passes.
Full details: Description check
Explanation
The description states the purpose (repeated expensive loop increment-guard proofs for Ghost of Yotei compute shaders), the cache design (keyed by (phi, compare, increment_block), invalidated on IR mutations), the hash-table change in LoopBoundProof, performance measurements, and test coverage. These match the file-level summaries and PR objectives, so the description is related to the changeset.
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
Comment
@coderabbitai helpto get the list of available commands.@ -1756,0 +1829,4 @@}const bool guarded = ComputeIncrementGuard(phi, compare, increment_block);m_increment_guards.insert_or_assign(key, IncrementGuard {epoch, guarded});return guarded;@coderabbitai[bot] on GitHub · 2026-10-24 11:33 UTC · original · edited 2026-10-24 16:49 UTC
🔎 Supported by static analysis
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11051
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42466
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15131
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11150
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10654
Invalidate increment proofs before DCE.
EliminateDeadCode()can replace a proof-relevantBlock::conditionwithout advancingg_ir_mutation_epoch. The cache tests show that this change can alter the verdict for the same(phi, compare, increment_block)key. A proof cached byFoldBoundedLoopSelectors()can therefore be reused byPlanIndirectDescriptors()with a stale verdict.Suggested fix
✅ Addressed in commit
372cfb1@coderabbitai[bot] on GitHub · 2026-10-24 11:33 UTC · original · reviewed
Actionable comments posted: 1
0babe70b-003e-4f4d-b60e-148577b39850Reviewing files that changed from the base of the PR and between
8291cfeb04and519273af93.CMakeLists.txtsrc/graphics/shader/recompiler/ir/Block.cppsrc/graphics/shader/recompiler/ir/Value.cppsrc/graphics/shader/recompiler/ir/Value.hsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cpptests/LoopProofCacheTests.cpptests/ResourceTrackingTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Nawid3333 on GitHub · 2026-11-03 18:03 UTC · original
Test report: Ghost of Yōtei (PPSA26344) on current main, Windows 11, RX 9070 XT (AMD driver 26.10.1).
On main (
dfec14aa8) the game needs #1967 to get past its first compute shaders (without it,Tracker::CollectScalarReadoverflows the stack), and #1758 and #2062 for the descriptor pool and the warm boot. With those three, a cold boot stays on the splash screen for me: compute shader0xb920ac9e14cb5fb8(102 blocks, 3 loops) does not get through resource tracking, and the compiler thread spends its time creating and destroyingLoopBoundProofobjects. Offline this shader takes about as long on893b03552+ #1967 (11322 ms), so the slow proof is not new.With this PR merged on top (it merges cleanly):
PrepareShaderSource+TranslateProgram):0xb920ac9e14cb5fb812431 ms,0x69ba1a07c7a955108722 ms,0x3d82c2913cac198d1796 ms0x386c6a44da561c0d275 msExtractResourcePlan, serialized withSaveResourcePlanand hashed) are the same for all 172 shaders with and without this PR (and the same in two runs of the same build).893b03552build. Without this PR, three cold boots stayed on the boot screen ("Waiting for frames", 0 draw calls) after 35 to 56 compute shaders. Two cold boots with--graphics-debug-dumpgot further without this PR (about 124 compute shaders), so the stall also depends on timing.So on current main this PR also fixes a stall, not only compile time.
Pull request closed