Commit Graph

18350 Commits

Author SHA1 Message Date
d51b4f41ff Merge pull request #237 from IAmNotSiob 2026-11-21 17:07:35 -05:00
69e8455e53 Merge pull request #233 from Kam471 2026-11-21 17:07:35 -05:00
69b578eefa Merge pull request #229 from Kam471 2026-11-21 17:07:35 -05:00
b59427776d Merge pull request #225 from Kam471 2026-11-21 17:07:35 -05:00
74863bfa91 Merge pull request #190 from Kam471 2026-11-21 17:07:35 -05:00
cd10e30ac6 Merge pull request #181 from Kam471 2026-11-21 17:07:34 -05:00
d4a44d3fcc Docs/Tests: sync mesh v5 notes in design.md and add NumThreads constant regression test 2026-11-21 14:07:28 -08:00
6440281767 tests/semantic: run OpBitReverse and SAbs in the interpreter, and test bfrev/brev/abs
spirv_mini_interp.py had neither, so the translations of v_bfrev_b32,
s_brev_b32 and s_abs_i32 could not run. OpBitReverse reverses the bits at the
result's width. SAbs wraps the most negative value to itself, as s_abs_i32
does on the hardware.

test_alu_bitrev_abs.py checks v_bfrev_b32 and s_brev_b32 (and that two
reverses give the input back), and s_abs_i32 with its SCC, including
0x80000000. test_interp.py tests both ops directly.
2026-11-21 19:06:11 -03:00
36bc1200ad Runtime: offline xgameruntime shim (XGameRuntime, XSystem, XTaskQueue, XAsync)
Every GDK title calls XGameRuntimeInitialize first and builds its async work on
XTaskQueue/XAsync. Add an xgameruntime.dll shim table for those, ahead of the
executable: XGameRuntimeInitialize/Uninitialize (reference counted),
XSystemGetDeviceType (Series X; LEONIDA_DEVICE_TYPE overrides) and
XSystemGetConsoleId (placeholder), plus the 23 XTaskQueue/XAsync functions.

XTaskQueue/XAsync come from microsoft/libHttpClient (MIT), copied unmodified
into third_party/xtaskqueue (task queue only, no HTTP stack); a small pch.h
stand-in lets them build alone. xgameruntime_test drives the table through
the shim registry the way a title boots. Nothing goes online.
2026-11-21 23:06:10 +01:00
188fb19d0e Tools: CPU differential oracle for the translator (shader_diff.py)
AI-assisted. New runner comparing tools/cpu_ref.py (ISA model, untouched) against rdna2spirv + tests/semantic/spirv_mini_interp.py (translated SPIR-V), bit-exact over seeded straight-line ALU programs.

- tools/shader_diff.py: program table (12 verified vector ALU ops), seed handling, first-mismatch report (case, seed, lane, register, expected/actual bits, last-writer op), counted skips with reasons, exit 0/1/2, --self-test canaries (a passing case, an intentionally wrong expectation that must fail, an unsupported op that must skip).
- tests/test_shader_diff.py: determinism, mismatch + NaN controls, skip accounting, fixed-seed end-to-end run, self-test gate.
- docs/shader_validation.md: harness-design paragraph updated to the shipped tool.

Verified here: 6 pytest green; 400 seeded programs, 0 mismatch, 0 skipped, 0 harness errors; mutation check (blinded comparator) turns 3 tests red; compileall + make_game --help green. Scope is the harness only: no changes to cpu_ref semantics, no GPU needed, runs in standard CI.
2026-11-21 19:05:43 -03:00
58ebeccef0 Tools: export short streamed-music idents by duration 2026-11-21 22:05:28 +00:00
338ff3354b tests: verify closed-region node splitting on random irreducible CFGs and synthetic shaders 2026-11-21 19:05:14 -03:00
ab3b0492f2 cfg_structure: add closed-region node splitting for irreducible CFGs 2026-11-21 19:05:13 -03:00
71c3b0b368 audio_wav.py: give x.ogg and x.opus their own WAV instead of losing one
Both inputs mapped to x.wav (as did x.ogg and x.OPUS on Windows). Two jobs then decoded into the same
x.wav.part.wav at once, and with --jobs 1 the second replaced the first; either way the summary said
"3 WAV written" while one result was gone. output_names now keeps the extension for inputs that share a stem
(x.ogg.wav, x.opus.wav) and adds ~2, ~3 if a name still clashes. Unique names are unchanged, so WAVs from
earlier runs are still found and skipped.

