Commit Graph

33 Commits

Author SHA1 Message Date
1725e0818a translator: gate mask-word gathers on EXEC coverage; scalar mask number reads
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>
2026-11-30 22:22:13 +00:00
c663c2a85e Merge pull request #2724 from OreoFR/carry/pr-282
reprend #282: fix(rdna2spirv): order image_sample, image_gather4, image_bvh and ignore ds_nop in --wave64-emulate
2026-11-30 17:02:20 +01:00
51445af783 Merge origin/main into carry/pr-282
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>
2026-11-29 17:14:37 +01:00
e7c3366210 Merge origin/main into #1906 (carry prep)
docs/design.md: wave64 emulation row keeps main's barrier text and the PR's s_bitset sentence.

Co-authored-by: Jordan <44410206+JordanWebDev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 09:41:15 +01:00
a78040bb13 Wave64 one-lane fold: loop a one-block self-loop, half EXEC writes, implicit carry VCC
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
2026-11-27 13:39:13 +01:00
18af7e9fa2 wave64_emulate_opt: fold a region at most one lane of the wave runs (SHADER-W64-ONE-LANE-FOLD)
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
2026-11-26 00:53:17 +01:00
84816055d5 wave64_emulate_opt: a guarded s_barrier keeps only the tail in the round scheduler (SHADER-W64-STRUCTURED-SBARRIER-TAIL)
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>
2026-11-25 21:45:21 +01:00
e11c0017ca wave64_emulate_opt: model s_bitset0/1_b32/b64 as read-modify-write and SCC-less (SHADER-W64-EMU-BITSET-RMW) 2026-11-25 09:21:42 -06:00
33431d6fe5 fix(wave64_emulate_opt): refuse exec-fold regions containing a trailing conditional branch
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>
2026-11-25 10:06:01 +02:00
8e5cf5aef1 fix(rdna2spirv): include END in out_pcs for trailing conditional branches
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>
2026-11-25 03:41:00 +02:00
0681b9d280 cfg_structure / rdna2spirv: unwrap tautological %pc guards in structured CFGs (ms_wave_info_s3 AMD LLPC crash)
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>
2026-11-25 03:40:21 +02:00
273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
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>
2026-11-24 11:42:12 -06:00
268389e20d Merge pull request #263 from kotekompotek/contribution/wave64-emulate-barrier-sync
rdna2spirv: wire Wave64 emulate barrier/sync optimization pass
2026-11-23 22:28:16 -05:00
bed6382f78 wave64_emulate_opt: an SGPR pair with one mask half and one constant half counts as a lane mask 2026-11-24 08:38:20 +05:30
1826e88839 fix(rdna2spirv): order image_sample, image_gather4, image_bvh and ignore ds_nop in --wave64-emulate 2026-11-23 20:29:32 -03:00
bef7488733 Merge #3976 into own/slot67
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>
2026-11-23 21:49:07 +00:00
80417b9c4e wave64: align emulate barrier prediction for s_flbit, mixed s_cmp_*_u64, and ds_nop
Fixes three --wave64-emulate AssertionError crashes and sync mismatches:
- tools/wave64_emulate_opt.py (_classify_block_body, _insn_may_barrier): recognize s_flbit_i32_b32 and s_flbit_i32 on lane masks, and s_cmp_eq_u64/s_cmp_lg_u64 on mixed mask+data SGPR pairs via _has_any_lane_mask_word().
- tools/rdna2spirv.py (Gen.x_memory_order): treat ds_nop as a no-op matching NOOPS and wave64_emulate_opt._x_memory_order_access().
- tests/semantic/test_wave64_emulate_opt.py: add FindSMsb to run_emulated_workgroup OpExtInst handler.
- tests/semantic/test_wave64_emulate_barriers.py: add unit and 64/128-thread workgroup interpreter regression tests.
- docs/design.md: document the wave64-emulate barrier alignment rules and CPU verification scope.

Verified locally (CPU only, no GPU/spirv-val/llvm-mc):
- python -I tests/semantic/test_wave64_emulate_barriers.py -> 13/13 OK
- python -I tests/semantic/test_wave64_emulate_opt.py -> 22/22 OK
- pytest -q (12 test files) -> 70 passed

# Conflicts:
#	docs/design.md

# Conflicts:
#	docs/design.md
#	tools/wave64_emulate_opt.py

# Conflicts:
#	tools/wave64_emulate_opt.py
2026-11-23 21:13:20 +05:00
8c22bf40a0 wave64_emulate_opt: cache opcode metadata, fuse liveness/body pass, and precompute superblock dirty transfer (#6895)
Squash-merged after diff review of PR #6895 - wave64_emulate_opt: cache opcode metadata, fuse liveness/body pass, and precompute superblock dirty transfer
2026-11-23 09:45:26 -06:00
0e8c9bc28f wave64_emulate_opt: handle slist operands and src_scc in liveness and mask checks (#5500)
Squash-merged after review of PR #5500 - wave64_emulate_opt: handle slist operands and src_scc in liveness and mask checks
2026-11-23 08:09:39 -06:00
4c17a68fed Merge pull request #4574 from Bloh09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/design.md
2026-11-22 23:16:04 -05:00
8cbd3fbac9 Merge pull request #4392 from leather147
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/design.md
2026-11-22 23:14:19 -05:00
1aa3e384f6 Merge pull request #4300 from DoubleD17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:13:18 -05:00
a54ea0eebf wave64_emulate_opt: keep a folded EXECZ region's exits to the join, so a scalar branch there skips the rest
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.
2026-11-22 18:25:27 -08:00
6214c46850 wave64: synchronize scalar flbit reads of lane masks
AI-assisted (Codex).
2026-11-23 04:11:25 +03:00
7b1836fde8 wave64: keep SCC live for explicit src_scc reads 2026-11-23 00:35:25 +00:00
70e739fd70 wave64_emulate_opt: coalesce hoisted spine guards across early exits and loop headers 2026-11-22 16:28:35 -04:00
1551d2cc36 rdna2spirv: unwrap known-pc spine guards and outline inline x_round setup 2026-11-22 16:01:58 -04:00
496f5e47a4 Merge branch 'perf/wave64-emulate-dead-scc-exec-fold' into perf/wave64-emulate-structured
# Conflicts:
#	docs/design.md
#	tests/semantic/test_wave64_emulate_opt.py
#	tools/rdna2spirv.py
2026-11-22 14:37:04 -04:00
5131dece32 wave64-emulate: track implicit SCC read in s_cmovk_i32 and M0 read in v_movrel/v_swaprel 2026-11-22 12:32:41 -04:00
5ddfd09fc5 wave64-emulate: make transfer_superblock strictly monotone (fix phantom dirty_in clear) 2026-11-22 12:09:22 -04:00
4d9ef4eb27 wave64-emulate: add acyclic single-write folding and structured inline/hybrid emulation (#884) 2026-11-22 11:54:15 -04:00
d93e53178d wave64-emulate: handle reused saveexec pairs and align is_mask_op SCC check 2026-11-22 11:13:00 -04:00
18abefa47b wave64-emulate: elide dead SCC votes and fold safe lane-local execz regions
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.
2026-11-22 10:57:54 -04:00