Skip to content

docs: the retail boot chain, what stops gta6rt --run in order (RT-5 measurement) - #6915

Merged
shayderrr merged 2 commits into
ProjectLeonida:mainfrom
Pipodi:docs-retail-boot-chain
Nov 23, 2026
Merged

shayderrr merged 2 commits into
ProjectLeonida:mainfrom
Pipodi:docs-retail-boot-chain

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-5 measurement (data for its owners, not a claim; the finding was posted on #6750 first)

Depends on: none to merge (docs only). It describes a run with #6709, #4531, #6582, #4313, #4348 and #2490 merged locally.

What and why

Adds docs/retail_boot_chain.md and its row in docs/README.md. The page records how far gta6rt --run gets with the retail executable on Windows. It lists the thirteen stops in order and, for each, the PR that clears it or the local stand-in used. It also gives the call shapes behind them, so RT-5's owners and the xmem/d3d12_xs authors don't have to measure them again:

  • Physical pages: the shapes of XMemAllocatePhysicalPages, XMemMapPhysicalPages, XMemMapPhysicalPagesScatter and XMemFreePhysicalPages, and a placeholder-based CPU stand-in that gets past them.
  • Device slot 26 (a struct return) is called with the return buffer first, (ret, this, …).
  • Device slot 48 creates command queues from a PC D3D12_COMMAND_QUEUE_DESC prefix followed by Xbox words.
  • Device slot 73 creates command lists under a console list IID. With d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path #2490's proxy, 581 lists are created and closed.
  • Placeholder reserves: XMemVirtualAlloc with MEM_RESERVE_PLACEHOLDER, then physical sub-ranges carved out with MEM_REPLACE_PLACEHOLDER.
  • Device slot 133 places a resource at a virtual address (the shape of CreatePlacedResourceX), and the proxy's 128-slot table turned that call into a null call.
  • Current stop: the title asserts that the first descriptor heap's CPU start equals a value it already holds.

New file, so it doesn't conflict with the open PRs on docs/boot.md.

Tested

  • One run on Windows 11 with an RTX 4090 (driver 617.42), LEONIDA_D3D12=vulkan, an MSVC 2022 RelWithDebInfo build, and main 1cc6e3c12 plus the PRs above, from my own 1.0.2.1 copy.
  • python -m pytest tests/test_docs_links.py passes.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. Only export names, public SDK types, slot numbers, flag values and counts; no addresses, offsets, IID values or bytes from the executable.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Pipodi and others added 2 commits November 23, 2026 16:21
…easurement)

Ten stops measured on one Windows + RTX 4090 run with six open PRs merged
locally: which PR clears each, the physical-page export shapes, and the three
device slots whose Xbox shape differs from the PC (26 struct return with the
buffer first, 48 queue creation, 73 list creation). Counts, export names and
slot shapes only; no addresses, IID values or bytes from the executable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3), review nits

Placeholder reserves through XMemVirtualAlloc, the physical sub-ranges carved out
of them, device slot 133 (a resource placed at a VA) and the current stop at
the first descriptor heap. Cites ItsNotRexed#6715 and wraps the long line.

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

Copy link
Copy Markdown

Independent reproduction of this chain on Linux under Wine: own 1.0.2.1 copy, Wine 11.21, RTX 4070 Laptop (Vulkan), LEONIDA_D3D12=vulkan, clang-cl/lld-link 23.1.4 + xwin SDK 10.0.26100 cross build of main 1cc6e3c12 + #6709 + #4531 + #6582 + #4313 + #4348, with local stand-ins written separately from yours (own command-list proxy in the 0-27 / 28-31 / 32-55 / 56-59 order instead of #2490).

Same stops in the same order, 1 to 13, and the same current stop: the first descriptor heap's CPU start is asserted against the value the title already holds. Same counts at that point: 5 queues, 5 fences, 7 allocators, 581 command lists created and closed, about 1,180 D3D12 trace lines. Stop 10/11 placeholders work under Wine through VirtualAlloc2 (MEM_RESERVE_PLACEHOLDER, MEM_REPLACE_PLACEHOLDER) and VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER).

