Commit Graph

4057 Commits

Author SHA1 Message Date
2edbda73e7 translator: quad reads and helper lanes in pixel shaders, from VIctory
On the console whole-quad mode puts a pixel shader's helper lanes in EXEC.
Vulkan keeps a helper active for quad and derivative operations only;
whether it joins a ballot or a shuffle is the driver's choice. Ported from
VIctory, which runs the title:

- DPP quad_perm, a dpp8 whose every lane reads its own quad, and a
  ds_swizzle that stays in the quad (QUAD_PERM, or masks that keep lane
  bits 2-4) are quad operations in a pixel shader (Gen.quad_read:
  OpGroupNonUniformQuadBroadcast / QuadSwap), the source's EXEC bit too,
  so a helper across a triangle edge is read as on hardware (VIctory
  921d8d3b4). They were subgroup shuffles and a ballot.
- v_readfirstlane_b32 in a pixel shader: an active lane that its own
  ballot leaves out (a helper the driver keeps out) takes its own value,
  so a waterfall loop serves it in the first pass (VIctory 060195536;
  without it such loops spun with only helpers left until DEVICE_HUNG).
  An empty ballot read lane 0 before.
- A pixel's discard keeps the killed lane as a helper for the survivors'
  quad reads (VIctory 77053a0c5): Leonida never ends a lane before the end,
  so this held already; the test pins it.

Vertex, geometry and mesh shaders keep their shuffles (no helpers there,
and quad operations would need quadOperationsInAllStages).

spirv_mini_interp.run_workgroup now runs OpGroupNonUniformQuadBroadcast
and QuadSwap, with `helpers` taking part as Vulkan requires.
test_ds_permute's pixel fixture runs whole quads only (a pixel wave holds
whole quads; a lane missing from its quad is a compute shader's case).

Tests: tests/semantic/test_quad_helper_lanes.py with the hand-written
fixtures quad_helper_reads.asm and discard_keeps_helper.asm, run with
helpers a driver leaves out of ballots, votes and shuffles. Contract rows
in docs/design.md. Not GPU-verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 18:32:16 -05:00
82489afecf translator: cap loop iterations per entry (--loop-limit), from VIctory
A loop over data the host has not mirrored yet reads zeros and can run
billions of times; VIctory lost the GPU that way and caps every loop at
128 passes in a pixel shader, 256 in a vertex, geometry or mesh shader and
4096 in a compute shader (victory lower.rs LOOP_LIMIT and count_iteration,
commit 15b0091e8; the per-stage values from 570a941e9). Leonida had no cap.

cfg_structure.loop_counters finds the loops of any graph: each strongly
connected region left after the counted edges of the loops around it are
removed, its counted edges the ones into its entries (the back edges of a
natural loop), its resets the blocks outside with an edge in. Every cycle
has a counted edge, so every loop ends. rdna2spirv keeps one Function
variable per loop; every lane of a wave runs the same blocks, so the lanes'
counters agree (one counter per wave). At the cap a branch back takes its
other way out, and a block with no other way leaves the program: %pc = the
end and %done, and a pixel is discarded at the end (%lc_kill, after the
POPS interlock like every exit). A wave that leaves early is counted done
by the barrier rounds and the wave64 emulation rounds, so it holds no
barrier; under --wave64-emulate such blocks count as an early s_endpgm for
plan_structured_emulation and stay out of lane-local folds.

--loop-limit PS,VS,CS sets the limits (or one N; 0 = no cap, and the output
is byte-identical to before: all 102 fixtures, with and without
--wave64-emulate). index.json records loop_limit and capped_loops for every
module with a loop. Contract row "Loop iteration cap" in docs/design.md.

