Shader: merged hull factor writes under a lane-index AND fail the control point 0 proof, then a waterfall loop's ballot is refused (PPSA01317) #17251
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from boykopovar/AnyPS5. Originally posted by freneza on 2026-11-08T16:17:38Z.
What happens
A merged hull program stops in tessellation lowering:
shader 0x13d1ac0d00 stage 2: ShaderRecompiler::Recompile: tessellation lowering: per-patch tessellation output is not written by control point 0 alone at pc 0x304Title, test or build step
PPSA01317 01.710.000
AnyPS5 commit
main4977f64052with open PRs merged on top (#16644, #9335, #7256, #10049, #9969, #14296, #9457 and #14636), plus local changes that let the title get this far.FirstInvocationOnlyand the lane-mask check inTessellationLowering.cppare unchanged onmaind0d11564ca.System
Bazzite (Linux 7.2.9), RTX 5070 (NVIDIA 615.78.08), built in a Fedora distrobox.
Steps to reproduce
Start the title's first licence test. The hull program is translated when the driving scene loads. Its address changes between runs (0x13cfac0d00, then 0x13d1ac0d00). With
APS5_DUMP_SHADERS=1the.prepare.reqcapture reproduces both failures below offline withagc_shader_replay --prepare.Log
What was checked
The failure is the same in three runs. These findings come from the capture and the replay tool.
1. The per-patch write really comes from control point 0 only, but
FirstInvocationOnlycannot prove it. The tessellation factors at pc 0x304 are stored underv_cmpx_gt_u32 exec, 1, v11(pc 0x2bc), wherev11 = v_bfe_u32 v1, 8, 5is the control point ID. In IR, the store's predicate is:The
SelectU32condition is the other operand of the sameLogicalAnd, so the select is the control point ID whenever the predicate holds.FirstInvocationOnlycallsIsInvocation, which evaluates its argument with no predicate. The select is therefore not resolved, and the check fails.When
FirstInvocationOnlyrecurses into aLogicalAnd, I pass thatLogicalAndas the predicate thatIsInvocationevaluates under. This needs four changed lines, and the capture then gets past this check:This is sound because an operand of a
LogicalAndonly matters when the wholeLogicalAndholds. Phi operands are still checked without a holding predicate.2. Next stop: a waterfall loop. With that change, the replay stops at
the hull program uses a lane mask other than its own lane's bit(reported at pc 0x0). TheBallotstill in use comes from a waterfall loop at pc 0x258–0x2a0:v_readfirstlane_b32 s3, v6, thenv_cmpx_eq_u32 exec, s3, v6;s_mov_b32 m0, s3, then an LDS access;s_xor_b32 s10, s10, exec,s_mov_b32 exec, s10and a branch back while lanes remain.The loop runs one LDS access per distinct
m0value among the active lanes. Its remaining-lanes mask is theBallot, read throughCompositeExtractU32x4andBitwiseOr32to test whether any lane remains.Open question: should merged-hull lowering recognise this
readfirstlane/cmpx_eq/xor execloop and turn it into a per-invocation access? The loop's result does not depend on which lane is picked first. If that is the intended direction, I can open a PR for part 1 with a test.I can share the 14 KiB capture privately with a maintainer who needs it.