Commit Graph

122 Commits

Author SHA1 Message Date
49475796c2 Fix tests the round-39 merges broke
- test_translate: #1904 caps structured depth at 16, so the #1993 dispatch-loop test lowers MAX_STRUCTURED_DEPTH.
- test_ctest_registration: skip-code scan ignores conditional returns.
- test_d3d12_stubs_generation: INCLUDE uses os.pathsep.
- docs/README.md: one Other languages line.
- first_light.py, make_game.py: LF text writes; stdout guard on three tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:31:20 -05:00
1354612b91 Merge pull request #1927 from Tayar 2026-11-22 10:39:30 -05:00
d9f7ec4162 Merge upstream main
# Conflicts:
#	tools/fspx_unpack.py
2026-11-22 10:28:36 -05:00
6a16ac1436 FSPX lookup: a kind-0 state key next to the code key; ambiguous programs are refused (RT-99 review)
Review on #1911: two containers with the same kind-6 program and different kind-0 entries (32x1x1 and 64x1x1)
translate to different modules but got the same fspx_code_sha256, so both resolved to the same pipeline.

- tools/fspx_unpack.py writes the kind-0 entry as fspx/<name>.state; tools/shader_meta.py records its SHA-256 as
  fspx_state_sha256 next to fspx_code_sha256.
- make_game.py: entries with the same code and state keys must have identical modules, otherwise the FSPX step fails
  naming both programs and drops the index. The same code key with other state keys is allowed.
- runtime: a container or bare payload (kinds 0 and 6 present) matches the code key and then the state key; no match
  is E_INVALIDARG. A bare kind-6 program (slot 67, no kind 0) takes the code key's entries when their modules are
  identical, and is refused with E_INVALIDARG and an "ambiguous" log line when they differ.
- Tests: the review case in tests/test_fspx_shaders_stage.py, shader_library_test and d3d12_fspx_compute_test.
- docs/fspx.md: the two keys and the ambiguous case.

On 1.0.2.1 the 29 kind-6 programs are distinct, so nothing resolved wrongly before: 17 translated entries, 17
distinct code keys, 17 distinct (code, state) pairs, all 17 found from the container and from the bare program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:28:07 -05:00
d625f4fd12 make_game: check the RDNA2 wave64 guard before vulkaninfo 2026-11-22 12:22:18 -03:00
2538803660 make_game: reject cached wave64 emulation on AMD Windows RDNA2 2026-11-22 12:05:19 -03:00
7886972a6b Merge upstream main
# Conflicts:
#	docs/d3d12_command_objects.md
2026-11-22 09:48:41 -05:00
754c9f9d25 Merge pull request #1804 from liang-kai-shui 2026-11-22 09:48:20 -05:00
b189efea55 Merge pull request #1758 from sovljanskii 2026-11-22 09:48:10 -05:00
00452cfaa3 Merge pull request #1615 from Ewann 2026-11-22 09:48:04 -05:00
b95bc8fac6 make_game: name an earlier ~/Documents/Leonida build when the Mac default moves
A Mac that built into ~/Documents/Leonida before the default moved to
~/Leonida would start a fresh build and leave its resumable work folder
behind without a word. When that folder exists, the log now says where
it is and how to keep it: move it to ~/Leonida, or pass --out.

The notes come from icloud_default_notes(), tested with a temporary home
folder. From @AGVibecoder's review.

AI-assisted.
2026-11-22 15:41:48 +01:00
ffcc9a4060 rdna2spirv: refuse an incomplete shard set at --merge
--merge globbed index.part*.json and merged whatever was there, so an
interrupted shard run published a partial index.json that make_game.py
takes as a finished translation. Each --shard run now writes a
shard<i>.json marker ({"index": i, "count": n}) beside its part, and
--merge checks that all markers agree and that the parts are exactly
0..n-1 before merging; parts from before the markers fall back to
make_game.py's shards.json plan. make_game drops the markers with the
parts when it re-plans.
2026-11-22 22:39:13 +08:00
c7801ac6fb Merge upstream main
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/README.md
2026-11-22 09:35:55 -05:00
088447e117 FSPX programs: translated by the shaders stage, found at run time by their kind-6 bytes (RT-99)
The FidelityFX DLL creates its compute pipelines from FSPX programs (docs/fspx.md): through slot 67 with the bare
kind-6 program, then through slot 62 with the DXBC container whose ACCC part holds the payload. Both ended in
E_INVALIDARG: the layer took only FSSM bytecode, the build never translated the DLL and the index had no key for it.

