shader: count memory index users once when planning descriptors #1308
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!1308
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1308/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?
@NeySlim on GitHub · 2026-10-09 14:54 UTC · original
NeySlim:perf/track-memory-index-users→main· +29 −9 · 1 files · 1 commits · closed without mergingProblem
When resource tracking plans indirect descriptors,
MemoryIndexBelongsTochecks that no other memory instruction uses the memory index of a descriptor read. It walks every instruction of the program for each query, and it is queried for the candidate reads of every image or buffer handle that needs a plan, so large shaders pay a quadratic cost. Translating the pixel shader3d52c7172f95fd37of God of War Ragnarök (PPSA08332), the walk takes 14% of the time; in a combat scene that compiles new shaders it takes 6% of the GPU command thread.Change
PlanIndirectDescriptorscounts the memory instructions of each memory index once, when it starts, keeping the first one, andMemoryIndexBelongsToanswers from these counts. Planning adds only non-memory instructions (selector phis, masks, bounds) and removes none, and the queries only run while it plans, so the counts stay exact. A query with an index outside the table exits instead of walking.Test
No behavior change, so no new test fails without it. On a branch with my other pending changes (the function is the same as on
origin/main), I compared the output of the shader compiler on the programs God of War Ragnarök compiles in its first 12 minutes (1,986 recorded stage inputs, translated and compiled to SPIR-V in one process): the SPIR-V of every program is identical with and without the change, and translation takes 21.8 to 23.0 s instead of 28.3 to 35.0 s (two runs each,TranslateProgramonly, -23% best to best). The translated programs (ProgramToString) of 1,040 shaders dumped from the game are also identical.resource_tracking_tests,resource_materialization_testsandshader_cfg_testspass.shader_recompiler_compute_tests, one case per process: same results asorigin/main(600 of 610 cases pass on both; the same 10 fail on this RADV setup).Validation
Linux, Ryzen AI Max+ 395, Radeon 8060S, Mesa RADV 26.2.3. Not tested on Windows or macOS; the change is platform-independent C++ in the recompiler.
AI use
I used Claude Code (AI agent) to profile the translation, write the change, and run the comparison and tests above on my machine. I reviewed the diff and the results before opening this PR.
@coderabbitai[bot] on GitHub · 2026-10-09 14:57 UTC · original · edited 2026-10-12 16:06 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
22ed3cb0-b7d8-4563-a313-0f8c246efa37📥 Commits
Reviewing files that changed from the base of the PR and between 9de7f3a9c48ba2d431d003367659e2e253b8e000 and
bd4daf880b.📒 Files selected for processing (1)
src/graphics/shader/recompiler/ir/passes/ResourceTracking.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
📝 Walkthrough
Walkthrough
Trackernow counts memory instructions that use each memory metadata index before planning indirect descriptors.MemoryIndexBelongsTouses the count and first user to allow an index with no users or one user that matches the supplied owner.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Refactor
Merge Risk: ⚪ Minimal · up to
bd4daNo actionable issue remains from this change; it is ready to merge after normal checks.
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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.Pull request closed