Two stops are specific to this setup. They come before stop 3 and stop 7:

  • Before stop 1, a clang-cl build only: without Loader: the mapped game executable owns module TLS index 0 (RT-259) #4313, main faults inside gta6rt during the guest's CRT init (host_module_name reads its function-local static as null). This is the slot-0 TLS clash surfacing earlier. The CI MSVC runtime-windows artifact of main does not hit it and reaches stop 1.
  • Between stop 5 and stop 6, under Wine: GameInput.dll ordinal 1 binds to Wine's own built-in gameinput.dll, whose GameInputCreate fails, and the title soft-asserts. It needs the GameInput shim built (-DLEONIDA_SDL3_FETCH=ON, which a cross build without an SDL3 package leaves out) and the gameinput.dll!#1 row from gameinput: answer GameInputCreate imported by ordinal 1 #3410. With both, [rt] gameinput: SDL 3.4.20 gamepads and the run goes on.

Device slot 78 and 79 calls also arrive just before the shader-cache and descriptor work: two calls of slot 79 and one of slot 78. Forwarded by number they land on PC CreateReservedResource2 / CreateSampler2, and the title asserts on the result. Returning S_OK from both gets past them, which is consistent with xvalkyrie's notes placing the frame-event methods at 78 to 81.

AI-assisted.

@thiefyzheng thiefyzheng left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read + local run (AI-assisted review, per AGENTS.md). This is the most useful page I have seen on the boot state — one stop at a time, each with the PR that clears it, and §5's "what this does not show" keeps it honest about the local stand-ins.