Tests: tests/semantic/test_loop_limit.py with the hand-written fixtures
loop_limit_back.asm, loop_limit_jump.asm and loop_limit_barrier.asm (the
exported count, the discard at the cap, the dispatch-loop form, the vertex
cap, and a two-wave compute shader whose second wave never leaves its loop
while the first passes s_barrier, in native wave32 barrier rounds and under
--wave64-emulate with one and two waves); tests/test_cfg_structure.py
checks loop_counters on 6,000 random graphs. Not GPU-verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:56:20 -05:00
c2f5bd7780 docs: shader rules to take from VIctory into Leonida's translator
Loop iteration cap, rectangle lists, literal sampler compare, quad ops and
helper lanes, VS-to-PS linking by signature row, per-program wave64
emulation, and the runtime shader lookup's keys and miss path, each with
the VIctory source and the Leonida place it lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:31:55 -05:00
ed5d8570f1 docs: port plan for taking VIctory's fixes into Leonida's runtime
The title's needs in the order it hits them (system calls before the first
frame, the console D3D12 ABI in front of the Vulkan layer, menus, world),
what VIctory does for each and where it lands in Leonida, and where
Leonida's Vulkan design can cut frame time (imported title memory, buffer
device addresses, resizable BAR, asynchronous submission).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:28:27 -05:00
0283d40cb4 runtime: build on MSVC without the Vulkan device; fix SHAPE context sizes
d3d12_xs_device.cpp called rt::d3d12::create_console_descriptor_heap
(slot 14, 3630610ca) without including d3d12_com.h, which exists only with
the Vulkan device (LEONIDA_VULKAN_DEVICE), so gta6rt did not compile
without Vulkan headers. The console path is now built with the Vulkan
device only, and when the helper refuses a host D3D12 device the PC call
makes the heap from the 16-byte desc, as before 3630610ca.

