Recompiler: term() misclassifies S_SETPC_B64 as Term::Next, breaking multi-block ES+GS Mode::Geometry shaders #1360
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1360
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?
@microwave805 on GitHub · 2026-11-24 15:12 UTC · original
Checked on
main(930e8b4).Problem
In
crates/xcl/src/gpu/rdna2_spec.rs:577,S_SETPC_B64hasflags: 5(F_BRANCH | F_INDIRECT), notF_TERMINATOR(8). InMode::Geometry, the ES→GS handoffS_SETPC_B64hasd.far_target == None, sordna2::branch_target(d)returnsNone.term()(crates/xcl/src/gpu/recomp/mod.rs:564-574) therefore falls through toTerm::Next:In addition,
edges(mod.rs:1446) only collectsrdna2::branch_target(d), omitting the ES→GS handoff edge intogs_start. As a result, whenever either ES or GS has ≥ 2 basic blocks,structured_span(c, 0, hi)(mod.rs:1078-1101) treats theS_SETPC_B64block as plain fallthrough, sees no outside edge enteringgs_start, and collapsesS_SETPC_B64plus leading GS blocks into a singleemit_structuredregion underif (pc == 0u). Insideemit_structured(mod.rs:1040-1043), theFlow::JumpExpr("select(xcl_es_phase, 0xFFFFFFFFu, {s}u)")/Flow::Jump(s)/Flow::Endreturned byemit.rs:864-872forS_SETPC_B64is silently discarded.Minimal trigger
Any
Mode::Geometry(g)shader withg.gs_start = Some(0x10)where ES or GS has ≥ 1 branch (e.g., ES =0x00..0x10ending inS_SETPC_B64; GS =0x10..0x18withS_CBRANCH_SCC0 -> 0x20,0x18..0x20,0x20..0x24S_ENDPGM), translated withwave64 = true, split_wave64 = true(NVIDIA / wave32 GPUs):structured_span(c, 0, u64::MAX)returnsSome(0x20), emittingif (pc == 0u) { ... pc = 32u; }with noif (pc == 16u)block.xcl_entry_pc = 0u, all 64 lanes) falls directly into GS code beforeGroupMemoryBarrierWithGroupSync(), racing on LDS on 64 lanes; then the GS phase (xcl_entry_pc = 16u, lower 32 lanes) has no matchingif (pc == 16u)block and emits 0 vertices/primitives.S_SETPC_B64or ES-only (gs_start = None) falls through instead of jumping/terminating.Suggested fix
Return
Term::Otherinterm()for unresolved indirect branches (d.inst.flags & (rdna2::F_TERMINATOR | rdna2::F_INDIRECT) != 0), and include geometryS_SETPC_B64transitions inedgessostructured_spannever merges across ES/GS boundaries or swallowsgs_start.AI use: Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on
930e8b4before opening.github-bot referenced this issue2026-11-26 04:52:19 +00:00
@tiagonogueiraa-bit on GitHub · 2026-11-24 15:17 UTC · original
claiming: I'll reproduce the issue's minimal ES+GS program on the CPU (translation only), then make the unresolved
S_SETPC_B64end its block for the structurer and add the ES→GS edge, sogs_startgets its ownpcblock. It comes with a CPU test on the HLSL that fails on main. PR within the hour or two.Written with Claude Code (Claude Opus 5.5).