make_game.py is not affected: it runs this tool on awc_opus.py output, which is all .ogg.

Tests: SameStemTest in tests/test_audio_wav.py, with a fake ffmpeg so it runs without ffmpeg installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:05:08 +03:00
ae144b8f79 Allow an explicit Vulkan loader in macOS GPU tests 2026-11-21 15:02:34 -07:00
8200f0523b Docs: link the gamedata XML catalog from the design table 2026-11-21 22:02:24 +00:00
256da65a1b Translator: 10:10:10:2 buffer formats had x and w swapped
GFX10 format names list the channel widths from the top bit, so 2_10_10_10
(50) is R10G10B10A2 and 10_10_10_2 (44) has a 2-bit x. FORMATS read them
from bit 0, which swapped the two for typed buffer loads and stores.

cs_store now writes its R10G10B10A2 word through 50. cs_fmt_1010102 covers
both formats; to run it, buffer_load_format masks a shift that was 32 for
aligned elements, and the test interpreter gains the conversions it needs.
2026-11-22 03:47:22 +05:45
73c99273a8 tests/semantic: run OpIAddCarry in the interpreter, and test the carry chain
spirv_mini_interp.py had OpISubBorrow but no OpIAddCarry, so no carry-out add
(v_add_co_u32, v_add_co_ci_u32, s_add_u32, s_addc_u32) could be run.

test_carry_chain.py checks the result and carry-out of v_add_co_u32,
v_sub_co_u32, v_subrev_co_u32 and their _co_ci forms (e32 through VCC, e64
through SGPRs), and of s_add_u32/s_addc_u32 and s_sub_u32/s_subb_u32 through
SCC, at the carry and borrow boundaries. It also checks the 64-bit add and
subtract built from each pair. test_interp.py tests OpIAddCarry directly.
2026-11-21 19:02:04 -03:00
2765bbfc22 run_gpu_tests: honor LEONIDA_W64_EMULATE via a w64_emulated() helper (cmd.exe leaves a trailing space in 'set VAR=1 &', so the raw == '1' parse drops the flag and mis-sorts the wave64 emulated results on a 32-wide GPU) 2026-11-21 23:01:48 +01:00
3cb99297cd Update checkout action versions in runtime.yml 2026-11-22 01:01:48 +03:00
16586f7239 build_runtime.ps1: the direct MSVC build makes gfx10_descriptors_test and vk_bindless_test
The fallback block (no VS CMake tools) built vk_texture_test when
VULKAN_SDK is set but not the two tests this branch adds. They are built
the same way now: both include their headers by relative path and need no
library.

Not run here: this machine has no MSVC or PowerShell. The two sources
build with MSVC through CMake (reported on the pull request).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 17:01:19 -05:00
058170f6e0 tests/semantic: run integer compares in the interpreter, and test v_cmp/s_cmp
spirv_mini_interp.py had OpULessThan, OpUGreaterThanEqual and a 32-bit
OpSLessThan only, so most v_cmp_* and s_cmp_* translations could not run. It
now has OpULessThanEqual, OpUGreaterThan and the four signed orderings, and
reads a signed operand at the width of its type, so a 64-bit compare is not
cut to 32 bits.

test_int_compares.py checks v_cmp_{eq,ne,lt,le,gt,ge} for u16/i16/u32/i32
(e32 and e64) and u64/i64, s_cmp_{eq,lg,lt,le,gt,ge} for u32/i32, and
s_cmp_{eq,lg}_u64 at sign and width boundaries against Python's own
comparison. test_interp.py tests the new ops directly.
2026-11-21 19:00:46 -03:00
2fecf12124 fssm_header: parse the post-code binding table
Decode the filler, header, 20-byte records and name record after
code_end, and add a --bindings summary. Measured over 26,503 blobs:
5,640,704 records, all parse.
2026-11-21 21:59:15 +00:00
f2d0063282 Refactor CI workflow and update action versions
Updated CI workflow to use specific action versions for checkout and setup-python. Removed viewer-tests job and adjusted steps for consistency.
2026-11-22 00:58:50 +03:00
690e6ee702 manifest.py: report a damaged manifest instead of a traceback; create it atomically
verify read the manifest with json.load(...)["files"] and indexed each entry's "size" and "sha256" directly,
and main caught only OSError. A truncated or malformed manifest therefore ended in a JSONDecodeError, KeyError
or TypeError traceback. load_manifest now checks the JSON, the "files" table and every entry, and raises
ManifestError, which main reports as an ERROR line with exit 2 like a missing file.

