* scripts, tools: build llvm-mc 23.1.5 by default, so the pipeline library translates
LLVM 21.1.8's gfx1013 decoder cannot decode 840 of the 2,684 compute
programs in the pipeline library of 1.0.2.1: their listings carry 79,490
undecodable words and 8,310 exp invalid_target_N lines, the translator
refuses all of them as "fall-through into undecodable words", and the
shaders stage keeps 1,844 of 2,684. LLVM 21 does translate all 26,503
shaders of shaders.rpf; the library is what it loses.
The same bytes under llvm-mc 23.1.5 have no rejected word in those 840,
and 839 of them translate and pass spirv-val (the last wants s_sethalt,
which the translator does not implement, under either version). The 1,844
that already translated were re-disassembled too: 1,674 listings change
and all 1,674 still translate, the other 170 are byte-identical, so the
stage goes from 1,844/2,684 to 2,683/2,684.
The build helper now builds 23.1.5 by default. The docs that name the
minimum version (README, docs/design.md, docs/testing.md, docs/linux.md)
and the three user-facing messages that still said 21+ (make_game.py's
preflight, shader_disasm.py's probe error, mc_command.py's install hint)
now say 23+, with the tests that assert those texts updated.
AI-assisted (DeepSeek Harness).
Written with an AI assistant.
* docs: LLVM 23 is what the shaders stage needs, and a test pins the script's default
A startup-trace exit event with code 3 no longer hides a title
breakpoint; a device loss still takes precedence when it is the only
explanation, because the breakpoint is its handler.
AI-assisted.
A device-lost line written during teardown no longer renames a clean
guest exit or a time limit. The breakpoint check now looks at every
exception code, normalised for 0x and case, so a later teardown fault
does not hide it. The docstring says the [rt] lines are the C++ runtime's,
not the native Rust runtime's.
AI-assisted.
The summary called a device loss and the title's own int3 both
"process exit 3, no exit event". Use the RUN block's END words: the
runtime's device-lost line becomes "device lost", and exit 3 whose last
exception is 0x80000003 becomes "title breakpoint".
AI-assisted.
test_tool_stdout_encoding.py requires every tool's __main__ to set errors='replace'
on stdout, for a redirected stdout that is a strict ANSI code page under -I. The new
tool did not, so main failed that test on both Linux and Windows.
Same block as ab_control_flow.py and the other tools.
LEONIDA_MESH_AMPLIFY no longer needs a file: indirect/amplify_dxil.rs holds the stage's container (DXC as_6_6,
signed; the tool refuses an unsigned one, which D3D12 would not take), made by the new standard-library tool from
the Windows SDK's dxc or one named. LEONIDA_MESH_AMPLIFY_DXIL=<file> still takes another build of the stage, to
try one. The bytes are the runtime's own shader, not the title's; the file is text and the game-data check passes.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the tool's output is byte for byte the file the
in-game runs d276 to d279 loaded; cargo check with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Testers could not use the gate daily without memory figures, and a memory pile-up took a 3090's Windows
down twice. The parser now reads the runtime's memory line and video memory line (every 5 s in builds with
diagnostics) and writes a memory block: the private bytes at their most and when, the most of them in
physical memory, the least the PC had left to commit and when, the card's video memory in use at its most
and when with the budget then, the seconds over that budget, and the most shared memory in use. The video
memory is what the system counts for the process, so it works on any card. The five runtime strings it reads
join the contract test.
A fuzzed sNaN through v_fmamk_f32 into v_cmp_class_f32 flipped a result
bit on both Vulkan GPUs against the reference model. The model returns a
canonical quiet NaN for v_fmamk_f32, but on gfx1036 under the game's MODE
the hardware mostly returns the NaN source's word and only sometimes
quiets a signalling one (f32_hw_s5.log), so whether the result tests as
signalling or quiet is not something the model can know. Track registers
holding such a computed NaN (st["nanf"], set by v_fmamk_f32 with a
signalling or already-fuzzy NaN operand and propagated through the
pass-through ops and register moves) and raise Uncertain when
v_cmp_class_f32 reads one, instead of reporting a mismatch that is a
model gap, not a translator bug.
Co-Authored-By: Devin <noreply@cognition.ai>
The review of 97535ad found three more OpBitwiseAnd & 0xFFFF sites whose
operand is an %int-derived bitcast feeding a preserve-high-half merge,
the same shape NVIDIA's shader compiler miscompiles:
- v_cvt_i16_f16: OpConvertFToS %int -> Bitcast -> And, then write_lo16
or the op_sel merge (the u16 sibling is %uint and safe)
- v_cvt_norm_i16_f16: the snorm path has the same structure (unorm safe)
- saturate_int16 signed path: SClamp %int -> Bitcast -> And reaches the
preserve merges through the d16 image/buffer stores
All emit OpBitFieldUExtract %uint x, 0, 16 instead, spec-identical.
Audited every remaining And & 0xFFFF site: the rest are %uint-derived,
operand-side, packed-Or consumers, or constant masks.
RTX 4070 SUPER spot-checks of v_cvt_i16_f16/v_cvt_norm_i16_f16 (VOP2
form; llvm-mc rejects op_sel on these) produce the right words on both
the old and new modules, so the bug does not reproduce on this shape;
the extract removes the risky pattern regardless. Full semantic suite:
487 files, 6279 tests, 0 failures.
Co-Authored-By: Devin <noreply@cognition.ai>
NVIDIA's shader compiler (RTX 4070 SUPER, wave32) corrupts the preserved
high half of a 16-bit VOP3 result when OpBitwiseAnd & 0xFFFF consumes a
value that passed through %int ops and the result merges with
(old & 0xFFFF0000): v_add_nc_i16 v14, v3, v12 op_sel:[1,1,0] clamp wrote
0x1113AAA8 for 0x0002AAA8. BitFieldUExtract reads the same low 16 bits
and dodges the peephole; SClamp on %int and select-based clamps do not.
AMD (gfx1036, Vulkan and hw_oracle) and the CPU interpreter are
unaffected.
Co-Authored-By: Devin <noreply@cognition.ai>
VK_FUZZ_SKIP_CRASH treats every vk_compute_test exit outside 0/1/2/77 as a
driver crash skip, including the negative return codes Python uses for signal
deaths on POSIX. Spell that out in the module contract and cover it beside the
Windows access-violation case so exits 1/2 staying fatal is unambiguous.
Co-Authored-By: Devin <noreply@cognition.ai>
Translate with rdna2spirv.py --pc-tail-ubo when LEONIDA_PC_TAIL_UBO asks for it
(the 1/true/yes/on convention image_fuzz, lds_fuzz and valu_fuzz already use), so
the modules fit a device's 128-byte push-constant range; the variable also
reaches vk_compute_test through the inherited environment.
VK_FUZZ_SKIP_CRASH=1 records a vk_compute_test crash (the AMD Windows shader
compiler's access violation and the like) as a per-program skip instead of
aborting the batch; exit 1 (CHECK failures) and 2 (usage errors) stay fatal,
as does every non-zero exit without the variable.
Co-Authored-By: Devin <noreply@cognition.ai>
Restore both depth-compare gather opcodes. Pass the current wave mode when a writelane mask operand checks an already parked lane, matching the slot analysis and the read/write paths.
Refs #1397. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
A lane mask in an SGPR, EXEC or VCC is one wave-wide word on hardware.
The EXEC-coverage gate added earlier in this pull request could not prove
the independent-SGPR restore idioms crosslane_fuzz uses, so it fell back
to this lane's 0 / ~0 bit for exactly the programs the read is meant to
fix. It also encoded the wrong control-flow model: EXEC narrowing is a
per-lane value here, not a SPIR-V edge. Mask-data readers are already
kept out of lane-local `if (active)` runs, and the eager wave-mask store
keeps lowering from moving the subgroup gather into an EXEC-selected
arm, so lanes EXEC has off still contribute their mask bits.
Remove the gate and the CFG EXEC provenance analysis it needed, gather
the mask word for every lane-mask data read, and cover narrowed SGPR and
VCC reads, an independent all-ones SGPR EXEC restore, and the composed
vector-bitwise mask words. The vector-bitwise expectations now check the
uniform mask words and the resulting per-lane cndmask bits and popcounts
rather than the old fallback artifact.
Co-Authored-By: SWE-2.1 Max <noreply@google.com>
Review follow-up on the mask-word gather gate (#1397): `s_mov_b32 s4,
exec_lo` under an unknown EXEC narrowing recorded nothing for s4, so the
later `s_mov_b32 exec_lo, s4` restore minted a fresh ("n", id) tag in
_exec_src_ex. mask_exec_sigs coverage then failed and the read kept this
lane's 0 / ~0 bit, while the equivalent literal `s_mov_b32 exec_lo, -1`
resolved to a constant half-state and gathered — register and literal
restores of the same runtime value disagreed.
_mov_sgpr_vals now returns an ("al", halves) alias for an EXEC source
whose half-state is an unknown narrowing, the same scheme saveexec uses:
exec_lo gives (state, None), exec_hi (None, state), exec gives each half
in its own register for b64 moves. _exec_src_ex already resolves those
aliases, so the restore reproduces the original tag and the gather stays
exact; untracked SGPR sources still mint a fresh narrowing and stay
conservative.
Tests: two semantic cases (wave32 and wave64) assert the register
round-trip gathers OpGroupNonUniformBitwiseOr identically to the literal
-1 restore; cs_exec_copy.asm (+ fixture, check.py/run_gpu_tests.py dump
entries) stores the mask word, exec_lo's own word and the literal-restore
word side by side on real hardware — PASS on RTX 4070 and Radeon
(64-wide), wave64 exec filters 9/9 on AMD.
Co-Authored-By: Devin <noreply@cognition.ai>
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>
A lane mask (EXEC/VCC or a mask-tracked SGPR) that a VALU op reads as a
32-bit value — v_mov_b32 of it into a plain VGPR, or any VALU source
where the mask is data rather than a mask operand — materialized each
lane's own 0 / ~0 bit. Hardware holds the whole wave's mask word there
(tools/crosslane_fuzz.py's op_maskdata model: the uniform word written
to the active lanes), so every lane gets the word, the same in each.
- src_u materializes the wave mask word (lane_mask_word) for SGPR and
EXEC/VCC operands when the instruction's VGPR destination makes the
read a data read (mask_read_is_data); SGPR/EXEC/VCC destinations keep
this lane's bit, which mask_src readers rely on. Mask-holding VGPRs
already store the word, so their reads are plain loads.
- mask_src extracts this lane's bit back out of a mask-holding VGPR
(_vgpr_mask_lane_bit), half-aware in wave64 via mask_half.
- mask_data_src keeps instructions that materialize the word out of
EXEC-gated active runs (a subgroup op can't sit inside if (active)).
- v_readfirstlane_b32 of a mask VGPR broadcasts the first active lane's
copy — the only lane guaranteed fresh after an EXEC-gated v_mov_b32 —
as the word itself into a VGPR destination (VGPR writes are never
mask-tracked), or this lane's bit for a mask-tracked SGPR/special
one; fixes cs_wavemask lanes 48-63.
Found by tools/crosslane_fuzz.py (#293). docs/design.md's whole-wave
mask contract updated.
Co-Authored-By: Devin <noreply@cognition.ai>
The comment still claimed an absent invocation in a partial non-fragment
quad gave an undefined value natively, while the non-fragment branch
reads every lane's activity with OpGroupNonUniformBallot. Wording only.
DOC-QUAD-ANY-PARTIAL.
run.json's dirty leaves untracked files out; a new untracked count says how many there are. The first
second under 2 frames counted from the world's first second, so the arrival's streaming dip was the
run's; it now counts from 60 s in the world, like the median. The longest gap with no frame stays
from the world on: a freeze on pipeline compiles comes right after arrival. The docs say both, and
that world_at_s counts from the gate's start, the precompile included.
tests/test_tool_stdout_encoding.py (on main since this branch started) wants every tool's __main__
block to do it: under -I a redirected stdout is strict in the console's code page.
tests/test_tool_stdout_encoding.py (on main since this branch started) wants every tool's __main__
block to do it: under -I a redirected stdout is strict in the console's code page.
test_docs_repo_paths failed: docs/measuring_fps.md named scripts/game-gate.ps1, which only #2782 adds.
Name the game gate's run folders instead, here and in the tool's docstring.
docs/measuring_fps.md tells how to read an A/B (neighbouring pairs, the
effect with its standard error, ABBA after a throwaway run), but the
scripts it named were never in the repository, and testers' two-run
verdicts turned out to be noise.
`abba` takes runs in the order they ran (folders of scripts/game-gate.ps1
or logs), one value a run (its world median frame time: frames within a
run are not independent), pairs neighbouring runs and gives the mean
difference with its standard error and a 95 % t interval, the median of the
differences and how many agree in sign. It needs at least 4 pairs, as many
with A first as with B first, so a linear drift cancels; with 3 runs a side
it fits the side and a linear trend instead. It says "B faster" or "B
slower" only when the interval leaves 0 out and all pairs but one agree.
Gate runs that did not PASS are left out with their pair.
`phases` does the same inside one LEONIDA_AB run, per switch, for the
median frame time and the `A/B counters` line, leaving out pairs of blocks
whose draws a frame differ by more than a tenth. `plan` prints a balanced
order. Numbers only, never log text.
Testers ran in-game gates and A/Bs by hand on five machines, each with
their own launcher wrapper and log parsers, and lost runs to consoles and
key files. scripts/game-gate.ps1 runs leonida.exe through the checkout's
play-d3d12.ps1 and writes one folder per run: run.json, launch.ps1, the
-DryRun settings, the F1 settings file, the launcher's output (the
precompile lines nobody kept), the runtime's log, events.jsonl and a copy
of the tester's data template (their own saves are never touched). It
stops the game with WM_SYSCOMMAND/SC_CLOSE (the runtime's own end: suspend,
pipeline cache saved) once -WorldSeconds were spent in the world, on a
STOP file or after -MaxMinutes, and kills it only 60 s later; it keeps the
game's exit code. `start` runs the same detached (created through CIM, so
an agent's or console's end does not end it); `stop` asks a run to end.
tools/game_gate.py (standard library) reads the folder into
summary.json (leonida-gate-summary/1): build, card, settings (the run's
settings line, no paths), precompile counts, time to the world (two frame
lines with 500 draws or more, cutscenes included), when the pipeline
cache went warm (60 s with nothing being made), fps from the presents
(median, p5, frame p95, end median, the first second under 2 frames, the
longest gap with no frame), crashes by kind (device lost, panic, fault by
module kind), exit, stop and a verdict: PASS needs 300 s in the world,
no device loss, panic or fault, no gap over 10 s, alive at the stop. The
testers' answers to a draft on the bridge are folded in. Its tests use
synthetic logs and check that the runtime still writes what it reads.
merzleckeier measured it on CachyOS: --skip-existing --jobs 1 left 0 of 3
existing outputs alone, --skip-existing --jobs 2 rewrote 3 of 3. The submit call
passed export_bank four arguments where the serial call passed five, so the
flag never crossed into the pool. The unit test above it calls export_bank
directly - the function, not the CLI - which is why the plumbing was not
covered; the new test runs the tool as a subprocess for --jobs 1 and 2, freezes
an output, and carries its own control (the same command without the flag must
rewrite the frozen file).