Skip to content

d3d12_xs: device slot 127 takes the resource's memory through the title's XMem hook (retail boot chain stop 17) - #7235

Open
NiiRoZz wants to merge 5 commits into
ItsNotRexed:mainfrom
NiiRoZz:d3d12-xs/slot127-xmem-hook
Open

NiiRoZz wants to merge 5 commits into
ItsNotRexed:mainfrom
NiiRoZz:d3d12-xs/slot127-xmem-hook

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #7231 (comment)

Depends on: #7021 (the __XMemAllocationHooks__ bridge) and #7052 (device slot 127). This branch is #7021's head with #7052 merged in; only the last commit, f5dae9ff2, is this PR. #7021 currently conflicts with main, so the diff against main also shows both of them until they land.

What

After the PC device creates a committed resource for Xbox device slot 127, the proxy calls the title's installed XMem allocation hook for that resource's allocation size (from the PC GetResourceAllocationInfo). It passes the D3D allocator ID and page-size field 2 (kXmemCommittedResourceAttributes). The memory is attached to the resource with SetPrivateDataInterface, so it goes back through the hook's free when the resource dies. The PC resource is not backed by that memory; it only keeps the title's accounting the same as on the console. With no hook installed, if the hook refuses, or if the PC call fails, slot 127 behaves as before.

Why

Stop 17 of the retail boot chain (#6982): a fatal assert right after the title's first full-screen render targets. Measured locally at the title's call sites, it isn't a size check against our answers:

Limits: the object type of a resource allocation is not measured, so it is 0. Only slot 127 does this; the other committed-resource paths (slots 27, 53, 76) can follow once a title is seen counting them.

Tested

Windows 11, MSVC 2022 (14.44, RelWithDebInfo, Ninja), RTX 5090:

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. Only public API names, XMem attribute fields, resource shapes and counts; no addresses, offsets, disassembly, strings 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

Khuraie and others added 5 commits November 23, 2026 23:42
…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.
…nment, refuses null heap properties; tests pin heap flags, session and reference counts

Review of ItsNotRexed#7052: dispatch and release through the ID3D12Device10 interface pointer (not the base device's vtable); keep every PC-valid resource flag bit, 0x400 included; null heap properties return E_POINTER; the test now passes non-zero heap flags and a protected session, checks the single release returns 0 for texture and buffer, and covers a distinct Device10 pointer.
…allocation hooks for descriptor heaps)
…le's XMem hook (retail boot chain stop 17)

The console D3D runtime allocates a committed resource's memory with XMemAlloc, so a title's
__XMemAllocationHooks__ see it. Around its first full-screen render targets the title installs a hook
that bump-allocates allocations with page-size field 2 from a fixed arena and then asserts that little
of the arena is left unused; with no call reaching the hook, nothing is counted and the assert fires.

After the PC device creates the resource, slot 127 calls the installed hook (the one ItsNotRexed#7021 bridges for
descriptor heaps) with the PC allocation size and the D3D allocator ID, page-size field 2, and attaches
the memory to the resource as private data, so it goes back through the hook's free when the resource
dies. The PC resource is not backed by it.

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

Copy link
Copy Markdown

Retail Linux integration result on RX 9070 XT / Mesa RADV 26.3.1 / Wine 11.22. With #7052, #7078 and #7110, both 3840×2160 RGBA8 render targets were created. The host and tiled sizes agreed at 33,423,360 bytes per target. The last three traced calls created the SRV, RTV and UAV for the second target. The title then stopped.

With this PR’s slot 127 hook and #5680’s catalogue loader added, the same title reached Xbox slot 62 (CreateComputePipelineState) and loaded 26,584 translated shader entries from my local work folder. After that the trace shows four more committed resources, command lists, a descriptor heap and two more SRVs. It still ends during System Init, frame 0. The integration also contains #7075’s independent resource and #7066’s null view, so this measures startup progression only.

A separate synthetic test on Wine / lavapipe created two render targets. Each allocation hook was called once for 65,536 bytes, and the matching free ran on the last Release of each resource. No game data or shader artifacts are attached.

@controldebils

Copy link
Copy Markdown
Contributor

@NiiRoZz measured on the AMD Windows driver: f5dae9ff2 overruns the title's 64 MiB arena at stop 17, the same way #7240 does (details there: #7240 (comment)).

RX 6900 XT (gfx1030), AMD 26.11.2, Windows 11, MSVC, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, main plus the open boot-chain PRs, with this PR merged:

Suggestion: hand the hook the console tile size for render targets, not the PC size.

AI-assisted (Claude Code).

@justr4mzi

Copy link
Copy Markdown
Contributor

