shader: allocate both lane halves' dispatcher spill IDs in program order #1678
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!1678
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1678/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-10-19 00:39 UTC · original
Nawid3333:shader/deterministic-dispatcher-spills→main· +21 −5 · 2 files · 1 commits · closed without mergingWhen the recompiler emits a wave64 program for a host with 32-lane subgroups (NVIDIA, for example), a program that takes the CFG dispatcher fallback runs as two 32-lane halves. The high half's spill IDs were allocated by iterating
dispatch.spills[0], anunordered_map<const IR::Inst*, uint32_t>, so they followed the map's iteration order, which depends on the pointer keys:DispatcherIrreducibleControlFlowcompiled to different SPIR-V from one process run to the next (same size, OpVariable IDs permuted). Any cache keyed on the SPIR-V bytes would miss for such a shader (not measured).Logs in several issues show the dispatcher fallback on NVIDIA GPUs, for example NHL 27 (#1101, RTX 3060 Ti, the same 3 shaders in each of 5 runs) and Unbound: Worlds Apart (#391, RTX 3070, 32 shaders). They are from older builds, and whether those shaders are wave64 and spill is not visible in a log.
The change allocates both halves' spill IDs where the low half's are allocated, while walking the program's blocks and instructions in order. Every later use of the maps is a lookup, so the output no longer depends on addresses. For a 64-wide host the same
AllocateId()calls happen in the same order as before, and programs without the dispatcher fallback are not touched.Tests
Windows, AMD Radeon RX 9070 XT (fork CI builds Windows, Linux and macOS; the tests ran on Windows only):
CheckDispatcherSpillIdsDeterministicinshader_recompiler_compute_tests, added to--wave64-onlyand to the full run (on this GPU the full run stops earlier, atIndirectBufferStore, as it does on main): it compilesDispatcherIrreducibleControlFlowthree times for a 32-wide host and requires identical SPIR-V. With--wave64-onlyit fails on main in 5 of 5 runs and passes with this change in 5 of 5.spirv-val).shader_cfgpasses on main and with this change.If you would rather solve this differently, or not as a PR of its own, feel free to close it and say what you would prefer.
AI use
I used Claude Code (AI agent) to find the cause, write the change and the test, and run the checks; I reviewed the diff and the results.
@coderabbitai[bot] on GitHub · 2026-10-19 00:44 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
74d299e5-290b-4b13-a0ea-2b253210d397📥 Commits
Reviewing files that changed from the base of the PR and between
099de8dea6andcf38e51fae.📒 Files selected for processing: 2
src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Spill IDs are now allocated for both lane halves when phi or cross-block spills are registered. A new test compiles
DispatcherIrreducibleControlFlowthree times with host subgroup size 32 and checks for identical SPIR-V. The test runs in both the default and--wave64-onlypaths.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
cf38eThe change preserves the dispatcher spill-ID mapping, and the added test exercises repeated compilation of the affected wave64 case. No concrete merge-blocking risk remains.
Pre-merge checks:
4 ·
1
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. Analyzed 1 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
Comment
@coderabbitai helpto get the list of available commands.Pull request closed