startup: lower constant-trip mesh57 loops outside exchanges (#2413 T6) #2622
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2630"
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 R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-25T23:37:56Z.
Change
Implements #2413 T6 constant-trip loop lowering in
translate_mesh57: one proven scalar counted back-edge outside the two modelled group-memory exchanges is unrolled; data-dependent trips, EXEC-carrying bodies, and unconditional back-edges stay refused byslot 57 mesh: a loop outside the group-memory exchanges is not covered.Extends / supersedes the host-only refusal fixture in #2622: the accepted constant-trip program translates and draws; unsupported shapes keep the exact-string refusal oracle; the once-through mutant (back-edge →
s_nop) must fail the constant-trip draw reference.Refs #2413
Refs #2622
Refs #1759
Refs #870
No R1 runtime, no T5/T7, no compute Dispatch, no shared-interface change beyond
mesh_skeleton.Verification
Commit:
e8adb6b7onSimSalabimse:cursor/mesh57-t6-loop-lowering-f5d7Tip base:
d371ce46(R0Y00/main)Claim: https://github.com/R0Y00/Xbox2Windows/issues/2413#issuecomment-7177696411
Host (Linux agent):
Result: both
ok.Windows Release (when available on a mesh-capable machine):
WARP and one mesh-capable GPU should match the CPU rasteriser; adapters without mesh tier skip 77 (report separately). This agent host is Linux-only, so WARP/hardware draws were not run here.
Evidence and follow-up
tests/startup_mesh57_loop.s); no retail.m57.s_mov_b32 s40, 0then four iterations ofs_add_u32/s_cmp_lt_u32/s_cbranch_scc1; finals40 == 4selects vertex red = 1.0.s_branchback-edge, compare against root constants8,v_cmpxin the loop body; once-through mutant fails the draw oracle.Checklist
AI-assisted contribution.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T23:53:10Z.
Review: CHANGES_REQUESTED
mesh_trip_countcurrently lets the update opcode pick the comparison's signedness. At2be6d420,mesh_trip_count(0x7fffffff, 's_add_i32', 1, 's_cmp_gt_u32', 4, 's_cbranch_scc1', True)returns1. The first update produces0x80000000, so the unsigned comparison is true and the back-edge is taken. This loop cannot be unrolled within the current 64-step bound. Please take signedness from the compare alone and cover a signed update followed by an unsigned compare across bit 31 in the source-built path. Please also tighten the once-through check to require an actual draw-reference mismatch, like the wrong-pixel control does. Its current assertion can pass on an unrelated PSO or command failure.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T23:57:44Z.
Review of head
2be6d420, by reading the diff against main (not run). Two findings that are not in the current review, and one sequence for the signedness point already raised.1. Reversed subtraction simulates the wrong recurrence.
gfx2hlsl.py:1487-1490accepts the counter as either source (elif ops[2] == counter ...) and keeps only(name, imm), andmesh_trip_count(:1405-1409) then always computescounter - step. Add is commutative, buts_sub_*is not:The simulation computes 5 - 6 = 0xffffffff, which is not < 4, so it emits one trip and leaves s40 = 1. Refusing a
s_sub_*step whose counter is the second source would close it.2. Dropping the latch hides SCC reads after the loop from
descriptor_scc_reads.region_walk(:1641-1653) repeats the body and skips the latch (i = latch + 1), soStage.inshas no instruction at the latch offset.Stage.descriptor_scc_reads(main:2746-2764) walks byoff + sizefrom 0 and stops atoff not in instructions(main:2753), so it ends at the body's finals_cmpand checks nothing after the loop. The refusal it would have given isscc from descriptor data in <reader>. A control: after the fixture loop,s_add_u32 s41, s10, 4(an SCC write the translator does not model, on the descriptor table pointer) thens_cselect_b32 s42, 1, 0should refuse with that message (not run). A branch reader would be caught separately (a branch reads SCC that is not proven wave-uniform) and would hide the gap.3. Signedness (already in the review), the other direction:
signed = step_name.endswith('_i32') or '_i32' in cmp_name(:1399) also over-unrolls:The simulation compares signed and emits 3 trips.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T01:35:53Z.
Rebased onto current
main(includes the pre-exchangeexecz/mesh_wave_loadspath) and addressed the review notes on the prior head:s_sub_*(counter as SRC1) is refused; only commutatives_add_*keeps that operand order.Draw reference mismatch+ non-zeromismatches=), not a generic non-zero exit.Host:
python3 -B tests/startup_mesh57_loop_check.pyandstartup_mesh57_loop_refusal_check.pyreportokhere. Windows WARP/hardware draw re-run still needed on this head.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T02:40:12Z.
Review: APPROVED
Re-reviewed the current head. The comparison determines signedness, reversed subtraction is refused, and the wrong-trip control requires the intended pixel mismatch. The host loop and scalar-table checks passed. WARP and RTX 4060 Laptop rendered all 1,024 expected pixels and rejected the once-through shader.