shader: split merged LS+HS programs into their tessellation stages (Ghost of Yotei) #2479
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!2479
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2479"
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-21 00:26 UTC · original
Nawid3333:fix/merged-hull-program→main· +167 −8 · 4 files · 2 commits · openWith tessellation on, Ghost of Yotei (#2350) stops at its first tessellated draw:
(official build
a21fd80, @whofixx). A diagnostic build that prints the stage programs of that draw shows why (#2350 comment, @Ben-Dash):The program at the LS address has the Agc binary type
kHs(3): one merged LS+HS program, with nothing at the HS address.PrepareTessellationProgramsonly handles the two halveskHsFront(LS address) andkHsBack(HS address), so it looks up address 0 and stops.Change
SplitMergedHullProgram(Tessellation.cpp) splits the merged program where its HS part starts. The join is the target of the program's first direct branch, which has to be a forwards_cbranch_execz; the instruction at the join has to bes_mov_b64 exec, -1. The LS half is everything before the join pluss_setpc_b64 s[6:7], the hand-off that fused front halves end with. The HS half is the prologue before the branch, followed by everything from the join on. A program that branches across the join, ends before it, or usess_getpc_b64/s_setpc_b64/s_swappc_b64stops with an error instead of being split.PrepareTessellationProgramstakes the merged path when the LS program iskHs, whatever the HS address holds, and translates the two halves like a fused pair. The split is cached per program hash, and each half gets the hash of its own words. FusedkHsFront/kHsBackpairs take the same path as before.Erlou93's fork (Erlou93/KytyPS5-Erlou,
SplitMergedHullPrograminshader.cpp) splits these programs too; it has no upstream PR. This PR is a separate implementation that differs in two places: its HS half keeps the whole prologue (the fork keeps only the twov_mbcntinstructions), so values the prologue computes for both parts stay defined, and it does not need the HS address to be 0.Test
ShaderRecompilerComputeTests:TessellationMergedHull(triangles) andTessellationMergedHullQuadsbuild a merged program from the existing fused LS and HS fixtures (prologue,s_cbranch_execz, LS part,s_mov_b64 exec, -1, HS part), map it askHs, and runPrepareTessellationPrograms. The quads case also maps a stalekHsBackprogram at the HS address. Both halves have to start with the prologue, and every check of the fused cases then runs on the two halves. Without the change the first of them stops the suite withShaderGetInputInfoHS(): shader=0x0000000000000000 is missing from ShaderMap(measured on maina1fc5ae; this code is the same ona21fd80c8).Full
ShaderRecompilerComputeTestsrun against maina21fd80c8: 196 passed with the change, 194 on main (the 2 new cases); the same 4failed atlines on both (GpuSelectedFormattedRgba16StoreandIndirectImageQueryDimensions, each twice), and both runs stop at the same later check (image format does not support required usage: format=129 ... samples=2inimage.cpp).shader_cfg_testsoutput identical. Windows 11, RX 9070 XT, clang-cl; the compute test cases need the robust-buffer harness change of #2038 on this GPU.Game
@Ben-Dash ran a fork build with this change (ac02674 = main
a1fc5ae+ this change, run 44810316777) with tessellation on (#2350 comment): "Everything booted correctly and I was able to get in game". His shader counter ends atVS 417 | PS 794 | CS 564 | GS 0 | LS 5 | HS 6 | TES 7with no error. With the diagnostic build, the same setup had stopped at the first tessellated draw atLS 0 | HS 0 | TES 0.Written with Claude Code (AI): Claude Code found the cause from the testers' logs, wrote the change and the tests, and ran them.
@coderabbitai[bot] on GitHub · 2026-11-21 00:34 UTC · original
Walkthrough
The change adds a function that splits merged hull shader code into local and control halves. Tessellation program preparation now supports merged
kHsinput and caches the split halves and their hashes. Tests exercise merged hull programs for triangle and quad domains.Suggested reviewers:
nmzik,mrbigbritches,defektuChange: Bug fix
Merge Risk:
Moderate · up to
ee688Merged hull programs are now split into separate local and control programs. If the control part relies on a register set in the local part, tessellation could silently produce wrong output. This should be resolved or explicitly accepted before merge. The rest of the change looks bounded to merged kHs draws.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: splitting merged LS+HS shader programs into tessellation stages, which the changeset implements in SplitMergedHullProgram and PrepareTessellationPrograms. It also names the affected game, which is accurate context. Scope is specific and the wording is clear.
Full details: Description check
Explanation
The description explains the reported failure, the diagnostic output, and the approach. It covers the split logic in Tessellation.cpp, the PrepareTessellationPrograms path change, and the new tests. It is directly 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
@ -278,0 +316,4 @@halves.local.assign(local_part.begin(), local_part.end());halves.local.push_back(MergedStageHandoff);halves.control.assign(prologue.begin(), prologue.end());halves.control.insert(halves.control.end(), control_part.begin(), control_part.end());@coderabbitai[bot] on GitHub · 2026-11-21 00:34 UTC · original · edited 2026-11-21 02:15 UTC
Keep LS-written registers visible to the HS part, or reject programs that depend on them.
SplitMergedHullProgrambuilds the control half from the prologue and the code from the join onward. Register writes made in the LS part before the join exist only in the local half. If the HS part reads such a register after the join, it receives the prologue value instead. For example, an SGPR set to1in the prologue and set to2in the LS part is read by HS as1.The guard, join, and crossing checks do not reject this shape. The fused-stage path preserves register lifetime across the handoff. The merged path does not. Either preserve the LS register state for the HS part, or reject merged programs in which the HS part reads a register that the LS part writes.
@coderabbitai[bot] on GitHub · 2026-11-21 00:34 UTC · original · reviewed
Actionable comments posted: 1
b49bde70-4897-4241-b483-0398bc1406d3Reviewing files that changed from the base of the PR and between
a21fd80c8eandee688c8f41.src/graphics/shader/recompiler/Tessellation.cppsrc/graphics/shader/recompiler/Tessellation.hsrc/graphics/shader/shader.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -278,0 +316,4 @@halves.local.assign(local_part.begin(), local_part.end());halves.local.push_back(MergedStageHandoff);halves.control.assign(prologue.begin(), prologue.end());halves.control.insert(halves.control.end(), control_part.begin(), control_part.end());@Nawid3333 on GitHub · 2026-11-21 02:15 UTC · original
Right: in the merged program both parts run in one wave, so a register that the LS part writes and the HS part reads after the join would reach the HS part on hardware, and the split drops it. The HS half is compiled like a fused HS back half (its own user-data address in s0:s1) and gets the prologue before the EXEC guard plus its own code from the join, which must start with
s_mov_b64 exec, -1. The PR does not check for such a register yet.Whether Ghost of Yotei's program has such a read is not known yet: no dump of it exists here. A test build that prints the program's words is with the tester (#2350 comment). If its HS part reads a register that its LS part writes, I will add a check that rejects that shape instead of translating it.
@ -278,0 +316,4 @@halves.local.assign(local_part.begin(), local_part.end());halves.local.push_back(MergedStageHandoff);halves.control.assign(prologue.begin(), prologue.end());halves.control.insert(halves.control.end(), control_part.begin(), control_part.end());@coderabbitai[bot] on GitHub · 2026-11-21 02:16 UTC · original
@Nawid3333 Thanks for the clarification. The Ghost of Yotei shader’s dependency remains unverified. The dump should help establish whether its HS part reads a value written by its LS part.
A clean dump would not rule out that dependency in other merged programs. For general support, I recommend preserving those values or rejecting programs that depend on them. I’m not marking the finding as addressed yet.
You are interacting with an AI system.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.