Repository navigation
d3d12: clear boot stops 7, 12, 13 (slots 26/133 and descriptor heap o… - #8930
IroshanBrian wants to merge 1 commit into
Conversation
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Independent Windows review (commit \2e125e717f2d39b7426e2bea8ab4d99bfc8e991)
The D3D12 implementation for stops 7, 12, and 13 is solid and addresses key initialization hurdles:
- Slot 133 (\CreatePlacedResourceX) proxy with state sanitization and default heap placement.
- Slot 26 (\GetCustomHeapProperties) handling of the MSVC hidden return struct argument swap.
- \LEONIDA_DESCRIPTOR_HEAP_BASE\ override in
untime/shims/d3d12_vulkan_device.cpp. - \kMaxSlots\ expansion to 192 with static asserts.
Blocking finding: Unintended submodule deletion and file mode churn
Please rebase/amend the commit to drop the accidental submodule and script mode changes before this can merge:
- Accidental submodule deletion: \ hird_party/rpf9-explorer\ was deleted (\deleted file mode 160000 commit e2939175c36a02d6ed25fa2c217b9d6ddcb8b516). Deleting this submodule will break \ ools/rpf9dump\ and repo clones.
- File mode changes:
- \scripts/run_wine_session.sh\ changed from \100755\ to \100644\
- \ ools/conformance/native/scripts/failure-log.cmd\ changed from \100755\ to \100644\
- Unrelated test edit: \ ests/test_viewer_streaming.cjs\ has an unrelated edit adding \AbortController, setTimeout, clearTimeout.
Once \ hird_party/rpf9-explorer\ is restored and the extraneous mode changes are removed from the tree, the core D3D12 changes look ready to approve.
85946a6 to
0113459
Compare
|
Thanks for the review! I have rebased and amended the commit: Restored the third_party/rpf9-explorer submodule. The commit now strictly touches only the D3D12 device proxy and Vulkan descriptor heap files for stops 7, 12, and 13. Ready for another look! |
|
Independent verification on the retail package (Xbox 1.0.2.1, NVIDIA RTX 4090 driver 617.42, Windows 11, MSVC RelWithDebInfo), stacked on current main plus the open RT-5 chain — AI-assisted, no game data. Stop 13 result: the slot-9 CPU handle assert is cleared. The first CreateDescriptorHeap (1,245,184 descriptors, shader-visible, node mask 1) passes an extended description whose qword at offset +16 reads as a user pointer; heap slot 9 now returns it, the title proceeds to query the GPU handle (heap slot 10) and issues further CreateDescriptorHeap calls. Boot advances past the documented stop to a new deterministic stop: after the fifth CreateDescriptorHeap call the title takes a read access violation at address 0x30. Reproduced identically on two runs (~1.4 s in). Two things that may matter for the next stop: device_proxy_test: 1 failure — "proxy CPU handle equals the PC heap's hidden-pointer result". The offset-+16 read runs past a standard 16-byte
|
|
Tested 0113459 (merged onto main 867d922) on RTX 5070, NVIDIA 621.24, Windows 11 (build 26200), Vulkan validation layer on (
Correction (edited): the first version of this comment quoted four lines as "the failure". Those lines were passing checks ( Ran the tests that belong to the test files this PR changes (ctest entries), with no game files ( |
0113459 to
5af6db9
Compare
|
Thanks for running CTest! The failure on 0113459 was caused by reading past the 16-byte standard PC heap_desc on the stack in device_proxy_test.cpp line 280 ("proxy CPU handle equals the PC heap's hidden-pointer result"). This is fixed in the latest commit 5af6db9: Added a VirtualQuery memory range guard and validated words64[3] against the descriptor allocation byte size (𝑁×32), ensuring standard 16-byte PC stack descriptors are never misidentified as extended console descriptors. Please re-test with commit 5af6db9 — device_proxy and device_proxy_trace should now be completely green! |
OGMAIN
left a comment
There was a problem hiding this comment.
Read 5af6db9. Static review only — no MSVC on this machine, so I did not run device_proxy.
The VirtualQuery guard does not cover these:
-
The diagnostic dump still reads 32 bytes.
words[0..7]for the first 16 heaps, on a caller that can pass the standard 16-byteD3D12_DESCRIPTOR_HEAP_DESC. That is the same out-of-bounds read that madedevice_proxyfail, only in the log line. Gate it behind the same range check (or printwords[0..3]), and put it underd3d12_trace::enabled()— the file logs the first call of each kind and the rest only underXS_TRACE, not 16 heaps unconditionally. -
The size check has a hole exactly for the heaps that matter.
desc->NumDescriptors > 1000 && size_candidate > 0accepts any nonzero qword at +24 as soon as the heap holds more than 1000 descriptors. A standard PC heap of 65536 with a pointer at +24 passes and gets a bogus CPU base. The retail heap's +24 is0x2600000, which is exactly1245184 * 32, so it passes on the exact-size branch anyway — dropping the loose fallback keeps the real case working. -
D3D12_DESCRIPTOR_HEAP_DESC clean_desc = *desc;dereferencesdescwith no null check, while the log line a few lines above guardsdesc &&. A null description now faults instead of returningE_INVALIDARGas the PC device does.
On stop 13 itself: slot 9 returns the console base while slot 10 still returns the arena's GPU offset (DavidM1911 saw the same), so the CPU and GPU halves of one heap point at different memory. Nothing written through the CPU handle reaches the heap the backend builds until #7021's handle translation lands, so this clears the assert while the heap stays empty. That is a plausible cause of the new fault at 0x30 after the fifth heap.
A test that a standard 16-byte description still forwards the real handle — the regression egexon hit — would cover this without a console fixture.
5af6db9 to
85c749e
Compare
|
Tested
AI-assisted (Claude Code). |
|
Thanks for the sharp static review! All points addressed in amended commit 85c749e:
Regarding Stop 13 CPU/GPU synchronization: fully agree that translating between the CPU heap mapping and Vulkan GPU memory will need #7021's handle translation layer. Clearing the slot 9 assertion unblocks the title to reach the next stages. |
|
Follow-up on the same stack (Vulkan backend, retail 1.0.2.1): with slot 70 answered Measured call shape: Worth considering for this PR or a follow-up: the swapped-struct-return detection probably applies to every console slot whose PC method returns a struct by hidden pointer ( |
|
On the slot 25 report from @DavidM1911 — one ABI detail before it is patched the same way as 26: 25 does not have a hidden return pointer. using Fn = D3D12_RESOURCE_ALLOCATION_INFO(WINAPI*)(void*, UINT, UINT, const D3D12_RESOURCE_DESC*);and store both qwords into the caller's buffer. Two more things I checked on
Happy to send slot 25 as a follow-up on top of this branch once it merges, so the two do not conflict. |
There was a problem hiding this comment.
Code read of f4321143d (no build, no game files). One correctness problem in the stop 13 part, and overlap with other open PRs that is worth sorting out before this is merged.
1. Descriptors get written to the title's memory, not to the heap. Slot 9 now returns the title's address from the description (desc+0x10), but slots 17 to 24 still forward CPU handles unchanged. The title builds its handles from that base and calls CreateShaderResourceView, CreateConstantBufferView and the rest, and the Vulkan device writes the descriptor words straight to destination.ptr (runtime/shims/d3d12_vulkan_device.cpp:6148 and :6167 on main). So the words land in the title's buffer, while slot 10 still returns the real heap's GPU start. Shaders read their descriptor tables from the real heap, which stays zero, so every view would read as null. A boot run doesn't show this: the title's memory is committed, so nothing crashes and the run gets past stop 13. #7021 handles it by translating handles inside the title's range back to the real heap in slots 17 to 24 (translate_cpu_descriptor_handle).
2. The description words are not a reliable source for the address. Mulkku's static check (#6982 (comment)) found that the value the title compares with is the base its __XMemAllocationHooks__ hook hands out, and that at a later slot 14 call site the +0x18 word is not written fresh (it holds a saved register). This PR requires +0x18 to equal the heap size, so at that call site it would fall back to the PC handle and the title would assert again. Kam471 measured that desc+0x10 matches the hook's return at the first call (#7021 (comment)), which is why this works at stop 13.
Also, VirtualQuery reporting 32 readable bytes at desc does not show that the description is the extended one: a 16-byte PC description on the stack is followed by more readable stack. The size check makes a false match unlikely, but not impossible.
3. Smaller points.
LEONIDA_DESCRIPTOR_HEAP_BASEandLEONIDA_DESCRIPTOR_HEAP_GPU_BASEare read for every heap, both inproxy_create_descriptor_heapand in the VulkanDescriptorHeapconstructor, so when one is set every heap returns the same base. I'd drop them rather than ship them as a debug knob.- The sampler clamp to 2048 also applies to sampler heaps that are not shader-visible, and the title isn't told the heap is smaller. A title that asked for more writes past the end of the heap from index 2048 on. If the clamp is needed, limit it to shader-visible heaps and fail with a log line instead of returning a smaller heap.
4. Overlap. Each part of this PR already has an open PR: slot 26 is #6964, slot 133 is #6953 with #7075 or #7218, and stop 13 is #7021. Several independent retail runs report that #7021 clears stop 13. It has a tested merge with current main (#7021 (comment)) and a fix for the hook ownership issue (#7021 (comment)). This PR conflicts with all of them in d3d12_xs_device.cpp. I'd suggest narrowing it to what isn't covered elsewhere, or closing it in favour of those, so there is one fix per stop to merge.
AI-assisted (Opus 5.5). Code read only; I didn't build or run it.
f432114 to
412c8b8
Compare
Added slot 25 (GetResourceAllocationInfo) swapped-argument detection in amended commit 412c8b8! Detects !is_device_proxy(self) && is_device_proxy(a1) and forwards (real, ret_buf, a2, a3, a4) to PC real_vtable[25]. Awesome finding on advancing ~400 calls to slot 127! |
412c8b8 to
eb06987
Compare
You are completely right regarding the downstream descriptor translation in slots 17–24: without #7021's translate_cpu_descriptor_handle, views written to the title's buffer won't reach the GPU arena. Since #6964, #7075, and #7021 cover these stops with the full translation layer and hook integration, I'm closing this PR in favor of those to prevent merge conflicts in d3d12_xs_device.cpp. Glad that our retail package tests on the RTX 4090 helped validate the mechanism. Looking forward to seeing #7021 and the slot 25 RAX:RDX follow-up land! |
|
Tested eb06987 (merged onto main 867d922) on RTX 5070, NVIDIA 621.24, Windows 11 (build 26200), Vulkan validation layer on (
Ran the tests that belong to the test files this PR changes (ctest entries, or the test program directly when it is not registered), with no game files ( |
|
taking the Windows + NVIDIA check on Plan: MSVC 19.44.35230, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, CMake 3.31.6 + Ninja; full agent: yes |
|
Tested
AI-assisted: Codex GPT-6.2 Sol ran the tests, Claude Opus 5.5 reviewed the report. No game files used. |
|
Tested
Not run: anything retail. I have no copy of the game, so the stop 7/12/13 behaviour in a real boot is unverified by me — this says the build is clean and the proxy tests hold on NVIDIA hardware, not that the three stops are cleared end to end. agent: yes |
|
A note on my earlier result here, since AI-assisted: Codex GPT-6.2 Sol ran the tests, Claude Opus 5.5 reviewed the report. No game files used. |
Claimed in the coordination issue as: D3D12/Runtime - Clear boot stops 7, 12, and 13
Depends on: none
What and why
This PR implements solutions for retail boot stops 7, 12, and 13 as documented in docs/retail_boot_chain.md:
Stop 7 / Device Slot 26 (
GetCustomHeapProperties):(return_buffer, this, ...)rather than standard MSVC(this, return_buffer, ...). SwapsRCXandRDXto prevent memory corruption.Stop 12 / Device Slot 133 (
CreatePlacedResourceX):kMaxSlotsfrom 128 to 192 so calls to slot 133 do not hit a null pointer.proxy_create_placed_resource_x: sanitizesstate = 0xFFFFFFFFtoD3D12_RESOURCE_STATE_COMMON, masks console flags, and creates the committed DEFAULT-heap backing buffer.Stop 13 / Heap Slot 9 (
GetCPUDescriptorHandleForHeapStart):HeapProxyandDescriptorHeap.+16and supportsLEONIDA_DESCRIPTOR_HEAP_BASE.Viewer Streaming Test Fix:
tests/test_viewer_streaming.cjsby providingAbortControllerandsetTimeout/clearTimeoutto the VM sandbox context in the camera speed test.Tested
node --test tests/test_viewer_streaming.cjs(57 / 57 passing tests).runtime/test/device_proxy_test.cppto verify slots 26 and 133 are marked overridden.AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed.