Review fixes for the mask-as-data change:
- The wave-mask gather is a group op over the lanes EXEC leaves active,
and drivers differ on whether lanes EXEC has off still vote: NVIDIA,
AMD and KosmicKrisp return the whole subgroup's bits, MoltenVK's
ballot/reduce saw only the lanes a narrowed EXEC left on and produced
the EXEC value instead of the frozen mask word (cs_mask_vgpr_exec).
mask_word_read_ok now gathers only when a CFG must-analysis
(mark_exec_state) proves every lane that can hold a set bit of the
mask is EXEC-active at the read: each EXEC half is tracked as clean,
a constant mask, or an unknown narrowing (s_mov/s_cselect resolve
constants, saved-EXEC aliases and unchanged EXEC, so the common
restore idioms still gather), and mask_exec_sigs records every EXEC
state seen while each mask register held a mask. Unproven reads keep
this lane's 0 / ~0 bit, the pre-change answer.
- Scalar number ops read a lane mask operand as data too
(MASK_NUMBER_READERS, #1043's NUMBER_READERS): s_add_u32 s20, s10, K
after v_cmp wrote s10 yields the wave's mask word, while mask moves
and mask logic ops keep this lane's bit for the saveexec idioms.
- wave64_emulate_opt treats ins["mask_words"] (a mask read that will
gather) as a cross-lane exchange for the lane-local fold planner and
barrier scheduler, covering the scalar readers as well.
- test_slot67_operand_forms' expectedFailure comes off: the packed
vcc_hi word now reaches the data read.
Co-Authored-By: Devin <noreply@cognition.ai>
Conflict in the x_memory_order docstring (tools/rdna2spirv.py): main already
ignores ds_nop (80417b9c4), so the PR's part still new is ordering
image_sample, image_gather4 and image_bvh; its docstring is kept. The PR's
parity test probe gains x_one_lane, which main's Gen.x_memory_order reads.
Co-authored-by: totonii <totonicontato@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three soundness gaps the review reproduced against the round emulation:
- A region that is one block branching back to itself was emitted straight,
so it ran once. It now gets a sub-CFG like a multi-block region and is
emitted as a loop through cfg_structure.structure. This also covers the
read-only self-loop that was already folded before the one-lane rule.
- A write of one half of EXEC (v_cmp_eq_u32_e64 exec_lo, 0, v0) marked EXEC
at most one lane, though the emitter keeps the other half's lanes. A half
write now keeps the fact only when EXEC already had it and the half
written is within it (a compare).
- The short form v_add_co_ci_u32 vD, src0, src1 (also sub, subrev) wrote VCC
only in the emitter. explicit_carry_vcc now gives it its VCC carry-out and
carry-in operands when the listing is read, so every analysis sees the
write, and the emitter's special case is removed.
tests/semantic/test_wave64_one_lane_fold.py adds each case (8 subtests fail
before) and picks in lanes 32-63 of both waves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
A forward must-analysis proves EXEC at most one lane after v_cmp(x)_eq_{i,u}32 <constant>, v0 (v0 the thread id,
not written since entry; the group one row of x or rows of whole waves) and through copies, ANDs and saveexecs of
that mask. Such an s_cbranch_execz region folds with several stores and in a cycle, orders no accesses inside, and
when it writes no EXEC its v_readfirstlane_b32 is the lane's own value. One 1024-thread library compute program:
639 -> 33 OpSwitch cases, spirv-val valid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
plan_structured_emulation gave no plan for any multi-wave program with an s_barrier under a guard or in a loop, which every mesh program has (NGG epilogue). The tail scheduler used from an early s_endpgm on now takes over from that s_barrier on, and what comes before is emitted structured.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block with len(raw_edges[u]) == 1 ending in a conditional branch (no
fallthrough block, so falling through writes %pc = len(blocks) = END)
cannot safely sit inside a folded s_cbranch_execz/nz region whose exit
unconditionally sets %pc = skip.
Reject such blocks during the region walk in find_local_exec_folds
(matching the existing
ot succ[u] check) and add semantic regression
tests covering both s_cbranch_scc1 X and s_cbranch_scc1 skip in
structured and --dispatch-loop --wave64-emulate modes.
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
A conditional branch in the last basic block (no fallthrough block, so
len(raw_edges[b]) == 1) emits OpSelect(%cond, tgt, len(blocks)) and can
leave %pc at either tgt or cfg_structure.END.
Compute exact per-block out_pcs in rdna2spirv._block_out_pcs (matching
wave64_emulate_opt), pass it through capped_tree() into both
cfg_structure.structure() (so single-target fall-off-the-end blocks also
keep their dominated target guard) and unwrap_known_pc_guards(), and
pass compact_out_pcs into cfg_structure.structure() in wave64_emulate_opt.
Add unit and semantic regression tests covering both the loop back-edge
repro reported in review and the non-loop dominated-target variant.
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
cfg_structure.structure() wraps post-dominating join blocks after a diamond or loop in a ('guard', g, ...) node even when %pc == g is tautologically true on every incoming path. wave64_emulate_opt._unwrap_known_pc_guards already unwraps these guards for --wave64-emulate, which is why ms_wave_info_s3 passed on 32-wide NVIDIA GPUs while crashing with 0xC0000005 on native wave64 AMD RDNA2 Windows (driver 24.10.24, LLPC) where blk2's OpControlBarrier stayed trapped inside a conditional OpBranchConditional.
Move unwrap_known_pc_guards into tools/cfg_structure.py (reused by wave64_emulate_opt with zero duplication) and apply it in rdna2spirv.capped_tree() so both assemble() and needs_barrier_rounds() see post-dominating join blocks at top level.
SHADER-STRUCTURED-PC-UNWRAP
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.
Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.
Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.
Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.
No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.
Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
regen_fixtures finds its sources by marker on main, so the two ds_append
sources carry the marker instead of a SHADERS entry. ds_append and
ds_consume join wave64_emulate_opt's always-barrier ops (autogenes-sudo's
fix on #3976): under --wave64-emulate they exchange through a barrier
round, and a guarded one in a multi-wave group hit the translator's assert.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Squash-merged after diff review of PR #6895 - wave64_emulate_opt: cache opcode metadata, fuse liveness/body pass, and precompute superblock dirty transfer
find_local_exec_folds built the region's sub-CFG from edges inside the region only. An s_cbranch_scc0/scc1 (or any branch) from inside the region straight to the join lost that edge, so cfg_structure.structure placed the next block without a %pc guard and emit_folded_region ran it on the exit path too. Edges to the join now go to an exit node that is dropped from the tree. Test and design.md row added. AI-assisted.
Reduces redundant round barriers and OpSwitch cases under --wave64-emulate (Issue #884) via two exact CFG/dataflow passes in tools/wave64_emulate_opt.py: (1) backward SCC liveness skips scc_from_mask/scc_any_half votes when SCC is dead-out; (2) safe lane-local s_cbranch_execz/execnz region folding inlines single-entry/single-exit read-only regions with no cross-lane ops, no barriers, no EXEC-widening, and no live-out scalars behind if (%active) and chains single-predecessor continuations.