create wrote the final manifest in place, so an interrupted run left exactly such a truncated file. It now
writes <out>.partial and swaps it in with os.replace, removing the partial file on any failure; the previous
manifest stays as it was.

The shipped game/xbox-1.0.2.1.json still loads (108 entries).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:58:13 +03:00
d9c0ab5b48 vk_harness: VKH_HEAP on a device without buffer addresses is a SKIP; stricter VKH_SGPRS/VKH_HEAP parsing
A device without bufferDeviceAddress or shaderInt64 now gets "unsupported: ..." and exit 77, which check.py and
run_gpu_tests.py report as SKIP (the same handling as #203), so ps_vcc_x2 doesn't turn into a FAIL there. Words
are decimal or 0x hex only (no octal, sign or spaces), a trailing comma is rejected, and an empty VKH_HEAP is unset.
2026-11-21 23:57:11 +02:00
34f63c6c62 Translator: detect wave64 from 64-bit lane-mask SOP ops (#210)
Shaders that only use s_bcnt1_i32_b64 (and related mask ops) on ordinary
SGPR pairs were translated as wave32. Treat those ops as wave64 markers
and add a GPU test that expects a count of 48.
2026-11-21 18:57:04 -03:00
d5eabdad6a Runtime: CopyDescriptors and CopyDescriptorsSimple on the Vulkan device
A descriptor is the bytes of its heap slot (a TargetView in RTV and DSV
heaps, otherwise what the shader loads), so both are byte copies.
CopyDescriptors walks the destination and source range lists together,
one descriptor at a time; null size arrays mean one descriptor per range,
and whichever side runs out first ends the copy.

Test: d3d12_descriptor_test, through the Xbox-ABI proxy, checks the slots'
bytes for one run, range lists of different shapes on each side, null
size arrays, a destination longer than its source, and null arguments.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 16:56:56 -05:00
69ff8e5c72 Runtime: bindless set 0 (M2)
Set 0 as the translator declares it (docs/design.md, docs/d3d12_vulkan.md
section 5), in runtime/src/vulkan_bindless.h: the twenty bindings with the
array sizes vk_pipeline_check uses, and DescriptorTable (descriptor_table.h)
behind binding 2.

- An image has one index in its dimension (2D, 2D array, 3D, 1D), the same
  in every binding of that dimension. The storage arrays hold 256, so an
  image with a storage view gets an index below 256 and a read-only one
  goes above while there is room.
- Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest
  clamping sampler), because a miss in the table is index 0.
- Changes are queued and written by flush(), one write a slot: a view
  removed before the next flush is never written, so it may be destroyed
  at once.
- insert_key / erase_key change the table; flush() copies it to the buffer,
  into a new and larger one when it has grown. Erasing compacts a probe
  cluster, which moves other keys' entries, and a new buffer rewrites
  binding 2: flush_needs_idle() says when a flush would do either, so the
  owner can make sure no command buffer that uses the set is still running.
- With update after bind the set may be flushed between submissions; with
  partially bound only index 0 is written at creation.

Test: vk_bindless_test, run by runtime/test/shaders/check.py and
scripts/run_gpu_tests.py. ps_tex.asm, a hand-written RDNA2 pixel shader
built by build.py, loads a T# and an S# from a descriptor table and
samples: the translator's own lookup against the table and the set. It
draws the gradient with the T# at the fourth slot probed, the fallback
after the key is erased, the gradient after the table has grown into a new
buffer, another view at the same index and the fallback after removal,
with and without the descriptor-indexing flags; and it adds, removes and
destroys a view before its first flush, which the validation layer reports
if the write is still made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 16:56:56 -05:00
36ace7135e Merge pull request #222 from simonbronk
# Conflicts:
#	docs/design.md
#	tests/semantic/test_alu_perm_alignbit.py
#	tools/rdna2spirv.py
2026-11-21 16:56:10 -05:00
f43bead284 Runtime: GFX10 T#, S# and V# descriptors (encode, decode, Vulkan mappings)
docs/d3d12_vulkan.md section 5.3 asks for a C++ decoder of the structures the
shaders read from descriptor heaps, and section 3.4 for the layer to write them
in Create*View and CreateSampler. runtime/src/gfx10_descriptors.h is that
piece, as a header with no Windows dependency; nothing uses it yet.

- T# (image, 8 dwords), S# (sampler, 4) and V# (buffer, 4): encode from and
  decode to plain structs. Field positions are Mesa's register database
  (src/amd/registers/gfx10-rsrc.json, the gfx103 types), enum values its
  gfx6.json, and what goes where follows ac_descriptors.c and radv. They agree
  with what the translator reads: T# FORMAT at word 1 bits 28:20, the V# base,
  stride, NUM_RECORDS, FORMAT and DST_SEL.
- Only what a Vulkan view or sampler needs is encoded; tiling, compression
  metadata and tuning fields are written as zero and ignored when decoding.
- decode refuses dwords whose TYPE is not an image's (so a V# in a 32-byte heap
  slot is told apart), a reserved DST_SEL, and ranges that end before they
  start.