Verified

  • Applies cleanly to current main (2 files, new page + its README row).
  • python -m pytest -q tests/test_docs_links.py -> 6 passed.
  • Every §-reference in the stops table resolves: §2 and §3.1–§3.4 are the actual headings (## 2. Physical pages, ### 3.1 … … ### 3.4 Device slot 133 …), so the table is navigable rather than pointing at nothing.

One mismatch, in the README row only

docs/README.md:63 summarises the page as "…and device slots 26, 48 and 73", but the page also documents slot 133 (§3.4, "Device slot 133 places a resource at a virtual address") — and slot 133 is stop 12 of the 13, i.e. a stop the reader is being sent to this page for:

| [retail_boot_chain.md](retail_boot_chain.md) | … the physical-page export shapes, and device slots 26, 48 and 73. |

Suggest slots 26, 48, 73 and 133. That is the whole of my review — the page body itself is consistent (the counts at stop 13, the 581 command lists, the "128-slot table" explanation and the slot-9 hypothesis all read as measured rather than inferred).

One thing I would keep when this page grows: stop 13's hypothesis is currently the only unmeasured step, and saying so explicitly ("Hypothesis:") is what makes the rest trustworthy. If a later edit turns it into a statement before the descriptor model answers boot.md Q4, the page loses that property.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds docs/retail_boot_chain.md (102 lines) plus its docs/README.md row. The page records a measured gta6rt --run on the retail executable: thirteen ordered stops, each with the merged PR or local stand-in that clears it. Section 2 gives inferred signatures for XMemAllocatePhysicalPages, XMemMapPhysicalPages, XMemMapPhysicalPagesScatter and XMemFreePhysicalPages and a pagefile-based CPU stand-in. Section 3 documents device slot 26's ret-buffer-first struct return, slot 48's command queue from a PC D3D12_COMMAND_QUEUE_DESC prefix, slot 73's console-list IID (581 lists via #2490's proxy), placeholder reserves with MEM_REPLACE_PLACEHOLDER, and slot 133's CreatePlacedResourceX shape. Stop 13 is a descriptor-heap CPU-start assert.

Why merge

Directly serves static recompilation and executable analysis: it saves RT-5 owners and xmem/d3d12_xs authors from remeasuring the call shapes and boot order. Docs-only, new file, no overlap with open PRs.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

Adds docs/retail_boot_chain.md (102 lines) plus its docs/README.md row. The page records a measured gta6rt --run on the retail executable: thirteen ordered stops, each with the merged PR or local stand-in that clears it. Section 2 gives inferred signatures for XMemAllocatePhysicalPages, XMemMapPhysicalPages, XMemMapPhysicalPagesScatter and XMemFreePhysicalPages and a pagefile-based CPU stand-in. Section 3 documents device slot 26's ret-buffer-first struct return, slot 48's command queue from a PC D3D12_COMMAND_QUEUE_DESC prefix, slot 73's console-list IID (581 lists via #2490's proxy), placeholder reserves with MEM_REPLACE_PLACEHOLDER, and slot 133's CreatePlacedResourceX shape. Stop 13 is a descriptor-heap CPU-start assert.

Why merge

Directly serves static recompilation and executable analysis: it saves RT-5 owners and xmem/d3d12_xs authors from remeasuring the call shapes and boot order. Docs-only, new file, no overlap with open PRs.

Verdict: Approve

@shayderrr
shayderrr merged commit 8e3c7c7 into ProjectLeonida:main Nov 23, 2026
0 of 2 checks passed
ASTROWwwW pushed a commit to ASTROWwwW/Leonida that referenced this pull request Nov 23, 2026
…e and placeholder calls through gta6rt --run

tiny_xmem_physical imports xmem.dll like the title and makes the calls
ItsNotRexed#6915 measured after the first allocations, with
synthetic sizes and no game data:

- XMemAllocatePhysicalPages(0x280) with the count read back, a
  reserve-only MEM_PHYSICAL | MEM_LARGE_PAGES window, XMemMapPhysicalPages
  into it, an unmap by null array, a remap in another order (a page keeps
  its contents) and XMemMapPhysicalPagesScatter;
- a 185 MiB MEM_RESERVE | MEM_RESERVE_PLACEHOLDER reserve with attribute 7
  and PAGE_NOACCESS, five ranges carved out of it with
  MEM_REPLACE_PLACEHOLDER | MEM_PHYSICAL | MEM_LARGE_PAGES at addresses
  inside it, a second batch of physical pages mapped into them, and the
  rest of the placeholder still reserved.

It checks only what the title can observe (results, counts, addresses,
memory contents), so any xmem implementation can be run against it.
xmem_stub gains the four physical-page exports for the link.

The fixture's own logic was run on Linux against an mmap/memfd emulation
of the five calls (passes; fails when the emulation maps the wrong page).
The Windows build and the run under gta6rt are left to CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UkEUa9YfGQH4p9g1Guw9gq
tibzejoker added a commit to tibzejoker/Leonida that referenced this pull request Nov 23, 2026
… not import the title's pages

RADV under Wine refuses to import a view of a pagefile-backed section (E_OUTOFMEMORY on an RX 9070 XT,
found in review), which is the form xmem's physical pages take, so the retail boot stopped at the first
174 MiB placement. An import failure other than a misaligned VA now gives an ordinary DEFAULT buffer of
the same description, as ItsNotRexed#6915's stand-in did, logged once: the boot goes on, and the title's writes at
that VA don't reach it on such a driver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zneel pushed a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
…he title's own pages

Xbox device slot 133 is (va, desc, state, clear, riid, out): the title places a buffer at the VA of a
physical-page range it has just mapped (docs/retail_boot_chain.md 3.4, ItsNotRexed#6915). The proxy now hands it to
a handler the Vulkan layer registers (set_placed_at_va_handler), which imports [va, va + width) with
VK_EXT_external_memory_host and binds a VkBuffer to it: the CPU's writes there are the GPU's reads with no
copy, and the resource's console VA is the title's VA, so views and immediate writes the title names by
that VA resolve to it through the buffer VA index. The Xbox flag bits above the PC ones are dropped and
the layout made ROW_MAJOR, as slot 76 does; textures are E_NOTIMPL, a misaligned VA E_INVALIDARG, and
with no handler (a PC device) the slot refuses with E_NOTIMPL as ItsNotRexed#6953's table does.

Not decided here: a shader that adds heap_base to the title's VA (its own V#s) does not reach these
pages; that needs the single address space of docs/d3d12_vulkan.md 3.3.

d3d12_existing_heap_test: on a VirtualAlloc range and on a view of a pagefile-backed section (the form
xmem's physical pages take), the buffer's GPU VA is the address and a GPU copy to a READBACK buffer reads
a pattern the CPU wrote after creation; Vulkan validation clean on an RTX 4090.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants