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>
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted;
this commit is the resolution only. Build and test repairs follow in their own commits.
Rule of resolution: where both sides added different things, both stay; where both made the same change in two
forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two
changed the same code for different purposes, both purposes are kept.
Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, registry.cpp):
- d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device
routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device
slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the
console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and
list slot 139 (#396).
- Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's
completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is
attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider
pc_resource_desc, S_OK for queue slots past the PC table.
- Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its
undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base
list proxy, its null-view slot 70 and its refusing slot 133.
Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp):
- Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra
cases added; main's --env-slots-74 and #984's --env-slots-70.
- Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy,
the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases.
D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h,
frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp,
d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp,
vk_pipeline_check.cpp, vk_test_device.h):
- Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's
ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's
origin, so both pools run on disjoint sets of textures.
- frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter.
- main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4
stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980).
- shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it.
- Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count
refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it.
Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp,
runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp):
- ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on
ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file.
- gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries.
- Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped.
Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1,
make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py,
runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md,
runtime/README.md):
- Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake.
- rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's
restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped.
- shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags.
- shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants.
One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC
compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A pixel shader that needs derivatives starts with s_wqm_b64 exec, exec, and LLVM branches on wave-uniform conditions
inside that region as it does anywhere: v_cmp_* sN of scalars, s_and_b64 vcc, exec, s[N:N+1], s_cbranch_vccnz.
SHADER-10 took that for no lane vote only while EXEC was the launch mask, so here it was unsafe-vote-branch.
A compare of immediates and scalars is the same in every lane, so its mask is every lane of EXEC or none; the whole
quads of the launch mask have a lane in every 32-lane half that runs (a quad never straddles the halves). The analysis
carries "EXEC is the whole quads of the launch mask" as a dataflow fact, set by s_wqm_b64 exec, exec under the launch
mask and dropped by every other EXEC write. VGPR sources stay refused there, and so does a path on which a scalar was
read out of a uniform VGPR from a lane the launch mask may not have written.
Corpus (1.0.2.1, all 26,503, on top of SHADER-W64-SDST-PAIR): 452 pixel shaders go from tier C to A, none moves the
other way: C 7,741 to 7,289.
Tests: tests/semantic/test_wave64_halves_wqm_uvote.py; GPU fixture ps_w64_a_wqm_uniform_vote (RTX 4070 Ti, 620.70.06).
Co-Authored-By: Claude Fable 5.2 <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.
@shdann: put() dropped the destination's own tag but not a ('vote', r) tag on
SCC naming it. v_cmp into the pair or VCC, s_mov_b64 and s_cselect_b64 don't
write SCC, so s_cbranch_scc0 voted on the old mask while the run side
narrowed EXEC to the new one: false tier A (one 64-lane wave writes v6 in 32
lanes two 32-lane waves skip). put() now drops the SCC vote when it writes
the voted register (or the pair's second SGPR); ops that vote on their own
destination set the new tag after it.
Tests in test_wave64_halves_soundness.py: shdann's three listings are tier
C and diverge 1x64 vs 2x32; an unchanged and a re-voted mask stay tier A
and invariant. docs/design.md SHADER-10 row extended.
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>
Address @Flyander's review comments on PR #1982:
- Propagate wt and rank/base tokens (st['r'], st['b']) across every referenced VGPR >= dst_base on v_movreld_b32/v_movrelsd_b32/v_movrelsd_2_b32/v_swaprel_b32 (and read-side VGPRs >= src_base on v_movrels_b32/relsd/swaprel in step()), so non-zero M0 targets (e.g. M0 = 1) preserve downstream taint into sinks.
- Remove s_andn2_saveexec_b64 and s_andn2_wrexec_b64 from narrows(); keep s_andn1_saveexec_b64 and s_andn1_wrexec_b64 excluded as well because ~S0 & EXEC runs all lanes when S0 == 0, which diverges on 1x64 vs 2x32 behind s_cbranch_vccz.
- Add regression and 1x64-vs-2x32 divergence tests for non-zero M0 v_movreld_b32 (both tainted and clean control) and ANDN1/ANDN2 in vote branches.
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>
A path that does not exist, a folder, a file that is not JSON and a JSON list
each ended in a traceback (FileNotFoundError, PermissionError,
JSONDecodeError, AttributeError), so the census could not say what was wrong
with its input. It now reads and validates the index in main(): one ERROR line
and exit 2, nothing printed to stdout.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- run_gpu_tests.py: #1541's wave64 pixel fixtures (runtime/test/shaders/w64_graphics.py FIXTURES, tiers A-C) are
checked by that runner; run_gpu_tests picked up their .asm and failed 14 of them with "no checker defined".
It now leaves w64_graphics.FIXTURES to that runner.
- d3d12_d24_support_test (#1493): expected DEPTH_STENCIL in FORMAT_SUPPORT for R24G8_TYPELESS. Measured here, the
host D3D12 (RTX 4060 Ti and WARP) reports 0x001010b0 for R24G8_TYPELESS and 0x003110b0 (DEPTH_STENCIL) only for
D24_UNORM_S8_UINT, which #1511's per-format rules follow; the check now expects the bit for the typed format only.
- fma_mix_probe, text_tables, wave64_halves, xdxr_bvh: new tools without #1428's stdout errors='replace' guard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>