- Format table: GFX10_FORMAT code <-> VkFormat with each format's channel
  order as a DST_SEL (BGRA8 is 8_8_8_8 read as Z, Y, X, W), the view format for
  a T# on an image, DST_SEL -> VkComponentMapping, S# -> VkSamplerCreateInfo,
  T# type -> VkImageViewType (a cube is a 2D array, as the translator samples
  it).

Tests: gfx10_descriptors_test (ctest, Vulkan headers only): every field alone
at its bit position, round trips, refusals, the T#s cs_imgstore.asm builds,
the V# as the translator reads it, sampler words as radv writes them, the
format table and the mappings. tests/test_gfx10_descriptors.py reads the
table out of the header and checks each code's name against
tools/gfx10_formats.json and each Vulkan format's layout against that name.
Moving FORMAT by one bit, or giving a row another code, fails them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 16:55:55 -05:00
7b7a42bd3a World builder: preserve output when no input models can load 2026-11-21 17:54:33 -04:00
047d4d9b60 Wave64 emulation: guard the chained voted branch, more tests, bench reference
Raise Unsupported when a voted branch's segment was not started by the vote's
own round. New tests cs_w64x_mask_reuse2 (EXEC reuse, read after a store,
half of a mask pair rewritten, chained successor starting with a conflicting
load) and cs_w64x_chain_barrier (chained successor starting with s_barrier),
plus a translation test counting mask exchanges. bench_wave64.py reports a
missing bench line readably and compares against the native AMD output.
design.md: how the rules were confirmed, current GPU counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:52:35 +01:00
cdaef79a7d Wave64 emulation: fewer rounds (reuse mask exchanges, chain voted branches), benchmark
A whole-mask read of a register value already exchanged in the block reuses
the exchange; a block ending in a voted branch runs its successor in the
round that reads the vote. Adds scripts/bench_wave64.py, cs_bench_mix,
VKC_BENCH timing in vk_compute_test and the cs_w64x_mask_reuse test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:52:35 +01:00
c33c216cbd Runtime: implement CheckFeatureSupport for format support, VA limits, and options (D3D-11) 2026-11-21 22:52:10 +01:00
042f665da6 run_gpu_tests: comment names cs_bpermute32 as the other non-wave64 dump
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:52:03 +01:00
87700c04cf Zero disabled source lanes in wave32 ds_bpermute_b32
RDNA ISA 10.4.4: EXEC is honoured for reading the source, so a source lane
that is off reads 0. The wave64 paths did this already; the wave32 path
shuffled the raw value. New GPU test cs_bpermute32 (wave32), wired into
check.py, run_gpu_tests.py and tests/test_shader_checks.py; LDS row of
docs/design.md updated. ds_permute_b32 stays Unsupported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:51:44 +01:00
3fae38a7a1 GPU tests: ms_v5_workgroup expects #209's v5 (group * NumThreads + lane); run_gpu_tests runs #167's ps_texture_sample
#219's checker was written for the older workgroup-index model; on an RTX 4060 Ti lanes 0/1/31 of every
group read 32g, 32g+1, 32g+31, which is #209's model (the game's mesh entry shifts v5 right by 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:51:24 -05:00
58f3fe8f6b GPU tests: run ps_vcc_x2 on the GPU with a seeded V# and heap in vk_harness (TEST-19)
ps_vcc_x2 reads two dwords through the V# in s[0:3], but vk_harness pushed zeros and bound no memory, so on the
GPU it read address 0 and lost the device; run_gpu_tests.py skipped it and check.py left it out. vk_harness now
takes VKH_SGPRS (user SGPRs) and VKH_HEAP (addr=word seeds in a 64 KiB device-address heap, passed as the heap
base, with bufferDeviceAddress and shaderInt64 enabled only then). Both runners give ps_vcc_x2 the V# and words
tests/semantic uses and expect 0x11223344 0x55667788 0 0.
2026-11-21 23:51:16 +02:00
63cd7b8fe6 Docs: record the measured title-keyed stream-id resolution 2026-11-21 21:51:15 +00:00
59fc0da713 fix(xbox): run cs_wavemask under wave64 emulation in run_gpu_tests
SHADER-12: check.py already passes --require-wave64 only when
LEONIDA_W64_EMULATE is not 1. run_gpu_tests.py passed it
unconditionally, so cs_wavemask was skipped on every 32-wide GPU
even when the wave64 emulation path was active.

