Skip to content

docs/retail_boot_chain.md: stops 13-17 (descriptor heap at an address, device slots 70, 127, 25) - #6982

Closed
Pipodi wants to merge 1 commit into
ProjectLeonida:mainfrom
Pipodi:docs-boot-chain-stops-14-17
Closed

Pipodi wants to merge 1 commit into
ProjectLeonida:mainfrom
Pipodi:docs-boot-chain-stops-14-17

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; follow-up to #6915)

Depends on: none (docs only). #6915 is merged; this extends its page.

What and why

#6915 stopped at stop 13: the title asserting on the first descriptor heap's CPU start. This adds what came after, on the same machine and build:

  • Stop 13, cleared locally. The Xbox D3D12_DESCRIPTOR_HEAP_DESC carries a CPU address and size after the 16 PC bytes. The title asserts that the heap starts there. Giving the Vulkan heap that memory as its CPU storage clears it (§3.5).
  • Stop 14: device slot 70 makes an SRV from raw descriptions and a GPU address, with no resource. It is currently forwarded to PC CreatePlacedResource1 (§3.6).
  • Stop 15: device slot 127 has CreateCommittedResource3's argument list, but it sits past the PC vtable (§3.7).
  • Stop 16: device slot 25 (GetResourceAllocationInfo, called as (ret, this, …)) passes Xbox descriptors unchanged.
  • Stop 17, current: a fatal budget assert after the first full-screen render targets. The PC allocation sizes come out smaller than the console's, so too much of a fixed budget is left over.

The trace now holds 1,641 D3D12 calls, up from 1,185.

Tested

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. Only public SDK types, struct offsets of SDK-shaped descriptors, slot numbers and counts; no executable addresses, offsets, IID values or bytes.
  • 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

…, device slots 70, 127 and 25)

Follow-up to ItsNotRexed#6915. Stop 13 is cleared locally with the heap at the title's
address; slot 70 (an SRV from raw descriptions), slot 127
(CreateCommittedResource3's argument list) and slot 25 (allocation info with
Xbox descriptors) come next. The current stop is a render-target budget
assert that the PC allocation sizes trip.

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

Copy link
Copy Markdown
Contributor

Thanks for the measurements. I have my own 1.0.2.1 copy and can reproduce on Windows 11. Of the PRs that clear stops 1–12, only #6582, #6964 and #6953 merge cleanly on current main; the xmem ones (#4531, #6709, #6919, #6995) and the device ones (#2490, #6935, #6954, #6973) conflict in xmem.cpp and d3d12_xs_device.cpp. Could you push your local integration branch (code only, no game data) so others with the executable can start from stop 17 instead of rebuilding stops 6–16? I'd like to help measure the console's render-target allocation sizes for stop 17.

AI-assisted (Claude Code).