Independent native Windows 11 / MSVC 19.44.35230.0 / AMD Radeon RX 6700 XT (gfx1031, Vulkan 1.4.335, driver 2.0.372) verification of f5dae9ff2:

  • Build & CTest (standard and LEONIDA_VK_VALIDATION=1):
    • ctest --output-on-failure -R "^(xs_proxy_mock|device_proxy|d3d12_present|d3d12_draw)$": 8/8 passed (2.24 s standard, 1.58 s with LEONIDA_VK_VALIDATION=1, 0 validation errors).
    • xs_proxy_mock_test.exe (all 6 modes, including the slot 127 __XMemAllocationHooks__ 33,423,360-byte lease and release check) and device_proxy_test.exe (WARP): PASS (0 failures).
  • Negative control:
    • Reverting runtime/shims/d3d12_xs_device.cpp to parent 00722628a while keeping xs_proxy_mock_test.cpp at f5dae9ff2 fails at xs_proxy_mock line 1283: g_heap_hook.alloc_calls == 1 && g_heap_hook.last_alloc_size == kSize (exit 1). Restoring f5dae9ff2 passes (exit 0).

AI-assisted (Gemini, Antigravity).

@LooperSalty

Copy link
Copy Markdown

Tested f5dae9ff2 on Windows 11 10.0.26300, RTX 4070 SUPER (driver 610.88), MSVC (VS 2026) RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy (exe SHA-256 starts e95020b2), gta6rt --run with LEONIDA_UNIMPLEMENTED=stop and log, 2 runs. pass on NVIDIA: stop 17 is cleared.

Base: main ec0e01c5 + #6919, #6582, #4313, #4348, #6964, #6954, #6953, #2490, #7076, #7075, #7021, #7066, #7110, #7052 and #7115 merged locally (conflicts resolved by hand, tests not taken).

  • Before: int3 at game+0x247af2d, right after the first two slot 127 render targets and slot 20.
  • With it: slot 127 resource memory through the title's XMem hook: 33423360 bytes, allocated. No budget assert. The title goes on to slot 16 (CreateRootSignature), slot 62 (compute pipeline), then an uncaught C++ exception (0xE06D7363) from XboxBvhBuilder.dll (stop 18). 6.5 s, 688 MB peak.

On this GPU slot 25 already answers with the tile size, so the lease is 33,423,360 B per target, as @controldebils expected for NVIDIA and RADV. The AMD overrun does not show here. Exit codes, module offsets and slot numbers only. AI-assisted (Claude Code).

@hiddenblur

Copy link
Copy Markdown

A note from reviewing #7240, which leases the same slot-127 render targets: at f5dae9ff2 this PR leases the PC GetResourceAllocationInfo size (info.SizeInBytes), with no console tile rounding.

On AMD's Windows driver that size is larger than the console's. @controldebils measured 33,619,968 B (513 × 64 KiB) for a 3840 × 2160 R8G8B8A8_UNORM target against 33,423,360 B for its 30 × 17 SW_64KB_D tiles, and two such leases (67,239,936 B) overran the title's 64 MiB arena: an int3 inside the title's hook during the second target (#7240 (comment) and the comments above it). #7240 fixed it in d61755d4d by leasing console_render_target_size for listed render-target shapes. NVIDIA answers the tile size already, which is why the NVIDIA runs here pass.

I read the code; I haven't run this PR on AMD hardware.

AI-assisted. No game files.

@zohaiblazuli

Copy link
Copy Markdown

Tested f5dae9ff2 (with #7052 and #7021) on the retail executable: pass.

Retail Xbox Series 1.0.2.1 package + executable (sizes match game/xbox-1.0.2.1.json), Windows 11 10.0.26300, MSVC 14.50, GeForce RTX 3060 (driver 32.0.16.1742). Vulkan backend (LEONIDA_D3D12=vulkan, Vulkan SDK 1.4.363). gta6rt --run with --overlay to a scratch folder, outbound network blocked, LEONIDA_UNIMPLEMENTED=stop. Base: main 8575d36ed plus my local console-queue-flag and struct-return (slots 25/26/43) changes, with these PRs merged in this order: #6953, #7187, #7076, #7075, #7021, #7066, #7235 (which carries #7052). Conflicts resolved locally.

  • Slot 127 creates its resources through the PC CreateCommittedResource3, and the memory is taken through the title's XMem hook. The boot continues through view and root-signature creation to the first CreateComputePipelineState (slot 62).
  • The stop there is local: this machine has no translated shaders yet, so the Vulkan device cannot build the pipeline. Not this PR.
  • Merge note: d3d12_xs: device slot 73 answers the console list IID with the console list proxy (depends on #6935, #2490) #7076 renamed the mock's Kind::command_list to Kind::list; I kept both names. xs_proxy_mock_test, queue_proxy_test and device_proxy_test pass.

Outcomes only; no game data.

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