Mirror check.py: omit the flag under emulation and only apply the
64-wide-subgroup skip/confirmation checks when the flag is set.
2026-11-21 22:50:33 +01:00
49421fe75b README: shader GPU checks now cover 13 GPUs (#166), not one 2026-11-21 22:49:22 +01:00
8cce07b917 shader_disasm.py: scan blobs too short for the header instead of crashing the run
A blob shorter than 0xC4 bytes made code_range read the code offset past the end and raise struct.error. The
error came out of ex.map and stopped the whole run, so make_game.py failed at the same blob on every rerun.
Such a blob now goes to the s_endpgm scan like any other header miss and is counted as "scan failed" or
"no s_endpgm".

--jobs and --limit now must be at least 1 (--jobs 0 made ThreadPoolExecutor raise, --limit -1 dropped the
last file). A source with no .fssm files, or one that doesn't exist, ends with an ERROR line instead of an
IndexError or FileNotFoundError traceback.

Tests: tests/test_shader_disasm.py, with a fake llvm-mc (no GPU, no game data).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:48:43 +03:00
c73e25f4b7 make_game.py on Linux: leave the Windows-only runtime stage out by default, refuse it up front, find the Linux vk_pipeline_check
- Without --stages, runtime (Windows only for now) is left out off Windows.
  Before, the default build ran shaders and assets (hours) and then failed
  in runtime, so pipelines never ran.
- Asked for explicitly off Windows, preflight() refuses it before any work.
- pipelines finds vk_pipeline_check where CMake builds it off Windows
  (runtime/build/linux as in the README, or runtime/build as in
  CONTRIBUTING.md) instead of only vk_pipeline_check.exe, and says how to
  build it when it is missing. Windows is unchanged.
- tests/test_make_game_platform.py (9 tests, 6 fail before this change);
  test_make_game_preflight.py's all-tools test asks for runtime only on
  Windows, since it is now refused elsewhere.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:48:41 +01:00
4776b052d5 check.py: run cs_w64x_partial at subgroup 32 under wave64 emulation (TEST-20)
partial_wave_test always set VKC_SUBGROUP_SIZE=64. With LEONIDA_W64_EMULATE=1 the
shader is translated for any subgroup width, and on AMD, where 64 is available,
the emulated path was never run at 32 (#166, RX 6700 XT entry). Under emulation
it now asks for 32; without emulation it still asks for 64.
2026-11-21 18:48:40 -03:00
e4cacf51fa Translator: keep the buffer_load_format sub-dword merge shift below 32
buffer_load_format_* merges dword 1 above a sub-dword element with
w1 << (32 - bsh) and picks dword 0 when bsh is 0. For every dword-aligned
element, the discarded side shifts by 32, undefined in SPIR-V.
(32 - bsh) & 31 keeps it in range.

tests/semantic/test_buffer_load_format.py runs u32, u32x2/x4, uint8x4,
uint16x2/x4 and f16 loads from interpreter memory. spirv_mini_interp.py learns
the two things the format decode needs: OpConvertUToF/OpConvertSToF and GLSL
FMin/FMax (NaN operands raise UnsupportedConstruct).
2026-11-21 18:46:50 -03:00
7b82460339 Translator: register the mesh NumThreads constant before assembly (#209's v5 seed used it too late)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:46:33 -05:00
56f9e66f60 Tools: add a title-to-stream-id helper for untitled config records 2026-11-21 21:44:48 +00:00
3fc2a44190 hashdict.py: make generated dictionaries reproducible 2026-11-21 22:44:11 +01:00
5c1a1fbb6b Merge main to include the compute Y/Z harness test fix 2026-11-21 22:44:07 +01:00