- make_game.py: the shaders stage unpacks the package's DLL with tools/fspx_unpack.py --disasm into
  <work>/shaders/fspx and translates it into <work>/shaders/spirv/fspx, with the same wave64 mode and fallback
  flags. The step is redone as a whole when the DLL, its tools, llvm-mc or the flags change (fspx_build.json,
  written last) and never makes the game's shaders run again.
- tools/shader_meta.py: an entry of a program without an FSSM blob gets fspx_code_sha256, the SHA-256 of
  fspx/<name>.code.
- runtime/src/shader_library.h: the library also loads <dir>/fspx/index.json and finds entries by
  fspx_code_sha256. compute_program() takes an FSSM program as before, the kind-6 bytes of an ACCC container or of a
  bare FSPX payload, and a bare kind-6 program recognized by its prologue; the directory is parsed with the DLL
  reader's rules and bounds-checked, so a malformed one is refused.
- create_compute: looks the program up by the key of its kind and uses those bytes as the code base.
- Tests: shader_library_test (parsing, malformed directories, lookup, the fspx folder), d3d12_fspx_compute_test
  (PSOs from both forms, a dispatch each, refused inputs) and tests/test_fspx_shaders_stage.py.
- Docs: the lookup in docs/fspx.md; slots 62 and 67 in d3d12_command_objects.md and d3d12_vulkan.md. The size the
  slot-67 description carries at +0x30 is kind 6's own size, read from the DLL's code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:22:54 -05:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
2fc613a32a Merge pull request #1758 from sovljanskii 2026-11-22 09:15:07 -05:00
2ac20a6622 make_game: keep the default build folder out of iCloud-synced Documents on a Mac
default_out() is ~/Documents/Leonida, and the work folder (hundreds of GB
made from the game) goes under it unless --out/--work are given. With
iCloud Desktop & Documents sync on, macOS keeps ~/Documents in iCloud
Drive: a default build uploaded game-derived files to iCloud, and
"Optimize Mac Storage" can evict work files from the disk mid-build.

On macOS, when iCloud Drive holds a Documents folder
(~/Library/Mobile Documents/com~apple~CloudDocs/Documents), the default
is ~/Leonida instead, and the log says why. Windows and Linux keep
Documents/Leonida; an explicit --out is taken as given.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:57:09 +01:00
9eb822f2ff Merge pull request #1708 from Ash Hopkins 2026-11-22 08:38:37 -05:00
95a89a75d3 make_game: --wave64-emulate auto leaves emulation off on RDNA2 under the AMD Windows driver (#857)
AMD's Windows shader compiler for RDNA2 crashes (access violation in
vkCreateComputePipelines) on many --wave64-emulate compute shaders with LDS
(#857). auto turns emulation on when any device is 32-wide, so an Intel iGPU
next to an RX 6000 card gets emulated modules, and the runtime then runs them on
the RX 6000.

tools/vk_subgroup_info.py now reports vendor_id, device_id, driver_id and
rdna2_amd_windows for the runtime's GPU (RDNA2 by PCI device ID, AMD proprietary
driver). auto leaves emulation off when that GPU is one and runs wave64
natively; on and off are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:15:04 +01:00
2af78ff42d make_game.py: a layered driver's nested deviceName is not another GPU
smallest_max_subgroup splits vulkaninfo's output at each deviceName. Vulkan 1.4 drivers that report
VK_KHR_maintenance7's layered APIs print a second, deeper-indented deviceName for the same GPU (MoltenVK:
the Metal device) before the subgroup block, in both the text and the --json output, so the first "device"
had no maxSubgroupSize and the size read as unknown. Only the least indented deviceName now starts a
device. With MoltenVK 1.4.2 on an Apple M2 Max the auto mode read "unknown"; it now reads 32 (emulation
stays on either way on Apple GPUs, but a layered driver with 64-wide subgroups would have been misread).
New tests with both layouts.