acphal.cpp: SHAPE_XMA_CONTEXT's bit fields fill five dwords and
SHAPE_PCM_CONTEXT's six, so with 10 and 1 reserved dwords the structs
were 60 and 28 bytes and the GDK-size asserts (64, 32) failed on MSVC.
Only the size is used (the stride of the title's context arrays), so the
reserved tails are 11 and 2 dwords.

Tested: gta6rt builds (VS 2022, RelWithDebInfo); gta6rt --dry-run and
--init on the Xbox Series 1.0.2.1 package map and initialise all five
modules; --run stops at the first unimplemented import,
xcrdapi.dll!DStorageGetFactory.

docs/port_status.md: Leonida is the base, VIctory the patch source.
port_ctl.py: shot --small writes a reduced copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:27:46 -05:00
5aec2353db Add VIctory sync and run-control tools; let the pad file press buttons
scripts/sync_victory.py fetches DexNom/VIctory and merges new commits into
victory/ with git subtree pull. scripts/port_ctl.py starts a run with its
logs, captures and saves outside the repository, presses stand-in pad keys
through VICTORY_MOVEMENT_FILE, saves frames through VICTORY_CAPTURE_REQUEST
and reads the frame-rate lines.

The movement file now takes every key of the stand-in pad's table (Enter,
Back, Esc, Tab, the D-pad, shoulders, triggers, stick clicks), so menus can
be driven by a script. Tested with cargo test -p victory-hle --features
diagnostics movement (4 passed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:48:32 -05:00
a8b7ddbd50 Make main's tests green, part 2: docs drift, bvh_slot_check, find_hash_lookup (#10002)
Seven more test files that fail on main at d083a2c, after #9896:

- test_docs_repeated_lines: tests/semantic/README.md's command block is a fenced block, which the check skips;
  its indented form put two lines with the same 40-character opening three lines apart
- test_docs_repo_paths: docs/retail_boot_intel_host.md names #8554's frame-loop notes instead of a path that
  is not in the tree
- test_docs_env_vars: runtime/README.md documents LEONIDA_RNG_SEED (runtime/shims/bcrypt_rng.cpp)
- test_docs_design_rows: docs/README.md gets one row each for strand_grooms.md and ped_catalogues.md (two
  rows each were merged in), and design.md escapes the pipe in `prim_cnt << 12 \| vtx_cnt`
- test_docs_cli_flags: docs/testing.md passes llvm-mc through LLVM_MC, so `brew --prefix` is no longer read as
  a bench_wave64.py flag; pt-PT's quickstart points to the web checker that replaced tools/pc_checker.py
  (5125a01), as README.md does; the spirv-opt passes docs/embedded_shaders.md quotes join FOREIGN
- test_bvh_slot_check: bvh_match.model_geometries() yields six fields since the render bucket was added;
  unpack the two it needs
- test_joaat_agreement (find_hash_lookup's half): hash over the Latin-1 bytes like hashdict.joaat, as #6254 and
  #7820 proposed

Still red, for a separate change: test_joaat_agreement's leonida_mods half (it hashes UTF-8 bytes like
runtime/src/mods.h, so both sides change together), test_f64_conversion and test_f64_output_modifiers (they
expect the output scaling #6314 gated by MODE) and test_bvh_shaders_stage.
2026-11-24 00:28:18 +01:00
7067ff2f2b Merge pull request #5038 from ray3242/fix/i18n-es-quickstart-sync
docs(i18n/es): sync quickstart with current README (issue #4737)
2026-11-24 00:13:34 +01:00
c1f6b5bb52 Merge pull request #3637 from ray3242/devin/1795381635-design-leftovers-2
docs/design: remove the duplicated image-query contract row
2026-11-24 00:12:17 +01:00
e56d97950f Merge pull request #2498 from iasmitionsalvatore/pr/footprint-base-offset
d3d12: GetCopyableFootprints aligns from BaseOffset
2026-11-23 23:47:26 +01:00
bacf6f4e2a Merge remote-tracking branch 'origin/pr/8953' 2026-11-23 17:41:05 -05:00
2c9d676b24 Merge remote-tracking branch 'origin/pr/8957' 2026-11-23 17:41:04 -05:00
a5c9e54bf5 Merge remote-tracking branch 'origin/pr/8982' 2026-11-23 17:40:57 -05:00
e10ec61417 Merge remote-tracking branch 'origin/pr/8987' 2026-11-23 17:40:56 -05:00
d0c0fe437a Merge remote-tracking branch 'origin/pr/8988' 2026-11-23 17:40:56 -05:00
08c750ce7f Merge remote-tracking branch 'origin/pr/8989' 2026-11-23 17:40:56 -05:00
185ed7e319 Merge remote-tracking branch 'origin/pr/8993' 2026-11-23 17:40:55 -05:00
28a7ffd260 Merge remote-tracking branch 'origin/pr/9001' 2026-11-23 17:40:53 -05:00
fecb7797c8 Merge remote-tracking branch 'origin/pr/9003' 2026-11-23 17:40:52 -05:00
a63a7860e5 Merge remote-tracking branch 'origin/pr/9490' 2026-11-23 17:32:52 -05:00
89ca1aa169 Merge remote-tracking branch 'origin/pr/9488' 2026-11-23 17:32:51 -05:00
21714399e8 Merge remote-tracking branch 'origin/pr/9761'
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
2026-11-23 17:30:03 -05:00
f7b3afcda9 Merge remote-tracking branch 'origin/pr/9754'
# Conflicts:
#	scripts/build_runtime.ps1
2026-11-23 17:29:12 -05:00
4fa19c6f78 Merge remote-tracking branch 'origin/pr/9758'
# Conflicts:
#	tests/test_pc_checker.py
#	tools/pc_checker.py
2026-11-23 17:27:57 -05:00
b97d7b85cb Merge remote-tracking branch 'origin/pr/9755'
# Conflicts:
#	docs/README.md
2026-11-23 17:27:49 -05:00
2c8ed2d483 Merge remote-tracking branch 'origin/pr/9741'
# Conflicts:
#	docs/gpu_test_results.md
2026-11-23 17:26:45 -05:00
14cebd5afe Merge remote-tracking branch 'origin/pr/9730'
# Conflicts:
#	docs/gpu_test_results.md
2026-11-23 17:25:59 -05:00
2f6aa6fb5b Merge remote-tracking branch 'origin/pr/9765' 2026-11-23 17:24:53 -05:00
04f6d5245e Merge remote-tracking branch 'origin/pr/9750' 2026-11-23 17:24:49 -05:00
d0707969f0 Merge remote-tracking branch 'origin/pr/9742' 2026-11-23 17:24:47 -05:00
29bd7a11a6 gameinput: the device info has its GameInputLabel members
gameinput_abi.h left out the labels of the public v0 layout. In
GameInputControllerAxisInfo and GameInputControllerButtonInfo a label
sits at offset 4, in what is otherwise padding, so the sizes matched
while isContinuous, restValue, legacyDInputIndex and rawReportIndex were
four bytes early. GameInputGamepadInfo and GameInputUiNavigationInfo are
tables of 14 and 21 labels; they were declared empty, and the pointers
in GameInputDeviceInfo led to one-byte members, so a title reading a
label read whatever followed.

The header declares the enum, the two tables and the two label members
and pins each offset that moved. fill_info gives every control the Xbox
label of its position on every pad, since every pad is presented as an
Xbox One pad.

gameinput_test reads the tables by the public header's byte offsets, so
the shim's own header cannot agree with itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 23:15:46 +01:00
d578b4806e Tests: GPU coverage for ds_wrxchg*_rtn_b64, ds_or_rtn_b64, ds_min_f32 and ds_max_rtn_f32
docs/design.md marks the 64-bit LDS exchanges not GPU-verified, and
cs_lds_atomics_ext.asm (#9494) leaves ds_or_b64 and the f32 min/max
forms out. cs_lds_xchg64_ext.asm runs one lane through
ds_wrxchg_rtn_b64 (both dwords left and the returned pair),
ds_wrxchg2_rtn_b64 at offsets 0/2 (four old and four new dwords),
ds_wrxchg2st64_rtn_b64 at offsets 1/2 (512-byte steps), ds_or_rtn_b64,
ds_min_f32 with a quiet NaN in memory and ds_max_rtn_f32 ordering -0.0
below +0.0. The eight expected words are derived in its header from
the rows. Registered in check.py and run_gpu_tests.py next to
cs_lds_b64_cmpst; the wrxchg row notes the GPU check (the min/max and
bitwise b64 rows get theirs in #9494, to keep the two PRs apart).
2026-11-23 14:09:15 -08:00
98a688ece4 Merge PR #9607 2026-11-23 17:09:05 -05:00
3f2f9e7f66 Update gpu_test_results.md 2026-11-24 00:09:03 +02:00
db333b7fa7 Merge PR #9606 2026-11-23 17:09:03 -05:00
5af8d96693 Merge PR #9603 2026-11-23 17:08:58 -05:00
5125a01f03 Remove pc_checker.py and point to web checker
Removes tools/pc_checker.py and its test, and updates README and
docs/testing.md to link to https://assttro.github.io/can-i-run-leonida/
as a lightweight browser-based alternative.

Closes #9711
2026-11-23 23:08:43 +01:00
508fde4118 Merge PR #9592 2026-11-23 17:08:41 -05:00
bca17fcf82 Merge PR #9590 2026-11-23 17:08:37 -05:00
d0c05fbd6a Merge PR #9584 2026-11-23 17:08:28 -05:00
2cc21a6521 docs: the retail boot on an Intel host with 16 GB, measured (RT-5)
A measurement page in its own file: which stops of docs/retail_boot_chain.md and of #8554's ladder hold on an Intel CPU
with #7111's emulation, the stop that is specific to a 16 GB host (the 6.1 GiB physical-page request against the commit
limit, cleared by #7556), the frame loop to the 900 s timeout with stub pipelines, and what the layer refuses at that
depth, including the console mesh-shader stream subobject. Counts and slot numbers only; no addresses. Plus the
docs/README.md row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLP2cV47KaCDkbmckob
2026-11-23 23:08:14 +01:00
6e9a5463e2 Merge PR #9574 2026-11-23 17:08:10 -05:00
98d99cfca0 Merge PR #9570 2026-11-23 17:08:03 -05:00
ca9f9856bb Merge PR #9569 2026-11-23 17:08:01 -05:00
ad6e5d6bbe gta6rt: --init/--run stop with a clear message on a host without AVX
The game runs AVX code from its TLS callbacks on, so a CPU or OS without
AVX (a QEMU qemu64 guest) died with a bare 0xC000001D. Check CPUID.1
AVX/OSXSAVE and XCR0 YMM state first, print one line and exit 4 (3 is
LEONIDA_UNIMPLEMENTED=stop). --dry-run is unchanged and
LEONIDA_SKIP_CPU_CHECK=1 skips the check.

AI-assisted.
2026-11-23 23:07:51 +01:00
813b8ed6ee Merge PR #9560 2026-11-23 17:07:36 -05:00
2be1e08271 Merge PR #9549 2026-11-23 17:07:14 -05:00
a30edd1ad5 Merge PR #9538 2026-11-23 17:06:58 -05:00
3d1387b3b9 Merge PR #9531 2026-11-23 17:06:48 -05:00
1c4026d554 Merge PR #9527 2026-11-23 17:06:41 -05:00