@Pipodi

Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@simonbronk here it is: Pipodi:boot-integration (code only, no PR). Commits marked LOCAL and code marked not for main are stand-ins, not proposals. tedin7 and Khuraie (#7021) are turning the measured shapes into real PRs on #6910.

Base: main 1cc6e3c12 with #4531, #6709, #6582, #4313, #4348 and #2490 merged in. It doesn't merge cleanly with current main yet (xmem.cpp, d3d12_xs_device.cpp, CMakeLists.txt), so build it as it is.

To run it past stop 17:

  1. Build gta6rt (RelWithDebInfo) and run with LEONIDA_D3D12=vulkan.
  2. LEONIDA_SKIP_ASSERTS=20: a new opt-in vectored handler in main.cpp. It logs and steps over up to N int3 in guest code (not in host modules). Stop 17's budget check is one of these. A second assert comes later.
  3. LEONIDA_SHADERS=<folder>: one folder holding both your make_game.py SPIR-V and the 52 shaders embedded in XboxBvhBuilder.dll, with the two index.json files merged (the keys don't clash). The embedded set is made by docs/embedded_shaders.md's commands (pe_shader_containers.py --extract → fssm_unpack.py → shader_disasm.py --mcpu gfx1013 → rdna2spirv.py). Use current main's translator: with rdna2spirv: 8/16-bit MUBUF loads and stores (buffer_load_ubyte/ushort/d16, buffer_store_byte/short) #1864, all 52 translate and pass spirv-val; the branch's older translator manages 51. Without them, the title stops at the first BVH-builder compute pipeline.

Where it stops now (1,655 D3D12 calls):

  1. All BVH-builder root signatures and compute pipelines are created.
  2. Device slots 39, 27 and 41 are forwarded by number and return.
  3. A second guest assert is skipped.
  4. Device slot 61, forwarded to the PC slot 61, ends in an access violation inside the runtime.

The next thing I'm measuring is slot 61's Xbox shape. On the render-target sizes for stop 17: on the PC the full-screen target asks GetResourceAllocationInfo for one 33,423,360-byte allocation with 64 KiB alignment. A console-side size for the same desc would settle it.

AI-assisted (Claude Code).

@simonbronk

Copy link
Copy Markdown
Contributor

Reproduced on boot-integration (RTX 5070, Windows 11, Vulkan): with LEONIDA_SKIP_ASSERTS=20 and the 52 embedded shaders (current main translator, 52/52 spirv-val) the run reaches the same frontier: slots 39/27/41 return, then slot 61 → access violation in the runtime. On a 32-wide NVIDIA GPU the embedded set needs --wave64-emulate, otherwise the runtime warns on two wave64 compute shaders. I'm looking at slot 61's shape locally too and will post what I find here, so we don't duplicate; happy to rerun any build you push.

AI-assisted (Claude Code).

@Pipodi

Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@simonbronk thanks for reproducing it. Two updates so we don't duplicate work:

Slot 61 is settled by #7115 (mrp1no): CreateSamplerX(desc, dest) → PC CreateSampler. I tested it on this stack (report) and dropped my stand-in. With it plus #6891 (xg_xs: its texture computer is called at once afterwards and needs a non-null object), the run reaches 1,661 D3D12 calls.

The new frontier is slot 67 from the executable itself, not from the FidelityFX DLL. docs/fspx.md only knows the DLL's caller.

  • 28 DeserializeComputePipelineStateX calls, all from one call site in the exe. Kind 0 is 28 B, kind 1 is 20 B, kind 6 is 384 to 1,024 B, kind 7 is 280 to 472 B.
  • The 28 kind-6 programs are 28 different byte strings. They have no common 0x100 prologue (unlike the DLL's).
  • None of them is among the upscaler DLL's 29 programs (that DLL isn't even loaded at this point). None is in XboxBvhBuilder.dll or in the exe file as plain bytes. None is in any of the 25,734 carved FSSM blobs (32-byte windows, no hits).
  • So every call fails with no translated compute shader and returns E_INVALIDARG. After that, two more guest asserts and a guest access violation follow.

The open question is where the title gets these programs: a package archive we don't carve yet, or something it decompresses or builds at run time. If you look into it, the caller is the thing to trace. I'm on the same question. Your --wave64-emulate note is right for the 4090 too.

The branch is updated to this state. Counts only, no game files. AI-assisted (Claude Code).

@simonbronk

Copy link
Copy Markdown
Contributor

Two results from my run of boot-integration plus #7115, #6891, #7163 (in its shape), #3777 and #6935 (slot 80). RTX 5070, Windows 11, Vulkan:

  • Fence slot 12, past the PC chain: (value, &{0, callback, 0, 0}, flag). The title uses the return value as a pointer to the fence's 64-bit completed value. It compares *p with ~0 (device removed) and checks *p - value. With the proxy's E_NOTIMPL, the title dereferences 0x80004001 and crashes. A local stand-in returns the address of a per-fence mirror refreshed from GetCompletedValue(), and the run then moves on to command-list recording (list slots 20–24, 34, 44, 47, 50, 70, 75, 126, 142 get first calls). The real semantics probably need that memory to stay live (a GPU-written or updater-thread value), not refreshed per call.
  • runtime: DirectStorage zlib requests (file and memory sources) #7180 (zlib DirectStorage) on top: the zlib requests are inflated and the buffers change (42 distinct kind-6 hashes instead of 39; 31 are still the same). Every slot 67 call still fails with no translated compute shader, so these programs aren't in any translated set yet. The run then stops on a null object read in title code, which I haven't traced yet.

Fence slot 12 isn't claimed in #7049 as far as I can see. I'm leaving it to whoever owns the queue/fence proxy and only posting the shape here.

AI-assisted (Claude Code).

@simonbronk

Copy link
Copy Markdown
Contributor

Follow-up with #7180 merged on the same stack (RTX 5070, Windows 11, Vulkan):

  • The slot 67 programs are real after runtime: DirectStorage zlib requests (file and memory sources) #7180. I kept the refused payloads locally (kind 0/1/6/7 as the proxy builds them, in my own work folder only): 42 distinct calls, every kind-6 program non-zero with the FSPX prologue (words 0, 3 and 6 = 0xD580…).
  • They translate with the existing tools as they are. tools/fspx_unpack.py --disasm unpacks all 42. tools/rdna2spirv.py --no-asm --wave64-emulate then translates 38/42, 38 spirv-val-valid; the 4 others are refused by the CS thread-group-size SGPR rule. With that output as <shaders>/fspx/, every slot 67 call succeeds (0 no translated compute shader). So the missing piece is only where the build finds these payloads in the package (the zlib DirectStorage source), not translation.
  • The next stop is slot 57. On this branch it is forwarded to PC slot 57, which is ID3D12Device5::CreateLifetimeTracker (not supported). The title calls it once, gets no pipeline, and a few calls later reads a null field of its bound graphics-pipeline object (read at 0x68). That's @KkelebekK's claim 1 in Coordinating who works on what (41) (moved to #7231) #7049 (native graphics pipelines). I'm not touching it, and I'm happy to run their branch here as soon as it's pushed.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Verified at 01f2221, clean merge with current main 8575d36. Docs-only: stops 13-17 and sections 3.5-3.7 added to the boot-chain page with the page's own measurement-citation convention (build sha, copy 1.0.2.1, Windows 11, RTX 4090, driver 617.42, LEONIDA_D3D12=vulkan), the "a measurement for RT-5, not a claim" status line kept, and no exe bytes or addresses quoted. Stand-ins are honestly labeled untested beyond title. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@simonbronk

Copy link
Copy Markdown
Contributor

More from the same stack (RTX 5070, Windows 11, Vulkan), with LEONIDA_SKIP_ASSERTS lowered so each title assert stops the run:

  • The title assert during resource setup is slot 25 returning UINT64_MAX. The title asserts that GetResourceAllocationInfo's size is under 4 GiB. Two descriptions the console accepts and the PC refuses: B5G5R5A1_UNORM with RT+UAV, and R32G8X24_TYPELESS with depth-stencil+UAV. Locally, sizing them without the refused usage (UAV first, then RT) clears the assert. Resource creation will need its own answer for these formats.
  • Device slot 74 = (VA of the 6 GB physical allocation, 64 KiB page count, &handle). The generic route forwards it to PC ShaderCacheControl, which fails, and the title asserts. Accepting it with S_OK and a non-null handle clears that assert. The title keeps the handle in a global; I haven't seen it read back yet.
  • Device slot 57 with @KkelebekK's layout: I tried a local stand-in (digest table from my own <work>/shaders/dxbc, state B decoded as they describe). The first call resolves both containers (VS_Blit/PS_Blit-style pair, 1 RT, 3 inputs) and reaches vkCreateGraphicsPipelines. I'll leave the real implementation to their claim.
  • Slot 108's 4 MiB alignment is correct: those descriptions are 4-sample MSAA.
  • The run still ends with the same read at 0x68 on the render thread. The title's default programs are all set by then, so it isn't them.

AI-assisted (Claude Code).

@gkissel

gkissel commented Nov 23, 2026

Copy link
Copy Markdown

The same chain reproduced under Wine 11.21 on Linux (clang-cl + xwin cross build, -DLEONIDA_SDL3_FETCH=ON, LEONIDA_D3D12=vulkan, GTX 1650 Mobile 4 GB, NVIDIA 620.70), own copy of 1.0.2.1. It uses only open PRs plus two Wine-specific fixes, adding one PR at a time on top of main 08c1aa634, with 2 runs per step. Outcomes only, for anyone testing on Linux:

step stop on Wine cleared by D3D12 calls
0 main: read of 0x0 in host_module_name (the /GA slot-0 TLS) #4313 0
1 third XMemVirtualAlloc (2 MiB pool, attribute 0x183) #6919 0
2 XErrorReport not served #6582 0
3 GameInput.dll ordinal 1 binds to Wine's builtin stub, which fails (Wine-only) #7216 + an SDL3 build 0 → device created
4 device slot 26 (struct return) #6964 5
5 compute queues refused (console queue flags) #7037 13
6 slot 73, console list IID #2490 + #7076 1,181
7 XMemMapPhysicalPages into the descriptor pool returns NULL: Wine refuses PAGE_WRITECOMBINE views (Wine-only) fix offered on #6919 (comment there) 1,181
8 slot 133 through a null table entry #6953 + #7218 (VK_EXT_external_memory_host works under winevulkan) 1,183
9 stop 13, descriptor heap start #7021 1,198
10 stop 14, slot 70 #7066 1,632
11 stop 16, slot 25 (GetResourceAllocationInfo) faults in proxy_slot<25> in progress on my side 1,632

#4348 was merged at step 2 and changed nothing observable there. Conflicts between these PRs were all mechanical: slot lists, mock-test hunks, and #7066's route helper needing #7037's proxy_create_command_queue_x. I resolved them locally only; that local branch isn't pushed.

Two notes for Linux users:

AI-assisted (Claude Code). No game files, bytes or code addresses here.

@Mulkku

Mulkku commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Static check of stops 13 and 17 against the retail executable (Ghidra 12.2 headless, own 1.0.2.1 copy), next to boot runs on an AMD Radeon RX 9070 XT (Windows driver 32.0.32029.2010). Mechanisms, sizes and slot numbers only; no addresses.

Stop 13 (the heap slot 9 assert). The value the title compares heap slot 9's result with is the base of an XMemVirtualAlloc the title made earlier, not a word it reads back from the descriptor-heap description. Around its device slot 14 call the title registers an allocation hook through the executable's __XMemAllocationHooks__ export; that hook hands back the base when the requested size equals count × descriptor increment and the attribute word's low 14 bits are 4. So the check passes when the runtime allocates the heap's memory through the hook, which is what #7021 does; on my stack #7021 clears stop 13. The description does carry the address and size at +0x10/+0x18 at the stop-13 call site, but statically, at a later slot 14 call site the +0x18 word is not written fresh (it holds a saved register), so code that reads those words instead of using the hook would misfire there.

Stop 17 (the budget assert). The hook installed around the first render targets is a bump allocator over a 64 MiB budget (82 MiB for one value of the ConsoleMode registry setting). It takes only allocations whose attribute page-size field (bits 14-15) is 2, rounds each up to 64 KiB, and asserts when 2 MiB or more of the budget is left. "Used" is the hook's cursor, not slot 25's answer: a runtime that never calls the hook asserts with the whole budget left.

This explains the RDNA4/RDNA2 split between #7235 and #7240: two leases of AMD's RDNA4 answer (33,423,360 B each) use 66,846,720 B and leave 256 KiB, so the check passes; two of the RDNA2 answer (33,619,968 B each) need 67,239,936 B, more than the 64 MiB budget. #7235 passes on RDNA4 because that driver's size happens to fit. Leasing the console size (#7240, with #7078's sizes) makes it independent of the driver.

Not determined: the attribute words and sizes the real xmem.dll/d3d12_xs.dll pass, and what the ConsoleMode values are.

No game files. AI-assisted (Claude Code).

@tugasky

tugasky commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Three measured corrections to stops 13-15, from booting the stack with every PR up to #7066 merged (main 8575d36ed + #6919 + #4313 + #6582 + #4348 + #6964 + #6954 + #2490 + #6953 + #7075 + #7021 + #7066; RX 9070 XT, AMD 26.11.2; 4 runs each, identical). The full ladder is in #7154.

So the table's sequence for 14/15 is one path, not the only one: with the real PRs merged, 25 comes before 127. The 25 row (#7110's item) may be worth moving up, or the 127 row marked "depends on the slot-70 view being real".

AI-assisted: yes.

@tugasky

tugasky commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Correction to my comment above, measured after stacking #7110 (device slot 25) on the same tree:

  • Slot 127 is reached — my "this tree never calls it" was true only while slot 25 was unanswered. With d3d12_xs: device slot 25 cleans the Xbox layout word and flag bits on a copy before the PC GetResourceAllocationInfo (retail boot chain stop 16) #7110 merged, the title's first device slot 127 call is the line right after the slot-25 answer (device slot 127 (forwarded) is beyond the PC device vtable (80 slots); returning E_NOTIMPL) and it breaks with int3 (0x80000003), 4/4 runs.
  • The measured order on the merged PRs is 70 → 25 → 127, not 70 → 127 → 25: slot 25's GetResourceAllocationInfo (C form) is answered first, then slot 127 is refused. So stops 15 and 16 are swapped relative to this table — 16 before 15 — presumably because the table was measured with the §3.6/§3.7 local stand-ins, which take different paths.

Both the 25 and 127 rows otherwise match: 25 is a console struct-return shape (#7110), and 127 is past the PC vtable and gets E_NOTIMPL with the title asserting on the null resource (#7052 is the PR for it).

Same stack otherwise as my previous comment (main 8575d36ed + #6919 + #4313 + #6582 + #4348 + #6964 + #6954 + #2490 + #6953 + #7075 + #7021 + #7066 + #7110), four runs, identical; xs_proxy_mock_test PASS and device_proxy_test OK.

AI-assisted: yes.

@tugasky

tugasky commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Measured on the retail executable (Win11 26300.9550, RX 9070 XT, AMD 26.11.2, LEONIDA_D3D12=vulkan), so the rows for stops 13–17 can be filled in from runs rather than local stand-ins:

# what the title did cleared by
13 first CreateDescriptorHeap → slot 9 handle check #7021
14 device slot 70 (raw-word shader-resource view, null view accepted) #7066
15 device slot 127 (Xbox CreateCommittedResource3) → E_NOTIMPL → int3 #7052; 1 632 → 1 640 D3D12 calls
16 device slot 25 (GetResourceAllocationInfo, C form) — measured before 127, not after #7110
17 the title's own int3 in the XMem budget hook that bump-allocates its first full-screen render targets #7240 (leases 510 x 64 KiB per 3840 x 2160 target through the title's hooks; the int3 goes away and the run continues)

Two things for this document:

  1. The measured order is 70 → 25 → 127, i.e. stops 15 and 16 are the other way round here (this was written with local stand-ins for §3.6/§3.7).
  2. After stop 17 the chain is no longer a proxy gap: with no work folder the shader library is empty, the first CreateComputePipelineState (Xbox slot 62) fails, and the title throws. So stop 18 needs LEONIDA_SHADERS=<work>/shaders/spirv from the user's own make_game.py; runtime: a guest Sleep sits out host-only pipeline compiles, so the title's startup hang check survives a cold boot (RT-5 follow-up, stop 18) #7858 covers the hang check just behind it (1 641 calls).

Source runs: four runs per row, identical, each stack = main 8575d36ed + the listed PR plus #6919/#4313/#6582/#4348/#6964/#6954/#2490/#6953/#7075/#7021.

AI-assisted: yes.

zneel pushed a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
…ttedResource3 with Xbox descriptors, RT-5 stop 15)

Slot 127 is past the PC device vtable and was refused with E_NOTIMPL. It has the argument list of ID3D12Device10::CreateCommittedResource3; the proxy now calls the PC device's with the Xbox layout word and flag bits cleaned as slot 76 does. Measured in ItsNotRexed#6982.
zneel pushed a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
…(RT-5 stop 17)

The retail title asserts when its first full-screen render targets leave more than 2 MiB of a fixed budget unused (docs/retail_boot_chain.md, ItsNotRexed#6982). The PC size is about width x height x element bytes; the console takes whole RDNA2 SW_64KB tiles. Slot 25 adds the difference per render target description and never lowers a size. Depends on ItsNotRexed#6973.
@DatGuySnowfox

Copy link
Copy Markdown

Your stop 17 reads like a specific assert I traced statically, and if it is the same one the tolerance is tighter than it looks. Posting the mechanism in case it saves you the trace. Static analysis only, on my own copy, and I have not reproduced your run.

The batch that creates the full-screen surfaces installs a per-thread XMem allocation interceptor around itself, with a two-field stack context of {cursor, budget}. Its class word test is bits 14 and 15 equal to 2 (class & 0xC000 == 0x8000), so it is a different interceptor from the descriptor heap one in #7021, which matches the low 14 bits equal to 4.

What it does:

  • On the first matching call it chains to the next handler, substituting the budget for the requested size. So the host sees one request for the whole arena, not the small size the title asked for. The returned pointer becomes both the arena base and the initial cursor.
  • Every later matching request is rounded up to 64 KiB, the cursor advances by that, and the old cursor is returned.
  • The budget is 0x4000000, 64 MiB, or 85983232, about 82 MiB, when the console id is the Series S one. Nothing else changes it.
  • Overrunning the budget is a fatal assert inside the interceptor.

Then, after the batch, the installer asserts:

(arena_base + budget - cursor) <= 0x1FFFFF

That is the one I think you are hitting. It is an under-consumption assert: at most 2 MiB of the budget may be left. It is not checking that you stayed inside the budget, it is checking that you nearly filled it, which matches your reading that the PC sizes come out smaller and too much is left over. It also fires when the hook never ran at all, because the cursor is still zero and the expression is then the whole budget.

Two consequences, if this is the same assert:

  • The budget is a constant in the title, so the surface sizes are the only lever. They have to add up to within 2 MiB of 64 MiB, or of about 82 MiB under the Series S id.
  • The surfaces are created at the window's width and height with a configured format, and their count is a configured dword, so all three of those feed the total.

One thing I could not settle statically: whether the shortfall is the per-surface size or the count. If your run can print the cursor after the batch, the gap against 64 MiB would say which.

Separately, and only because two accounts are now in flight: your §3.5 has the CPU address and size riding in the Xbox D3D12_DESCRIPTOR_HEAP_DESC after the 16 PC bytes, while #7021 has it arriving through the __XMemAllocationHooks__ call with attribute 0x00800004. In the wrapper I read, the descriptor and the hook context are two separate stack variables and the base goes to the hook, which matches #7021. Both of you cleared the stop, so it may be that the address is available in both places, but the implementations differ and it seemed worth flagging rather than leaving for whoever rebases second.

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.

9 participants