AI-assisted. No game files.
2026-11-22 13:04:16 +00:00
baebfd3568 Merge pull request #1590 from anusara-bemal 2026-11-22 07:38:25 -05:00
114000eadc make_game: export both pools when texture basenames collide
rpf9dump names a pool's output folder after the source basename, so two pools with the same basename in one destination namespace shared a manifest and the second silently produced no DDS. Colliding pools now get a stable per-source export root; unique pools keep their existing folder and are not re-exported.
2026-11-22 17:59:51 +05:30
ce305ec6b3 Translator: wave64 VS/PS/GS on 32-wide subgroups when the halves can't tell (SHADER-10)
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>
2026-11-22 13:03:37 +01:00
ebef9057cb Merge pull request #1448 from EdouardSence 2026-11-22 06:38:06 -05:00
f4e0f706e1 Merge pull request #1407 from Hamza 2026-11-22 06:37:56 -05:00
1681f3dc1e Translator: --f16-interp-fallback reads f16 halves without PerVertexKHR (SHADER-196)
MoltenVK can't compile PerVertexKHR to MSL, so ps_interp_f16_high failed at
pipeline creation on every Mac. With --f16-interp-fallback every VS/mesh param
(and the --mesh-compute VS) also exports its two f16 halves decoded to f32,
low halves at location 29 - 2N and high halves at 30 - 2N, and a PS *_f16 read
takes them as ordinary smooth inputs. A producer skips halves that would land
on its own params; a PS whose half location is also an attribute is rejected.
The index records f16_halves on both sides.

tools/vk_subgroup_info.py reports per_vertex_inputs (false without
fragmentShaderBarycentric or on MoltenVK); make_game.py and run_gpu_tests.py
turn the flag on where it is false. Without the flag all 139 GPU-test modules
are byte-identical to main's, so NVIDIA/AMD keep the exact per-vertex path.

Apple A18 Pro, macOS 26.6.2, MoltenVK 1.4.2: ps_interp_f16_high passes, all
4096 pixels bit-exact; run_gpu_tests.py 84 pass/50 skip/1 fail -> 85/50/0
native, 112/22/1 -> 113/22/0 with wave64 emulation; ms_f16_pack passes through
--mesh-compute. Semantic suite 1194 -> 1203 OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted
2026-11-22 14:32:28 +03:00
e5ab7e512e make_game: decode XMA2 streams with ffmpeg on --jobs threads
decode_xma ran one ffmpeg at a time over every XMA2 stream. It now runs --jobs of them at once (the threads only
wait on their process). ex.map keeps the order, so the failures and the first one reported are the same as before.
2026-11-22 12:30:10 +01:00
302f925cc3 make_game: a redirected console must not kill --find on an un-encodable path
Windows encodes a redirected stdout (make_game.py > build.log) with the console's ANSI code page, and
`python -I` ignores PYTHONUTF8, so when a found dump's path holds a character outside that code page (a
Cyrillic, Greek or CJK user name in the profile it sits under), print() raised UnicodeEncodeError and
--find / auto-discovery ended in a traceback. stderr escapes such characters (backslashreplace); stdout
was strict. cli() now reconfigures stdout with errors="replace", so the listing prints '?' where the
code page has no glyph. Interactive consoles already write Unicode and are unaffected.

