Guard all cross-lane subgroup shuffles and broadcasts against unlaunched
lanes, eliminate %uint_0 fallbacks in favor of SubgroupLocalInvocationId,
and add static SPIR-V verifier (check_absent_lane_ub.py), wave-interpreter
unit tests, and a Vulkan GPU validation test.
AI-assisted: Antigravity (Gemini 4 Neon).
- wave64_halves.transfer: the cross-lane branch caught v_cmpx in DPP form and
returned before its EXEC write, so the analysis kept the old EXEC and could
call a value uniform that is not (tier B readlane-uniform instead of C).
It now goes through exec_write, never as a uniform vote.
- restore_skipped_instructions recovers v_cmpx_*_f32_dpp as it does v_cmp_*.
Found by adrianmjim's review of #1647.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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>
Only the elected lane runs the atomic, at its own address. Each 32-lane half
elects its own lane, so with a per-lane address (an untainted pixel coordinate
too) the halves bump different counters and their slots collide:
ps_w64_b_ballot_atomic with the counter offset from y gives {0: 16} for the
wave and {0: 8, 4: 8} with 8 lost slot words for the halves, yet was tier B.
Accept the elected atomic only when each address VGPR is uniform, or was
written by the elected lane from scalars and constants since EXEC last
changed; otherwise tier C elected-lane.
Merges that each passed alone but clash together:
- v_cmp_class_f64: the earlier cmp_class_f64 (685d16ed9) (operand-form checks, test_cmp_class_f64) and the later f64 branch
in cmp_class both handled the opcode; f64 goes to cmp_class_f64 again, f16 stays in cmp_class.
- rdna2spirv CLI tests: spirv-as/spirv-val now run in the output folder with the staging file's bare name, so
the test doubles resolve it against cwd; assemble_spirv decodes the output only when it is bytes. (The doubles
had been writing .spirv-*.tmp files into the repository root.)
- ps_w64 fixtures (TEST-722): an 18th fixture (ps_w64_a_discard) landed; its killed lanes export nothing and
keep the clear value.
- first_light: a run without an OBJ removes mesh.bin, and harness_env reads manifest["files"]; batch_glb's stats
name failures and dropped textures; run_gpu_tests reports a frame never written as a missing readback
(TEST-837).
- make_game TRANSLATION_SOURCES and runtime.yml's paths include spirv_opt.py and report_paths.py (and
wave64_emulate_opt.py), which the translator imports.
Repo rules: stdout guard on six tools; encoding on two opens (gen_gdk_runtime_classes' helper is read_utf8);
newline on one write; anim_skeleton_match's joaat encodes like hashdict.joaat; test_feature_scan's new test is
listed with the others its globals() runner reaches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
operands() sends every op with a NO_DEST prefix to its first branch,
except s_cmp and s_bitcmp. NO_DEST includes v_cmpx, so the later
`elif op.startswith("v_cmpx"): defs.append("exec")` was unreachable:
EXEC was taken as unchanged and the tainted-exec check never ran.
A wave64 VS that narrowed EXEC with a lane-dependent v_cmpx and then
wrote an output was tier A, although one 64-lane wave and two 32-lane
waves give different words for lanes 32..63. The same shader written
as v_cmp plus s_and_b64 exec was already tier C, tainted-exec.
v_cmpx now leaves the first branch, so it reaches the branch that adds
the EXEC def. A v_cmpx on a wave-uniform value stays tier A.
Addresses review findings on PR #2469 (@duudiis):
- Track active-EXEC-only v_readfirstlane_b32 results with ACT_RFL + ('act_rfl', exec_tok):
clears on vector ops while EXEC remains a descendant of exec_tok, and degrades to X
(tier C cross-lane) if read after EXEC restore/widening or in branches/sinks where an
empty-EXEC half's lane-0 fallback would escape.
- Tighten scaled_cnt_token(): for s_lshl_b32 / v_lshlrev_b32 only allow the shifted value
operand (never the shift distance) to carry CNT, and drop v_mul_u32_u24 (24-bit
truncation is nonlinear).
- Add classification and 64-vs-2x32 execution regression tests for all three cases.
- Lower pure scalar-spill VGPRs (touched only by immediate-lane v_writelane_b32 / v_readlane_b32 with non-VGPR source, never aliased by v_movrel*/v_swaprel_b32, never holding a lane mask) to parked scalar slots in rdna2spirv.py, making SGPR spills across lanes 0..63 exact on 32-wide subgroups (tier B lane-spill) while preserving stale-scalar control-dependence and taint propagation.
- Track active-EXEC uniformity (st['ua']) so v_readfirstlane_b32 on a VGPR uniform across all currently active lanes inside a narrowed-EXEC block is recognized as tier B readfirstlane-uniform (resets to full-EXEC uniformity on any non-narrowing EXEC write, restore, or mismatched-EXEC join).
- Fix operand-order handling for global_atomic_*/flat_atomic_*/ds_* atomics and global_store_*/flat_store_*/scratch_store_*/ds_write* sinks, and propagate lane-count tokens through uniform linear stride scaling (s_lshl_b32, s_mul_*, v_lshlrev_b32, v_mul_*) for wave-aggregated atomics.
- Add classification and 64-vs-2x32 wave-interpreter execution tests in tests/semantic/test_wave64_halves.py.
The run side of a pixel kill's early exit was rejected when its first narrowing was
`s_and_saveexec_b64 sN, <wqm mask>` (OFF_OK had only s_mov/s_and/s_wqm), which also left
confine_step's `old_inside or ok(x)` branch unreachable. Allow s_and/s_andn2 _saveexec/_wrexec
while EXEC is not yet inside: their new EXEC is S0 & EXEC or S0 & ~EXEC, so it is inside when S0
is, and the saved old EXEC is not treated as inside. s_or_saveexec first stays tier C, as does a
restore of the saved EXEC.
The design.md row now says the exit may export (an export is not required) and lists every EXEC
write the must-dataflow keeps inside.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wave64 pixel shader that kills pixels with `s_andn2_b64 live, live, exec/vcc` and branches with
`s_cbranch_scc0` to a block that only empties EXEC from that mask, exports and ends was tier C
unsafe-vote-branch. It is exact on 32-wide subgroups: a half whose live mask is empty writes nothing in
the exit and discards its pixels, and in the wave its lanes stay off to the end.
The rule accepts it only when:
- the branch tests the mask's own "not empty": the last SCC writer is a 64-bit logic op into that mask
(or s_cmp_lg_u64 mask, 0) and nothing rewrites the mask before the branch (or vccz/vccnz);
- the exit only sets EXEC from that mask (or 0), exports and ends: no other code, store or successor;
- the run side narrows EXEC into the mask's whole quads before anything but mask arithmetic runs and
keeps it inside on every path, loops included (a must-dataflow over narrowings and copies, unions and
s_wqm of registers known to be inside);
- no `exp ... vm` can run before the vote (a latched vm export would keep the pixels alive in the wave).
Also: s_mov_b64 / s_cselect_b64 of a lane mask no longer tag SCC as a vote on their destination (they
do not write SCC); the branch could take a lane-count compare for a vote and come out tier A.
Tests: classification of the kill (wqm + s_and, v_cmpx + s_mov, direct s_and / s_mov / s_wqm exec,
exit through exec 0, an if/endif after it) and near misses (exit with code, a store, an SGPR write,
another mask, a jump back; a run side that does not narrow or widens again; the mask rewritten after
the vote; SCC = mask == 0; a vm export before the vote; a shared exit), and 64 vs 2x32 vertex runs.
GPU fixture ps_w64_a_discard: RX 580 (RADV, required size 64) and RTX 5070 (32, against the 580
reference) equal the derived words.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generic 64-bit mask path tagged SCC as a vote on the destination of s_mov_b64 and s_cselect_b64, which
write no SCC (s_cselect reads it). With the cmp_eq "empty" polarity that reopened a false tier A, and a
s_mov_b64 between a compare and its branch moved the vote to the wrong mask. They now keep the SCC value
and tag; the other mask logic ops still set SCC = (result != 0).
Tests: the mov / cselect after s_cmp_eq_u64 (classification and 64 vs 2x32 runs).
Found in review by @tupacfan04.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`s_cmp_eq_u64 m, 0` sets SCC when the mask is empty, but it was tagged as the same vote as
`s_cmp_lg_u64 m, 0`, so `s_cbranch_scc1` after it took the empty side for the side the lanes that
vote yes run. A branch that jumps to the narrowing when the mask is empty and skips it otherwise
was tier A, while a half with no lane in the mask empties EXEC and the wave does not (lane 32
writes 35 in the wave and 0 in the halves); the correctly oriented skip was tier C. The cmp_eq
vote now carries an "empty" sense and the branch inverts which side is the yes side.
Also: `s_mov_b64 exec, <mask>` (an EXEC restore) tagged SCC as a vote on EXEC though s_mov writes
no SCC, so a later `s_cbranch_scc*` reading an earlier mask vote was checked as an EXEC skip
(tier A, outputs differ between 64 lanes and two halves). Only `s_or_b64 exec, ...` tags it now.
Tests (wave interpreter, 64 lanes against two halves of 32): the wrong-sense eq branch is tier C
with outputs that differ; the eq skip (both operand orders) and the lg skip are tier A with equal
outputs; the eq branch with scc0 is tier C; the s_mov restore case is tier C with differing outputs.
All four fail without the change; no existing test changed.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rdna2spirv maps a legacy GS's LDS write to an output slot from its
offset alone and drops the VGPR address (the lane's GSVS area), but
wave64_halves read that address as the store's data, so a GS whose lane
id only forms its GSVS base was tier C lane-id. It now checks only the
data operands of a GS ds_write.
w64_graphics.py draws gs_w64_a_ring and gs_w64_c_lane_id at wave64 and
wave32 (RADV_PERFTEST=gewave32), build.py builds gs_* fixtures with
gs_tri's signatures, docs/testing.md explains how to run and extend the
wave64 graphics checks, and docs/design.md records the rule and that the
corpus GS are written for wave64. Checked on an RX 9070 XT (GFX1201) and
a Ryzen 9800X3D iGPU (GFX1036), RADV Mesa 26.3.1: 23/23.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ps_w64_a_permlane, ps_w64_a_swizzle and ps_w64_a_bpermute check v_permlane16/x16, ds_swizzle
(quad-permute, swap, broadcast) and ds_bpermute in a wave64 pixel shader with words that only
depend on the 2x2 quad layout of fragment lanes. They give the derived words on an RTX 5070.
wave64_halves.py called a ds_bpermute/ds_permute whose address comes from the lane id tier C
(lane-id). The id is 0..63 in the wave and 0..31 in a half, equal modulo 32 lanes, and a wave64
permute uses address bits 2..6 of its half only, so an address that is the same modulo 128
bytes reads the same lane. The classifier now tracks that modulus through sums, differences,
bitwise ops with invariant values and left shifts; shifts by less than 2, right shifts and the
low count alone stay tier C. Classification and wave-interpreter tests (64 lanes against two
waves of 32) cover the rule and its near misses.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/wave64_halves.py classifies each wave64 VS/PS/GS by partition
invariance: A exact as translated, B exact by construction (waterfall loops,
wave-aggregated atomics up to slot order, readfirstlane/readlane of values
that are the same in every lane), C not exact (lane counts/ranks/ids,
readlane of varying data, stale scalars behind votes, masks as data, ...).
index.json gets wave64_graphics, wave64_graphics_reasons and
wave64_graphics_idioms; --wave64-graphics warn|error|off (error refuses
tier C). One rewrite: readlane of a proven-uniform VGPR reads the own copy.
--census prints tier counts from an index.json. ps_w64_* fixtures,
w64_graphics.py (fragment subgroup size required 64 vs 32) and semantic
tests; vk_harness gets VKH_HEAP_DUMP and a subgroup-size report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>