Skip to content

GTA6 Xbox boot progress: ~650 D3D12 calls, first frame submits (draft, integrates #7218 #7286 #7078 #6953 #4348 #4313 #4531 #3390 #6709) - #8134

Closed
trxyazilimgit wants to merge 237 commits into
ProjectLeonida:mainfrom
trxyazilimgit:gta6-xbox-boot-progress
Closed

trxyazilimgit wants to merge 237 commits into
ProjectLeonida:mainfrom
trxyazilimgit:gta6-xbox-boot-progress

Conversation

@trxyazilimgit

Copy link
Copy Markdown

Claimed in the coordination issue as: none — this is a draft progress report from an integration branch, not a claim. Individual fixes can be split into claimed PRs on request.

Depends on: #7218, #7286, #7078, #6953, #4348, #4313, #4531, #3390, #6709

What and why

Draft / progress report — not meant to merge as-is. This branch integrates the open PRs above plus local fixes, and pushes the retail Xbox Series executable (v1.0.2.1) further through boot on a PC through the Vulkan layer.

Where boot gets to: ~650 D3D12 calls (from ~470). The title reaches its main loop and submits its first command lists (queue slot 35). The current stop is in the main thread at RVA 0x4fb0aec. There, a handle-typed wait (0x9796d0 -> 0x4fb0a50) dereferences an object whose vtable reads 0x3b9aca00 (1e9). It is likely a frame-fence or timestamp handle the title expects from an unimplemented queue slot 32 or allocator slot 9.

Local changes. Each is commented in the code with the measured RVA, and anything unmeasured is marked ASSUMPTION.

  • Device slots:
    • 25: console flag bits masked; retried without UAV when the format has no storage support (B5G5R5A1 on NVIDIA).
    • 41: argument type 0x69 created as DISPATCH (assumption).
    • 61: console 0x54-byte sampler description decoded.
    • 74: page pool.
    • 108: GetResourceAllocationInfo1 in Xbox struct-return order.
    • 127: CreateCommittedResource3, with title XMemAlloc budget accounting.
  • Queue slot 18 is GetTimestampFrequency on the console, not GetDesc. This was measured at RVA 0x24841a6. PC GetDesc wrote 16 bytes over the caller's saved RBX, and that caused a crash much later. Queue slot 35 goes through slot 10's path, so probes are dropped and heaps synced (building on d3d12_xs: route command queue slot 35 to ExecuteCommandLists #7286).
  • Slot 133:
    • Buffers at non-page-aligned addresses: the surrounding pages are imported and the buffer is bound at its offset in them.
    • Textures fall back to committed textures; the title's writes do not reach them yet.
  • xg_xs: a linear XG texture computer (XGCreateTextureComputer, XGSuggestSwizzleMode).
  • A8_UNORM beyond a 2D SRV is stored as R8_UNORM.
  • CLZERO is emulated through a vectored exception handler on CPUs without it (Intel).
  • Indirect DispatchMesh through vkCmdDrawMeshTasksIndirect(Count)EXT.
  • Shader library preload thread. The title's ~30 s watchdog fired during lazy loading.
  • XboxBvhBuilder shaders are loaded from spirv/bvh.
  • Startup trace: every thread's stack when the title's watchdog fires, and a register dump on exceptions.

Credit: the integrated PRs' commits keep their authors.

Known gaps:

  • DStorage zlib, BCPack and swizzle
  • FSPX shaders (slot 67)
  • Slot 70 texture views
  • Slot 86
  • Texture data upload from the title's XG layout
  • Queue slot 32 and allocator slot 9
  • PresentX

Tested

  • Hardware: NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.01, on Windows 11 (26200). CPU is an Intel Core Ultra 7 155H, which has no CLZERO.
  • Build: scripts/build_runtime.ps1 -FetchSdl3 passes, tests included.
  • Run: gta6rt with LEONIDA_D3D12=vulkan against a retail v1.0.2.1 dump. Each fix above was checked by the next run getting past the previous stop.
  • Shaders: the shader translator itself is unchanged. The embedded BVH shaders were translated with the existing rdna2spirv --wave64-emulate (52 shaders translated). spirv-val was not re-run separately for this report.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator rule changed.)

jewmaster1337 and others added 30 commits November 22, 2026 21:24
Windows gives the process executable module TLS index 0, and MSVC code built
with /GA reads TEB->ThreadLocalStoragePointer[0] without loading _tls_index.
The loader gave a mapped EXE a gta6rt_tls_host.dll clone's index instead, so a
thread_local int v = 42 EXE built /O2 /GA /MD printed tls_index=6 value=0
under gta6rt --run (natively tls_index=0 value=42).

Index 0 belongs to gta6rt.exe itself (and to each test EXE that links
pe_loader.cpp): measured through _tls_index == 0 before any mapping and the
new tls_index0 trace event. All of its own TLS reads go through _tls_index,
so the first time an executable is mapped the loader loads one more helper
clone (leonida_tls_host_<pid>_home.dll), stops the other threads, swaps
slots 0 and the clone's index on every thread and writes that index into the
owner's _tls_index. Threads started later swap their own slots first thing
in the helper's DLL_THREAD_ATTACH. Both pointers are OS-allocated blocks of
that thread and the OS frees every slot at thread exit, so the swap is
permanent and nothing is restored. The executable then takes slot 0
(kMainImageSlot) through the existing per-thread install, thread events and
~Loader paths; DLLs keep the helper indices. A second executable mapped
while one is live, or a move that cannot be made (a thread kept running in
the owner's code for 250 ms), gets a helper index and a stderr note.

Measured on Windows 11 26300 to make the swap safe: a new thread publishes
its TLS array in the TEB only once it is filled (LdrpAllocateTls), an ending
one clears it before freeing the blocks (LdrpFreeTls), LoadLibrary of a TLS
DLL updates other threads in one NtSetInformationProcess call, and an EXE's
TLS callbacks run after every DllMain for thread attach and detach.

Tests: loader_tls_index0 maps tiny_tls_ga.exe (built /GA, code shape
checked) next to tiny_tls.dll: 42 on the loading thread, a pre-existing
thread and new threads, this EXE's own TLS intact on all of them, two runs
in a row, a second executable at once, and a busy thread holding the move
off. run_tiny_tls_ga runs it under gta6rt --run and --init and checks the
trace names gta6rt.exe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s the EXE's

Fixes from the review of the index-0 change:

- The lazy move at the first executable map stopped other threads and swapped
  their slots, guarded by a "thread is inside gta6rt.exe" check. That is not
  enough: MSVC keeps &ThreadLocalStoragePointer[_tls_index] across calls
  (zlib_inflate saves it at [rbp-80h] across memset, push_back and
  inflate_codes, then reads _Init_thread_epoch through it), so a thread
  stopped in the heap or memset still reads the wrong slot afterwards. The
  move is now rt::reserve_tls_index0(), done once at process start: gta6rt
  calls it from a .CRT$XCT initializer, before its own static initializers
  and before any of its threads; the CRT startup frames above it hold no TLS
  slot address (checked in the disassembly). It swaps slots 0 and home on the
  calling thread only; no thread enumeration, suspension, TEB writes or
  TlsAlloc mark are left.
- The home clone's block was the helper's 514 bytes, smaller than
  gta6rt.exe's 1398-byte TLS. The home clone is now written from
  gta6rt_tls_host.dll with its TLS directory pointed at a new 16 KiB export,
  gta6rt_tls_home_template, filled with a copy of the EXE's template and its
  alignment (LdrpAllocateTls copies End - Start and ignores SizeOfZeroFill,
  so the zero fill is part of the range). Every new thread then has a fresh
  copy of gta6rt.exe's TLS at the home index from its first instruction, so
  no adoption step or window before the helper's DLL_THREAD_ATTACH is left.
  The mapped template is checked against the EXE's after the load.
- The owner is GetModuleHandleW(nullptr) with _tls_index 0, not any module
  whose index reads 0.
- A primary helper without gta6rt_tls_host_set_thread_event is refused.
- An executable that does not get index 0 (no reservation, or another
  executable holds it) is refused by --run and --init with an error; its /GA
  code would read and write another module's TLS through slot 0. The README
  no longer says it "reads the first one's slot 0".
- Thread attach installs every module's copy before any TLS callback runs,
  as Windows allocates all blocks before the first DllMain.
- Tests: loader_tls_index0 (runs) checks this EXE's block moving from slot 0
  to the home index by identity, the home template's size and content, and
  that the getter reads slot 0 with its _tls_index pointing elsewhere (fails
  for a non-/GA build of the fixture); loader_tls_index0_threads reserves
  while threads are being created, with one suspended thread that has no TLS
  array yet and tiny_thread_hook.dll running test code before the helper's
  DLL_THREAD_ATTACH; loader_tls_index0_noreserve maps without the
  reservation. The tiny_tls_ga.cpp comment names the real test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ils cleanly

From the second review of 89cec3b8:

- The first load_tls_host_clone call is now the home clone, from .CRT$XCT,
  and it registered cleanup_tls_clones_at_exit with atexit before
  g_tls_clones was dynamically initialized in .CRT$XCU. The vector's
  destructor then ran first and the cleanup walked a destroyed vector, so
  --dry-run, --init and every return-1 path left the slot clones'
  leonida_tls_host_<pid>_<slot>.dll files in %TEMP%. g_tls_clones is now
  allocated with the first record and never destroyed, and the atexit
  handler is registered there. The home clone cannot be deleted while it is
  mapped (DeleteFileW and a POSIX-semantics delete both fail with
  ERROR_ACCESS_DENIED), so it is left for the next run's sweep, as the
  README says.
- process_alive() took an ended process as alive while another process
  still held a handle to it (CMake's execute_process does), so the next
  run's sweep skipped its files; it now reads the exit code.
- reserve_tls_index0 catches what reserve_index0 throws (for example
  std::filesystem::temp_directory_path) and stores it as the reason, so the
  reservation fails before main with a message instead of ending gta6rt.
  The owner's file name is taken before the move, so nothing can throw
  between the move and recording it.
- Tests: run_tiny_tls_clone_cleanup runs gta6rt --dry-run, --init and
  --dry-run on tiny_tls_clones.exe (three TLS modules, so one slot clone)
  and checks that each run's PID leaves no clone file but its home clone and
  that the next run deletes that one; it fails with the old cleanup.
  run_tiny_tls_ga also runs with TMP and TEMP naming a missing folder: the
  reservation fails, --run and --init refuse the image with the reason and
  run none of it, --dry-run maps it with the note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ry reads

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>
docs/directstorage.md records which DLL and ABI the console title is expected
to use (dstorage_xs.dll medium, xcrdapi.dll and dstorage.dll low confidence),
what is not public (vtable order, interface ids, some constants) and the choice
made for each, what owning the modules shadows at run time, what the shim does
(including the order of its request checks), and what later PRs add (zlib,
BCPack, swizzle, physical pages, GPU-backed destinations, parallel reads).
Index row in docs/README.md; the owned-module list in runtime_imports.md and
the shim list in runtime/README.md name the new modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mit, /EHa under clang-cl

Review fixes for ItsNotRexed#4348 (Flyander, AirKyzzZ):
- DSTORAGE_REQUEST allows a buffer over 32 MiB only with 64 KiB or 2 MiB
  pages, which are not implemented yet, so such a request now fails with
  E_DSTORAGE_REQUEST_TOO_LARGE before any memory is touched.
- TotalRequestCount and the byte totals grow when a request is submitted,
  not when it is enqueued, and PendingRequestCount counts the request the
  worker is processing (DSTORAGE_PRIORITY_STATS).
- dstorage.cpp is built with /EHa under clang-cl, so guarded_move's __try
  catches an access violation in a title's buffer there too.

Tests: an over-limit and an at-limit 32 MiB copy, and stats checked
before Submit and while a copy is held on a guard page. The three new
failing checks fail with the previous shim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c and a title's VirtualAlloc

The console's allocation type picks the page size with bits the host reads
differently: 0x20000000 (2 MiB) is the host's MEM_LARGE_PAGES, which needs
SeLockMemoryPrivilege, 0x80000000 (4 MiB) is rejected, and 0x20400000 (64 KiB)
becomes MEM_LARGE_PAGES | MEM_PHYSICAL. XMemVirtualAlloc failed the 2 MiB mode
and rejected 4 MiB, and the title VirtualAlloc shim forwarded all three.

Both now share one path: the bits are decoded (other combinations stay
ERROR_INVALID_PARAMETER), never forwarded, and every page size is served from
ordinary host pages with the base aligned to the page size (VirtualAlloc2 with
an alignment requirement, else a reserve/release/reserve probe with retry),
sizes and addresses rounded to whole pages, and one host allocation per
region so VirtualFree and VirtualQuery match what was returned. A title's
VirtualAlloc still needs an operation; nonzero XMem attribute words still
fail with ERROR_NOT_SUPPORTED.

Page-size values as read in OpenScarlett (MIT, kernelx_abi.h, xmemory.cpp) and
omonkeyz/xbox-emulator (GPL-3.0-or-later, crates/compat/xmem/src/virt.rs); the
probe fallback follows xbox-emulator's reserve_aligned (sys.rs).

xmem_test gains 2 MiB / 4 MiB / 64 KiB cases for both entry points (24 of 104
checks fail on main; 146/146 pass here), and xmem_probe reruns it with
LEONIDA_XMEM_NO_VIRTUALALLOC2 set to cover the fallback.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libHttpClient.GDK.dll and XCurl.dll reach the GDK runtime through
xgameruntime.lib's thunks: LoadLibraryW("xgameruntime.dll"), then
GetProcAddress of InitializeApiImpl, InitializeApiImplEx,
InitializeApiImplEx2, QueryApiImpl, UninitializeApiImpl and XErrorReport.
The shims served only the first five. Without XErrorReport the thunks
refuse the runtime before they call any initializer: under gta6rt --run,
HCInitialize returned 0x89240101 (E_GAMERUNTIME_DLL_NOT_FOUND) and
curl_global_init returned CURLE_FAILED_INIT.

XErrorReport is now served by the function behind IXErrorImpl slot 3, so
a report reaches the XErrorSetCallback callback either way.
xgameruntime_test and the tiny_gdk_load fixture check all six names and
that a report through the export reaches the callback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only handle the observed reserve-only access and protection pairs. Retain host reservation state, granularity and CPU protection. AI-assisted.
# Conflicts:
#	docs/runtime_imports.md
…e PC vtable refuse with E_NOTIMPL

The retail title calls device slot 133, past the 128-entry table; the call read an empty entry and jumped to 0.
Every slot beyond the PC device's vtable now reaches the generic thunk. Mock test covers slot 133.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	runtime/shims/xmem.cpp
#	runtime/test/xmem_test.cpp
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/README.md
#	runtime/src/pe_loader.cpp
# Conflicts:
#	docs/README.md
#	runtime/CMakeLists.txt
…/d16, buffer_store_byte/short) (ItsNotRexed#1864)

Squash-merged after diff review of PR ItsNotRexed#1864
…ory (VK_EXT_external_memory_host)

The retail executable opens the 64 KiB graphics region it has just committed with XMemVirtualAlloc
through device slot 48 right after its first queue and fence; the layer answered E_NOTIMPL and the
title asserted.

The call now answers as the host runtime does on an RTX 4090 and WARP (six cases measured in
d3d12_existing_heap_test): the base of a VirtualAlloc allocation committed read-write over its whole
size opens a heap of that size, 64 KiB aligned, CUSTOM / WRITE_BACK / L0, SHARED |
SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS; an inner address, a partial or reserve-only commit
and a read-only range are E_INVALIDARG. The backing is the range itself, imported with
VK_EXT_external_memory_host, which the device and the test device enable when present.
CheckFeatureSupport(EXISTING_HEAPS) follows the extension. Placed resources in such a heap are
refused (E_NOTIMPL, logged) until the placed path addresses memory outside the arena.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unaligned title-placed buffers, exception registers

Queue slot 35 routed to ExecuteCommandLists following PR ItsNotRexed#7286.

Co-Authored-By: Vadson159 <vad.sofr@gmail.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01LcK6MEZaGkvjgvEZjGx5v2
… the fence proxy); crash dumps for the handle wait

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01LcK6MEZaGkvjgvEZjGx5v2
@Ryx69

Ryx69 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested c77a4fa27 with my own 1.0.2.1 copy on an NVIDIA GeForce RTX 5060 Ti (desktop, driver 32.0.16.2124), Windows 11 (build 26300), MSVC 14.44 RelWithDebInfo, LEONIDA_D3D12=vulkan. Shaders came from make_game.py --stages shaders: 26,573 translated, every shard spirv-val clean, and the 52 XboxBvhBuilder.dll programs in spirv/bvh.

It reproduces your stop exactly. The title gets into the main loop, reaches queue slot 35 (ExecuteCommandLists #1 and #2 with the probe lists dropped), and then reads 0x3b9aca60 at game_scarlett_master.exe+0x4fb0aec. The stack above it is +0x4fb0ac4, +0x23cf363, +0x23cf104, +0x2215eca. So the stop isn't specific to the 4060 Laptop or to Intel.

Along the way, 42 slot 67 (FSPX) pipelines fail with E_INVALIDARG because there's no translated compute shader for their kind-6/kind-0 hash. That's your known gap, measured here too. No swapchain is created before the stop.

AI-assisted.

@jeremygold02

Copy link
Copy Markdown
Contributor

I tested the slot-8 copy in c77a4fa2 against the source pitches and ordering in the 1.0.2.1 upload caller. Statically, that caller keeps a common destination base and plane zero, walks all mips of one array slice at a time, and passes consecutive source levels plus separate row and slice pitches. For a volume it calls once per mip and advances over that mip's shrinking depth.

Original input Compact source row pitches by mip Result against the candidate's linear destination
7×5 RGBA8, two slices 28, 12, 4 bytes 6/6 copies matched
9×5 BC1, two slices 24, 8, 8 bytes 6/6 copies matched
7×5×3 RGBA8 volume 28, 12 bytes 2/2 copies matched

The fixture compared all 196,608 destination bytes, including padding, for 908 bytes of generated input. Swapping only the first-mip source pointers between the two RGBA8 array slices still returned six successes and failed the pixel-byte comparison. On merged main dfe4e4ad, the 14 positive calls returned E_NOTIMPL and preserved every destination byte.

The test goes through the registered exports and vtable slot 8. It requires only the original fixture. From a configured Windows build of the verification commit, run cmake --build <build> --config RelWithDebInfo --target xg_linear_upload_test and ctest --test-dir <build> -C RelWithDebInfo -R "^xg_linear_upload$" -V. The destination offsets are specific to this PR's linear model. Whether the title's resulting bytes reach the sampled image is still open. Fixture and CTest target

Windows 11, MSVC 19.44, Intel Core Ultra 7 265K. GeForce RTX 5070, driver 621.01, idle. The comparison runs peaked at 2.2 MiB per test process. AI-assisted by GPT-6.2 Astra.

@JuniorBoschet

Copy link
Copy Markdown

Ran this branch (head c77a4fa27) on another NVIDIA card, in case it helps compare.

On: Windows 11, MSVC (VS 2022 Build Tools), NVIDIA GeForce RTX 3060, driver 32.0.16.2124, Vulkan SDK 1.4.363.0. Retail v1.0.2.1 package. LEONIDA_D3D12=vulkan, LEONIDA_SHADERS=<work>/shaders/spirv (26,555 translated shaders), with <work>/shaders/spirv/bvh built as docs/embedded_shaders.md describes (52 XboxBvhBuilder programs, 52 translated with --wave64-emulate, 52 pass spirv-val).

Result: the boot does not reach the main loop here. It gets through device creation, slots 25, 26, 41, 61, 74, 127 (the XMemAlloc budget accounting logs its first 33,423,360 B lease) and 133 (a buffer on the title's pages), the first RTV and slot 16, then slot 62 (the BVH builder's first compute pipeline) right after the shader index loads. About 33 s into the run the title's watchdog fires: your trace dumps 47 thread stacks, the title's main thread is in a wait inside its own code (not in the runtime), and no thread is inside gta6rt.exe at that moment. The process then ends with a null write in the title. No ExecuteCommandLists / queue slot 35 line is printed before it.

So on this machine the stop is the ~30 s watchdog during the BVH builder's pipeline creation (or what the main thread waits on right after it), before the first submit. I have not split the 33 s between loading the shader index, compiling the 52 BVH pipelines on the NVIDIA driver, and the wait itself; happy to rerun with a switch or a timing log if you point me to one.

One thing I hit setting it up: if VULKAN_SDK is not in the environment when CMake configures, the build silently leaves the Vulkan device out (only a CMake warning), and LEONIDA_D3D12=vulkan then runs on the PC D3D12 device, which stops much earlier. Worth checking on anyone's report that D3D12XboxCreateDevice says "Vulkan device" and not "PC ID3D12Device".

(AI-assisted run and write-up, Claude Code.)

@trxyazilimgit

Copy link
Copy Markdown
Author

Thanks all — very useful.

@Ryx69 thanks for reproducing. That stop is fixed in 5119d85: console queue slots 16–20 sit two past the PC's (16 Signal, 17 Wait, 18 GetTimestampFrequency, 19 GetClockCalibration, 20 GetDesc → PC 14–18). The title calls slot 16 with (fence, 1) from RVA 0x248260e; forwarding it to PC GetTimestampFrequency wrote 1e9 over the fence proxy's vtable, which is the 0x3b9aca60 read. Boot now goes a few calls further and stops at +0x4fb0b03 reading 0x80004001 (an E_NOTIMPL from a still-unsupported slot used as a pointer) — investigating.

@jeremygold02 thanks for the XG upload fixture. Happy to pull df0547c into this branch with your authorship if you're OK with that.

@JuniorBoschet the 30 s watchdog during the BVH pipelines is what I hit before seeding the Vulkan pipeline cache; I should have written it down. Build a seed once and place it next to gta6rt.exe:
vk_pipeline_check.exe /shaders/spirv/bvh /pipeline_cache.bin
The runtime reads pipeline_cache.bin beside gta6rt.exe as a read-only seed, so the NVIDIA compile no longer happens inside the watchdog window. The shader-library preload thread in this branch covers the lazy index load. And good point on VULKAN_SDK — I'll add that check to the description.

@Th3drata

Copy link
Copy Markdown

Nice catch on the slots shift! The new crash at +0x4fb0b03 reading 0x80004001 (E_NOTIMPL) is likely queue slot 32 (PresentX on the newer console layout, shift +2 per #2490).

In child_slot:
Any queue slot >= 19 falls into the Fwd >= self->slot_count check and returns hr_to_u64(E_NOTIMPL). The game calls slot 32 right after the queue submits, expecting an HRESULT S_OK (or dereferencing the return handle), and dereferencing RAX 0x80004001 causes the access violation at +0x4fb0b03.

We already prepared and tested the stub for slot 32 on our fork:

if constexpr (K == ChildKind::queue && Slot == 32) {
    static std::atomic<std::uint64_t> presents{0};
    const std::uint64_t n = presents.fetch_add(1, std::memory_order_relaxed) + 1;
    if (n <= 4 || n % 1000 == 0) {
        std::fprintf(stderr, "[rt] d3d12_xs: queue slot 32 (PresentX) #%llu: count=%u planes=0x%llx params=0x%llx; S_OK stub\n",
                     static_cast<unsigned long long>(n), static_cast<unsigned>(a1),
                     static_cast<unsigned long long>(a2), static_cast<unsigned long long>(a3));
    }
    return S_OK;
}

Available on branch: https://github.com/Th3drata/Leonida/tree/pr-8134-queue-layout (commit 431a45c94). Feel free to cherry-pick or pull!

@jeremygold02

Copy link
Copy Markdown
Contributor

Yes, please cherry-pick df0547c2 with its existing authorship. I applied it cleanly to your updated head 5119d85cd and reran ctest -R "^xg_linear_upload$" -V. All 14 generated uploads matched their full destinations, including padding. Swapping the two array-slice sources produced the expected mismatch even though all six copy calls succeeded. Fixture commit

Windows 11, MSVC 19.44 RelWithDebInfo, Intel Core Ultra 7 265K. CPU-only test. RTX 5070, driver 621.01, idle. AI-assisted.

@trxyazilimgit

Copy link
Copy Markdown
Author

Thanks @Th3drata! In my traces the 0x80004001 at +0x4fb0b03 comes from fence slot 12, not queue slot 32: the call right before it is call [rax+0x60] at +0x4fb0aec on the fence from device slot 36 (vtable+0x60 = fence slot 12), and the log shows "fence slot 12 is beyond the PC fence vtable ... returning E_NOTIMPL" at that moment. The title dereferences the result and compares it with the target value over 56 bits, so fence slot 12 returns the address of the fence's completed value. d5d46701a implements it (a polled cell per fence), and the title then reaches its third ExecuteCommandLists (second frame loop).

Queue slot 32 is still unsupported (called with (1, ptr, ptr, 3)), but its E_NOTIMPL didn't stop the boot here; I'd rather measure what it is before stubbing it as PresentX. Happy to take your stub once we know its arguments.

@Th3drata

Copy link
Copy Markdown

Correction to my comment above: the slot 32 stub was not tested, only written. Your fence slot 12 diagnosis is the right one — sorry for the noise.

@rideinstead

Copy link
Copy Markdown

⚠️ Automated security review: NOTES (commit c77a4fa2)

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

@andresayac

andresayac commented Nov 23, 2026 •

Copy link
Copy Markdown

Second machine: RTX 5080, Windows 11, MSVC 14.44, own 1.0.2.1 copy, LEONIDA_D3D12=vulkan, network blocked for gta6rt. On c77a4fa27 with the same queue 16-20 → PC 14-18 mapping as your 5119d85cd, I reach your fence slot 12 stop (the title dereferences the E_NOTIMPL it gets back).

#7290 already implements fence slot 12: the completed value at a live address, one mirror per fence refreshed by a thread-pool wait on a completion event, with slot 12 and the CPU Signal refreshing it at once. It conflicts with this branch's base, but its handler ports by hand (one file, d3d12_xs_device.cpp, ~120 lines) and clears that stop.

The next stop is a read through a null graphics PSO, at ~660 D3D12 calls. This run makes no device slot 57 call at all (compute PSOs through 62/67 only), so the title's PSO table entry is still null when it is read; cf. the slot 57 (DeserializeGraphicsPipelineStateX) note in #8683.

Tests: xs_proxy_mock and queue_proxy assert the PC order (queue slots ≥ 19 and fence slots ≥ 12 refused, GetTimestampFrequency at queue slot 16), so they fail with the console layout; #7490 updates them the same way.

AI-assisted. (Edited to drop executable addresses, per #7416.)

@Th3drata

Copy link
Copy Markdown

Queue slot 32 is PresentX — measured statically at its only call site, game_scarlett_master.exe+0x24824c1 (1.0.2.1), the one my run logged as the caller:

  • 3 arguments: edx = [r12+0x38] (plane count, 1), r8 = rsp+0x100, r9 = rsp+0xc0. Nothing stores [rsp+0x20] before the call, so the 3 seen as a 4th word is stack residue.
  • r8 is an array of 0x48-byte planes: the fill loop at +0x248232d steps rcx by 0x48 per plane and writes +0x00 the token, +0x08 1, +0x10 a resource-pointer slot, +0x18 a pointer to 16-byte {0,0,w,h} rects, +0x20 a pointer to 16 bytes (4 floats), +0x28 a dword from the input; the rest stays zero. That is field for field XboxPresentPlaneParameters in runtime/shims/xbox_present.h (Token, ResourceCount, ppResources, pSrcViewRects, pDestPlacementBase, ColorSpace, then ScaleFilter…Flags = 0), x64 size 0x48.
  • r9 is 0x20 bytes, zeroed, with one dword at +0x18 set to [r12+0x3e] == 0. With the field order in docs/d3d12_vulkan.md (ImmediateThresholdPercent, ViewCount, ExtendedDescCount, pExtendedDescs, Flags), that is Flags at +0x18 in a 0x20 struct. XboxPresentParameters in xbox_present.h currently declares only the float.
  • The token at plane+0x00 comes from the global that device slot 80 (call [rax+0x280], WaitFrameEventX) fills with (2, 0xFFFFFFFF, …, &token) just before on the same path, i.e. the documented GDKX wait-then-present pattern.

macOS data point (first Apple GPU run on this branch, as far as I can see): Apple M4, CrossOver 26.3 (Wine 11.0) + Rosetta 2 + MoltenVK, 5119d85cd + #7216 + the changes below, LEONIDA_D3D12=vulkan, shaders translated with --wave64-emulate on --no-float-controls (MoltenVK lacks shaderDenormPreserveFloat16; with float controls every pipeline is skipped). It reaches the same stop as on NVIDIA: 650 D3D12 calls, fence slot 12 from +0x4fb0aef. What it took beyond Windows:

  • CLWB at +0x4ecc84a and MONITORX at +0x4fb0bd7 (the wait loop behind fence slot 12; the image has 3 MONITORX and 4 MWAITX) are illegal under Rosetta 2. MONITORX/MWAITX are AMD-only, so an Intel host should also fault there once that wait has to spin. Emulated like CLZERO (CLWB/CLFLUSHOPT stepped over; MONITORX stepped over, MWAITX yields), only when CPUID reports them missing: f183dfb3d.
  • XboxBvhBuilder's RadixAlloc declares 37,084 bytes of workgroup memory, over the 32,768 Apple GPUs report, so the PSO is refused and the builder throws. Opt-in LEONIDA_LDS_OVER_LIMIT=skip (no pipeline, dispatches left out, BVH wrong) to keep booting: c43b92a25.
  • 52 BVH pipelines compile in 2.1 s on MoltenVK, so no pipeline-cache seed is needed here (writing pipeline_cache.bin crashes under MoltenVK anyway).

Branch: https://github.com/Th3drata/Leonida/tree/dev-boot-tour-v2. Not done: wiring PresentX to the presentation core, a native Windows build of these commits.

AI-assisted.

@godjacry

Copy link
Copy Markdown

Independent Windows Sandbox result for c77a4fa2 and 5119d85c. The host is Windows 11 build 26300.9974 with a Ryzen 5 5600X and GeForce RTX 5060 (NVIDIA 617.42). In the offline guest a synthetic D3D12 test selected the RTX 5060. Both runtimes were built x64 RelWithDebInfo with MSVC and SDL3.

I translated the 1.0.2.1 package with LLVM 23.1.5, SPIRV-Tools v2026.4 and wave64 emulation on. spirv-val passed 26,503/26,503 archive shaders, 52/52 XboxBvhBuilder programs and 21/29 FidelityFX programs. Eight FidelityFX programs stopped at undecodable words. The shader library was staged on the guest's local disk before the run.

Two launches of c77a4fa2 and one of 5119d85c all ended their startup trace with breakpoint 0x80000003 at title RVA 0x5925915. The confirmed process exit on the repeat run and on 5119d85c was also 0x80000003. All three stderr logs had zero D3D12 trace entries. On this isolated configuration the title stopped before the command-list submission you measured.

AI-assisted verification. Observations only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.