The regression test runs the real `make_game.py --find` as a child process over a synthetic dump (empty
probe files with the manifest sizes, no game data) under a private-use character no ANSI code page maps:
fails before the fix on every Windows locale, passes after, and passes on UTF-8 systems either way.
2026-11-22 03:08:37 -08:00
34d3897553 Merge pull request #1356 from Claude 2026-11-22 05:37:54 -05:00
a2d89b0a40 Merge pull request #1351 from jakeefr 2026-11-22 05:37:53 -05:00
afbcfdb709 Merge pull request #1348 from Flyander 2026-11-22 05:37:52 -05:00
080cee9036 Merge pull request #1342 from ICUMADETHIS 2026-11-22 05:37:50 -05:00
1dba48b7b7 audio: start ffmpeg without the caller's stdin
ffmpeg reads stdin for key commands. Every ffmpeg call in tools/audio_wav.py
(audio_digest, decode) and make_game.py (decode_xma) inherited the caller's
stdin, so a run started in the background of a terminal stopped at its first
decode ("Stopped (tty output)"), and input piped to the caller was swallowed.
tests/test_audio_wav.py's own ffmpeg fixture calls did the same: in a
`while read` loop over tests/ with ffmpeg on PATH, they ate the next file
names and four test files were silently skipped.

Give every ffmpeg call stdin=subprocess.DEVNULL, and add fake-ffmpeg tests
that check each call reads nothing from stdin: the decode run and the resume
check of audio_wav.py, and make_game.decode_xma().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQWmXYJ1uVSCTNfvSjPMF7
2026-11-22 10:28:47 +00:00
8abf740a7e [TEST-192] Detect default 64-wide subgroup path 2026-11-22 11:27:17 +01:00
4b63e03b47 make_game: search the real Downloads, Desktop and Documents for the game
find_dumps() built its roots from the home folder only. With OneDrive's Known
Folder Move, Explorer's Desktop and Documents are ~\OneDrive\Desktop and
~\OneDrive\Documents, two levels below the home root, so a copy kept in them
was never found and Build.bat fell back to asking for the folder.

On Windows, add the folders SHGetKnownFolderPath reports for Downloads,
Desktop and Documents (ctypes, standard library) to the search roots. Folders
that aren't moved are the same as the home-folder roots and are visited once.
default_out() is unchanged, so the port and its work folder never land in a
OneDrive-synced folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:24:32 +00:00
3cf44713e9 make_game.py: add --pick to choose the game folder in a folder dialog
Opens the system folder dialog (tkinter, standard library), re-asks until the
folder is a supported version, and fails with a pointer to --game when Tk or a
display is missing or the dialog is cancelled. --pick and --game are exclusive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjctnXX86CYbSh3uZNaNy
2026-11-22 12:12:50 +02:00
204989e9e7 make_game: --jobs reaches the Ogg Opus step; --runtime-build may be the output folder
- assets: awc_opus.py was started without --jobs, so with --jobs 1 the bank export still ran half the CPU count
  of processes (audio_wav.py, the next step, did get it).
- runtime: with --runtime-build pointing at the output folder (a runtime build unpacked where the port goes),
  shutil.copy2 raised SameFileError and the stage stopped before game_path.txt and the launcher were written.
  A file that is already the destination is left as it is.

Tests: one in test_make_game_argparse.py and three in test_make_game_platform.py; one of each fails on the old
code.
2026-11-22 10:00:48 +00:00
779aa4ae80 Merge pull request #1273 from Kevin Morales 2026-11-22 04:37:59 -05:00
a65a039cfd make_game.py: pass the versioned LLVM tools to CMake as full paths
CMake keeps the archiver and resource compiler given on the command line as
bare names (CMAKE_AR=llvm-lib-23), so a build folder configured from a
versioned set still needed those names on PATH: once a static library had to
be archived again, the runtime stage failed. The overrides are now the
resolved paths, so every entry in the cache is absolute.
2026-11-22 02:36:02 -07:00
961792cd8e make_game.py: read the cross-build's tools from CMake's compiler files
CMake keeps a toolchain-chosen compiler in CMakeFiles/<version>/
CMakeCXXCompiler.cmake, not in CMakeCache.txt, so every runtime/build/windows
configured with the plain names went unrecognised: with only a versioned set
left on PATH, preflight passed and the build failed after the long stages.
Preflight now reads the configured tools from those files and requires each
to resolve, else it says to restore them or delete the folder.

