cmd.exe expands %...% on every line of the generated _build.cmd (twice on a CALL line), and cl.exe rejects a % in the
path-valued /D definitions of the runtime's test targets (D8038) however it is quoted, so a checkout with % in its path
failed in configure, or a few hundred Ninja steps in once the batch was escaped (@ezbyDev's measurements in the original repository).
build_runtime.ps1 now stops before looking for Visual Studio when the checkout path has a %, and build_llvm_mc.ps1 when
-Temp has one, each naming the folder; docs/testing.md gets a Known-problems row. tests/test_build_percent_path.py runs
both scripts with such a path, with git, python and vswhere hidden so that a missing check can't start a real build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge that brought the mirrored pull requests into main (6dece9231) left the DirectStorage shim out, noting
that it "needs the typed-error zlib inflate". The shim's commits (f87d05fdd, ac1843da2, 00551ba00, by
mariuslozo-boop and Kelebek) are ancestors of main, but its files are not in the tree, so the retail
executable's XCRDAPI.dll!DStorageGetFactory import is unimplemented (issue #47, stop 5 of
docs/retail_boot_chain.md).
- shims/dstorage.cpp, shims/dstorage_xs_abi.h, test/dstorage_test.cpp and docs/directstorage.md are back as
those commits left them.
- leonida::zlib_inflate reports why it failed through an optional ZlibError* (header, data, checksum, limit),
which the shim turns into its E_DSTORAGE_ZLIB_* codes. This is the same interface the shim was written
against, added to main's current table-driven inflater; callers that pass no pointer behave as before.
- registry.cpp classes xcrdapi.dll!DStorageGetFactory as an HRESULT import, the retail spelling #47 found
missing.
- CMake and scripts/build_runtime.ps1 build the shim into gta6rt, and CMake builds and registers dstorage_test.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Merged from the TreXito/mangrove copy of the original repository, which carried
contributor pull requests that were never merged here.
Kept: rdna2spirv fixes (ds_append/ds_consume, v_ldexp_f16 under MODE.FP_ROUND,
thread-group SGPR, fma exact), the differential fuzzers (dot, vint, wint, vrel, cvt,
f16misc, salu, mode) with their tests, the exe/import fail-fast and int3 cause tools,
Zen 2 instruction emulation (cpu_emulation.h) and the xapu.dll/chad.dll shims.
Not taken, because they conflict with different implementations already on main:
the D3D12 Xbox-ABI layer, xmem, acphal, loader TLS, f64_diff, DirectStorage (needs the
typed-error zlib inflate), and the copy's own MANGROVE.md and README changes.
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.
xg_xs.cpp (already missing on main), acphal.cpp, xapu_chad.cpp and
d3d12_xs_pso_stream.cpp were in CMake's add_executable(gta6rt) but not in
the fallback's list. pso_stream is called from d3d12_xs_device.cpp (link
error); the others register their shims at startup, so a fallback build
would have run without them. tests/test_build_runtime_fallback.py checks it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/sandbox.py starts runtime/build/vk_sandbox.exe (without it the tool ends at 'unsupported: vk_sandbox is not built'), and tools/ps_sweep.py --exe / tools/ab_control_flow.py --all-attachments start runtime/build/vk_ps_sweep.exe. CMake builds both in its Vulkan tools loop; the fallback built neither, so a fallback build had no harness for either pixel check of translated shaders.
tests/test_build_runtime_fallback.py collects the harness names every Python tool under tools/, scripts/ and runtime/test/shaders/ starts and requires the fallback to build them: vk_sandbox and vk_ps_sweep fail on 5d74c272 and pass with the two cl lines.
The #7516 merge resolution left a stray "`" fragment at the end of the $files
list and dropped its ForEach-Object tail, so PowerShell rejected the script.
Reported by ScarionWorkspace and tugasky on #7154; the parser reports 0 errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The package's XboxBvhBuilder.dll creates 52 console compute programs as
pipelines in its constructor, on the title's thread. Translated, they take
25-60 s to compile on a cold driver cache (#7231/#7049: 31.2 s for one on
an RTX 4080, 59.5 s for all 52 on an RX 9070 XT), longer than the title's
~30 s startup watchdog, so a first boot ends at the builder.
runtime/shims/xbox_bvh_builder.cpp serves the seven exports the executable
imports (measured statically on 1.0.2.1: constructor 1 call site,
destructor 1, Set64BitMortonCodes 8, GetRaytracingAccelerationStructure-
PrebuildInfo 3, BuildRaytracingAccelerationStructureBatched2X 6,
CopyRaytracingAccelerationStructure 2, RehydrateRaytracingAcceleration-
StructureBatched2X 4) with the layer's own XDXR builder (D3D-178). The
loader binds imports to a shim before a bundled module, so the DLL is not
loaded and its programs are never created.
- each BATCHED_DESC2 element (docs/xdxr.md §1) is one layer build with its
postbuild descriptions; the offline-statistics type (0x10), which the DLL
refuses by throwing, skips the element instead (a shim must not throw);
- XDXR stream records and Set64BitMortonCodes tune the console builder's
heuristics and are ignored (logged once);
- prebuild sizes and copies are the layer's;
- the builder's state is kept in a table keyed by `this`: nothing is
written into the title's object, whose size isn't known;
- rehydration answers E_NOTIMPL for now (stage 2);
- LEONIDA_BVH_BUILDER=console keeps the bundled DLL.
xbox_bvh_builder_test (12 checks) calls the exports through the shim
registry as the title binds them; xdxr_bvh.py check-build validates the
BLAS, TLAS and compacted BLAS it builds (0/1000 rays differ on each).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Squash-merged after review of PR #5468 - gta6rt: link with an 8 MB stack; a game thread with the default size had 1 MB for a driver's compiler (RT-400)
XGameEventWrite succeeds and drops the event (LEONIDA_LOG_GAME_EVENTS=1 logs
them). A message or error dialog has no screen: its title, text and buttons go
to the log and it completes with the default button, so an error the game
shows at boot is readable. Other UIs fail before starting. Streaming: never
streamed, no clients, a connection-state token that never fires; per-client
slots answer E_GAMESTREAMING_NOT_INITIALIZED, whose low byte reads false for a
bool caller. Ids and slot order from xgameruntime-docs, signatures from the
GDK reference; two parameter lists marked ASSUMPTION.
xgameruntime_offline_test: 18 checks. ctest 162/162.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GDK title checks its license at boot. QueryApiImpl now serves XStoreImpl
(IXStoreImpl..6, 84 slots from xgameruntime-docs' layout; signatures from
the public GDK reference): the game license is active and not a trial,
package licenses are acquirable and valid, no add-ons, no products, no
package updates; license-changed/lost registrations hand out tokens and
never fire. Purchases, consumables, tokens, downloads and store UIs fail
before starting (E_FAIL, logged once); the undocumented slots answer
E_NOTIMPL.
UNVERIFIED: STORE_SKU_ID_SIZE 18, SKU_ID_SIZE 5, TRIAL_UNIQUE_ID_MAX_SIZE
64 (XStoreGameLicense 104 bytes) - the public pages give no values; to be
confirmed against the executable before a boot relies on them.
xgameruntime_store_test: 22 checks. ctest 161/161.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GDK title opens its save provider at boot; QueryApiImpl now serves
XGameSaveImpl (IXGameSaveImpl..3, 33 slots from xgameruntime-docs' layout,
signatures and error codes from the public GDK reference). Saves are files
in LEONIDA_SAVE_DIR\local-user\<container>\<blob> (default
%LOCALAPPDATA%\Leonida\saves), %-encoded: the layout tools/saves.py import
already writes. Updates are buffered and committed by write-then-rename;
container names follow the documented rule; the 16 MB update limit, the
documented E_GS_* codes, async variants through XAsync, and the
XGameSaveFiles folder/quota slots. Assumptions (quota, blob-name length,
nullptr blob list) are marked in the source and docs.
xgameruntime_gamesave_test drives every slot (50 checks). The two tests that
used XGameSaveImpl's id as "a class not served" now use a made-up id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Serve the Xbox DirectStorage API (IDStorageFactoryX2, IDStorageQueueX2,
IDStorageFileX, IDStorageStatusArrayX) under dstorage_xs.dll, xcrdapi.dll and
dstorage.dll. Declarations are our own (shims/dstorage_xs_abi.h), written from
the public GDK reference; layouts are pinned with static_asserts.
- OpenFile goes through the registry's kernel32!CreateFileW, so GAME: paths use
the console path mapping and the write overlay. GetHandle returns a ReOpenFile
handle with its own file position.
- One worker thread per queue runs submitted entries in order: file and memory
requests, status arrays, ID3D12Fence::Signal, EnqueueSetEvent (on a duplicate
of the title's handle taken at enqueue).
- Auto-submit at half the capacity (or disabled through DSTORAGE_QUEUE_OPTIONS),
enqueue into a full queue waits, CancelRequestsWithTag (a cancelled request is
a success and not a failure), error record and error event, Close and the last
Release drain the queue, IDStorageFileX::Close waits for the file's submitted
reads.
- Request checks: reserved bits, source type, BCPack/swizzle ranges, sizes,
1 GiB limit, null and foreign objects and closed files (also for zero-size
requests), end of file, inaccessible memory.
- zlib, BCPack, swizzle and physical pages return E_NOTIMPL (later PRs).
- Interface ids of the X interfaces are not public: a creating call accepts and
logs a new id per object kind, but refuses system COM ids (IMarshal,
IAgileObject, ...) and the PC DirectStorage ids; QueryInterface accepts only
IUnknown, the PC IDStorageStatusArray id (same shape) and the ids creating
calls accepted for that kind. Bad arguments are logged once per method.
- registry.cpp classifies xcrdapi.dll!DStorageGetFactory as HRESULT; the cl.exe
fallback in build_runtime.ps1 builds the new shim too.
ctest dstorage: 258 checks over synthetic files in %TEMP%, no GPU, no game data.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build_runtime.ps1 and build_llvm_mc.ps1 started the generated batch with
`cmd.exe /c "path"`. cmd.exe drops those quotes when the path holds a
special character such as & or ^, then runs only the part before it, so a
checkout (build_runtime) or -Temp/%TEMP% (build_llvm_mc) in a folder like
`a & b` failed at once with "C:\...\a is not recognized". With /s and a
second pair of quotes, cmd.exe strips only the outer pair.
tests/test_build_batch_launch.py takes each script's launch line as written
and runs it on a stub batch in folders named plain, `a & b`, `a&b`, `x^y`,
`sp (x)` and `東京 & co`: the stub must run and its exit code (0 and 7) must
come back. It also checks that the old form fails there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GDK title links the XUser* functions statically (xgameruntime.lib); each
thunk asks QueryApiImpl for XUserImpl and calls one slot with the function's
arguments after `this` (docs/runtime_imports.md). QueryApiImpl refused the
class, so XUserAddAsync, the call a title makes at boot before nearly
anything else, could not succeed.
runtime/shims/xgameruntime_user.cpp serves it, in its own file so the other
class PRs touching xgameruntime.cpp only meet it at one line:
- ids and slot order from xgameruntime-docs (facts only), signatures, enum
values and E_GAMEUSER_* codes from the public GDK reference;
- IXUserImpl..IXUserImpl6 answer with one 50-slot vtable, IXUserGamertagImpl
(XUserGetGamertag) with a second;
- one offline user, always signed in: XUserAddAsync (silent or not;
AllowGuests with AddDefaultUserSilently is E_INVALIDARG), fixed ids,
FindUserById/ByLocalId, Duplicate/Close/Compare, not a guest, adult, every
privilege, ResolvePrivilegeWithUi, AddByIdWithUi, IsStoreUser, change-event
tokens; gamertag from LEONIDA_GAMERTAG, "Player" otherwise;
- tokens, gamer picture, MSA tokens and resolve-issue fail synchronously
before starting; no sign-out deferral; private and PC-only slots log once.
xgameruntime_user_test (40 checks) drives every served slot; a second ctest
run checks LEONIDA_GAMERTAG.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests/semantic: BaseVertex/BaseInstance read 0 in the wave interpreter; the LDS MockGens follow
SHADER-309 (lds_bound, lds_access, lds_atomic); abs emission tests load their operand, since
SHADER-315 folds scalar ALU on constants.
- test_translate: the dynamic gather sampler is a loaded word, not s16 + 0 (SHADER-315 folds it).
- test_world_build: DDS downscale weights colours by alpha (62804d0d).
- test_fspx_shaders_stage: the fake disassembler writes the listing make_game now checks.
- xgameruntime_test: re-read the package id after clearing the LEONIDA_PACKAGE_ID override.
- docs: one row per topic again in design.md (72 topics) and README.md; one Other languages line;
embedded_shaders.md keeps one copy of each bullet; animation.md links the heading anchor.
- tools/scripts: character_textures uses report_paths.same_report_path; stdout guard on six programs;
LF write in vs_input_survey; the cl.exe fallback compiles winhttp_offline.cpp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without Vulkan headers everything under if(TARGET Vulkan::Headers) is left
out: the D3D12 COM objects, the Vulkan D3D12 device in gta6rt
(LEONIDA_D3D12=vulkan) and most of ctest. The only output was a STATUS line
naming four test tools, so a build whose VULKAN_SDK never reached CMake ran
45 of 125 tests and reported "100% tests passed".
- runtime/cmake/vulkan_headers_missing.cmake: a WARNING that names what is
left out and that CMakeCache.txt keeps the failed lookup.
- LEONIDA_REQUIRE_VULKAN=ON turns it into a configure error; both CI
configures pass it, and scripts/build_runtime.ps1 does when VULKAN_SDK is set.
- tests/test_cmake_vulkan_missing.py runs the module with cmake -P and checks
that CMakeLists.txt and CI use it; docs/testing.md gets a troubleshooting row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main.cpp calls rt::fs::configure (GAME: paths), but the direct-cl.exe
fallback (VS Build Tools without the CMake component) left
shims/file_system.cpp out of the launcher's sources, so gta6rt failed to
link (LNK2019/LNK1120, found by @Ingenioeren). Added to $files.
test_build_runtime_fallback: every .cpp in CMake's add_executable(gta6rt
...) must be in the fallback's launcher list, so the two can't drift apart
again (fails before this change on shims\file_system.cpp).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The package's GDK modules don't import xgameruntime.dll. libHttpClient.GDK.dll and XCurl.dll have no import
entry for it, but both carry the wide string "xgameruntime.dll" and the names InitializeApiImpl[Ex|Ex2],
QueryApiImpl and UninitializeApiImpl next to a statically linked XGameRuntimeInitialize: xgameruntime.lib's
thunks LoadLibraryW the runtime and GetProcAddress those names. Bound to the host, that bypasses the offline
shim. The executable is very likely built the same way.
- library_loader.cpp: LoadLibrary*/GetModuleHandle*/GetProcAddress/FreeLibrary for kernel32, kernelbase and the
api-ms-win-core-libraryloader sets. A module the registry owns (rt::shims::owns_dll) gets a pseudo-handle and
GetProcAddress resolves through the registry; an unserved name is NULL with ERROR_PROC_NOT_FOUND. Every other
module goes to the host.
- xgameruntime.cpp: the five entry points, with the signatures and the unknown-class error documented by
xodus-gaming/xgameruntime-docs (GPL-3.0, facts only). QueryApiImpl logs the class and interface ids and refuses
them, so the first boot with the executable names the COM interfaces to implement.
- xgameruntime_test drives the path through XCurl.dll's api-set binding; docs/runtime_imports.md records the
measurement and the new dry-run counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without VS's "C++ CMake tools" component, build_runtime.ps1 compiles
with cl.exe directly, and that list never built vk_compute_test,
vk_store_test or vk_harness (the programs check.py and run_gpu_tests.py
require and valu_fuzz.py/lds_fuzz.py run), nor vk_image_fuzz
(image_fuzz.py's harness). TEST-71 on that path stopped at
"vk_compute_test not found". Build them the way the fallback builds
vk_texture_test. tests/test_build_runtime_fallback.py checks that the
fallback builds every harness those tools name and that each source it
compiles exists.
Found by @derekhearst.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>