The plain names win only when their clang-cl is 19 or newer, so an old default
no longer hides a complete newer versioned set. A mixed set names the missing
versioned tool. The overrides go to every configure until the folder records
its tools, which also covers a folder whose first configure failed.
2026-11-22 02:34:50 -07:00
5e9f17c6b3 make_game.py: accept versioned LLVM tools for the Linux cross-build
Distributions that install LLVM as clang-cl-21, lld-link-21 and so on (Debian,
Ubuntu) were reported as having none of the five tools, so the runtime stage
was dropped or refused. Preflight now accepts the newest full set with one
version suffix and passes it to a new build folder as the toolchain's
CMAKE_<var> overrides (docs/testing.md). A runtime/build/windows whose cached
compiler still exists needs no tools on PATH: it keeps what it was configured
with.
2026-11-22 02:27:17 -07:00
c91b571031 Merge origin/main into build/make-game-translator-flags
Keep both sides: preflight/main() take fallbacks and jobs; argparse mock
asserts fallbacks=() and jobs=6 together.
2026-11-22 01:23:07 -08:00
f5a073213f make_game: forward the translator's fallback flags and record them beside the translation
- `translate()` takes `fallbacks` (the --no-float-controls/--bary-fallback/--texel-offset-fallback/--mesh-compute flags), keeps them in the shard plan, and passes them to every shard; shards finished under other flags restart.
- `shaders()` records the flags in spirv/translator_flags.txt like wave64_emulate.txt and re-translates when they change; `shader_outputs_reusable()` and `preflight()` count a folder with other flags as not reusable.
- New `--no-float-controls`, `--bary-fallback`, `--texel-offset-fallback` and `--mesh-compute` options; `fallback_flags()` maps them in a stable order.
- Tests: 13 new in tests/test_make_game_translator_flags.py (all 13 fail on main 426023a5 as the negative control); mocks in the resume/argparse suites take the new keyword.
2026-11-22 01:19:27 -08:00
cac87b289d Merge pull request #1233 from Nostyxx 2026-11-22 04:07:47 -05:00
342028959a build_llvm_mc: install llvm-mc outside AppData, where the install manager's python can see it
python from the Python install manager (the WindowsApps alias) doesn't see folders other programs create under %LOCALAPPDATA% or %APPDATA%, so the old default made make_game.py report llvm-mc missing and the fuzzers stop with WinError 2 although LLVM_MC named the file. The default -Dest is now %USERPROFILE%\.leonida\llvm-mc, and the preflight explains an LLVM_MC that points into AppData.
2026-11-22 15:39:48 +07:00
273886db50 make_game.py: build the runtime stage on Linux with clang-cl and xwin
Off Windows the runtime stage refused to run without --runtime-build. It now
cross-builds gta6rt.exe and gta6rt_tls_host.dll into runtime/build/windows
with runtime/cmake/clang-cl-xwin.cmake (XWIN_DIR, or ~/.local/share/xwin-sdk
as in docs/testing.md), then packages them with the Wine launcher as before.

Preflight lists what the cross-build lacks (cmake, the LLVM tools, clang-cl
older than 19, an xwin splat without VC/Tools/MSVC or Windows Kits um/x64)
and then configures it, so any toolchain error stops the run before the
shader stage. Without the tools the default stages still leave runtime out;
asking for it lists what is missing. The pipelines stage's vk_pipeline_check
is built natively into runtime/build/linux at the end of preflight, for the
same reason.
2026-11-22 01:36:05 -07:00
8bcf5bb3e2 Merge pull request #1140 from wish131400 2026-11-22 03:14:12 -05:00
23fe0a0c3a Complete BCPack DDS entries during the normal assets export 2026-11-22 16:04:49 +08:00
d8e4df46ff Merge pull request #1090 from Samu3k 2026-11-22 02:09:03 -05:00
16e7591419 runtime: thunk deduplication, XGameRuntime shims, PE loader long paths, and drive-root packaging 2026-11-22 12:19:06 +05:30