Repository navigation
d3d12_xs: translate title-owned CPU descriptor handles in ListProxy and preserve ClearDepthStencilView FLOAT Depth - #7880
Conversation
…nslate CPU handles
The d3d12_xs shim's device now hands callers console-shaped command lists (160-slot vtable, object body at +0x18 with the write cursor pinned at the record limits, console slots 27-30 recorded not forwarded, slot map measured to the PC table: 60->58, 61->59, 146->80). Queue layout detection is atomic and device-wide; SignalX (slot 23/25 by layout) forwards as Signal, PresentX (30/32) reaches the presentation core, and ambiguous slot 18 serves the timestamp- frequency getter until the layout is proven. AllocateUploadMemory (console slot 148) carves a bump arena out of persistently-mapped UPLOAD-heap buffers; the six root-VA setters and the IA/SO view setters translate arena pointers to buffer device addresses in proxy-owned copies. Impossible sizes and non-power-of- two alignments are refused before any arithmetic that could wrap. PC-compiled callers opt into real PC-shaped lists with console_lists=false on create_device_proxy, and PC-compiled guests with LEONIDA_D3D12_LISTS=pc — the fixture path check_tiny_frame.py sets, so a guest ClearRenderTargetView at PC slot 48 reaches the real list. The GPU tests take the flag; unmeasured console slots stay console-shaped for the title path. docs/d3d12_xs_console_abi.md records the measured ABI. Split from ItsNotRexed#2490 (third of three): fixes the run_tiny_frame failure the revert reported. AI-assisted. Hardware verification on the earlier identical code is in ItsNotRexed#2490's thread (RTX 3060 Ti-5080, RX 7600/9060/9070/7900 XT, Intel UHD, RADV; 177/177). Wine/clang-cl on the build host: xs_proxy_mock PASS incl. the overflow regression, queue_proxy child-runner section fails identically on unmodified main (Wine env), loader_test 86/0 upstream count. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
test_every_variable_is_named_in_a_document fails when a code-used environment variable is documented nowhere. The variable is described in the command-list section where the two list layouts are defined. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Upstream's device routes Xbox slot 73, but returned the real PC list unwrapped: the title's next console-slot call read through the PC vtable. With console_lists the device now builds the real list as ID3D12GraphicsCommandList and wraps it like the slot-12 path; a console IID is answered by the list proxy's QueryInterface.
The title's first call on a wrapped list is QueryInterface with the console command-list IID c3827890-...-51dc4874; is_list_iid knew only PC IIDs and refused it. Port the measured console->PC IID table from (closed, unmerged) ItsNotRexed#7124 into d3d12_xs_command_list_iid.h and run the requested IID through it in list_query_interface and in the PC-mode slot-73 path, so a console IID maps to ID3D12GraphicsCommandList6 and the caller gets the console-shaped proxy back.
create_device_proxy's console_lists default was true, so every test harness that links the TU and calls it directly got console-shaped lists and crashed or failed Close on PC vtable indices (kormocicsaba: d3d12_bindless_churn segfault, d3d12_mesh Close). The console shape is the title path: D3D12XboxCreateDevice opts in (unless LEONIDA_D3D12_LISTS=pc), and the default is now false so direct callers keep the pre-PR behaviour. The mock test pins both: slot 12 on a console_lists=false device returns the real list.
Pipodi measured the retail title calling console list slot 139 with (allocator proxy, pso) before recording — Reset, at PC slot 10. Map it and unwrap the allocator (and a pipeline state the same way); the unwrap now keys on the PC slot so console-10 and console-139 both land on the real Reset. xs_proxy_mock: PASS under Wine Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…2490 (console command-list proxy)
…nd preserve ClearDepthStencilView FLOAT Depth ItsNotRexed#7021 translates title-owned CPU descriptor handles (__XMemAllocationHooks__) on device slots 17-24, and ItsNotRexed#2490 wraps console-ABI command lists in ListProxy, but neither wires translate_cpu_handle into the five graphics command-list methods that consume CPU descriptor handles: - console slot 50 (PC 46): OMSetRenderTargets (RTV array / single-range + DSV) - console slot 51 (PC 47): ClearDepthStencilView (DSV handle) - console slot 52 (PC 48): ClearRenderTargetView (RTV handle) - console slot 53 (PC 49): ClearUnorderedAccessViewUint (CPU handle; GPU kept) - console slot 54 (PC 50): ClearUnorderedAccessViewFloat (CPU handle; GPU kept) Also installs a typed WINAPI thunk for console slot 51 (ClearDepthStencilView): on the Windows x64 ABI, FLOAT Depth (4th argument) is passed in XMM3 rather than R9, so the generic all-uint64_t list_slot template dropped/clobbered Depth before forwarding to the real list. Adds synthetic mock coverage across all five slots (including single-range RTVs, null/zero-RTV cases, count > 8 bounds safety, outside-range passthrough, and XMM3 float preservation) plus an end-to-end WARP/Vulkan GPU clear and readback check in device_proxy_test.
|
Tested I built For the two hardware runs, I changed only the adapter selection in the local fixture. I used DXGI vendor IDs 0x1002 and 0x10DE and checked the printed adapter names. On each adapter, console slot 52 wrote the expected RGBA texel through the hooked descriptor heap. Slot 51 preserved the requested depth of 0.25. Both runs exited 0. I also built the new mock test against parent |
Independent Windows review — PC descriptor-handle mismatch (COMMENT)Tested head: Environment: Windows 11 build 26300, MSVC 19.51, Windows SDK 10.0.26100, WARP. I independently reproduced a wrong-target RTV clear when a PC command list receives a custom CPU descriptor handle returned by heap slot 9. Synthetic reproducer Two RGBA8 textures, A and B, and valid WARP RTV heaps were used. The custom allocation hook supplied a second heap's CPU base. Its descriptor at index 1 already referenced texture B, while the device proxy translated the custom destination correctly when creating an RTV for texture A. The subsequent clear identifies which descriptor the command list actually consumed.
Each configuration was run twice with consistent results. Readback checked all four color channels after fence completion. Control texels remained unchanged. Likely explanation Device slots 17–24 translate custom CPU descriptor handles, and the console However, Consequently, a PC command list receiving a title-owned custom handle may interpret it as an ordinary native descriptor address and operate on a different resource. Scope and question The console path tested here behaves correctly. This finding does not establish a regression in the intended console behavior. Could we clarify the intended contract for PC-mode command lists?
I recommend resolving that scope decision with #2490 and #7021 before opening overlapping implementation work. Related: #7066 also requires destination-handle translation when composed with #7021; that integration point was previously identified and tested independently. Synthetic fixtures only. No proprietary game files, repository changes or publication were involved in the reproduction. AI-assisted investigation using OpenAI Codex. |
|
I reproduced the retail 1.0.2.1 console-list case under Proton CachyOS 11.0-20261015, Gamescope, and RADV on an RX 9070 XT. The test used the same local integration of #2490 and #7021 before and after adding the runtime change from
A separate diagnostic on the baseline tied the failure to console slot 52. The target received by the clear had a missing resource or zero layer count. Both barriers were recorded on the list, and the subsequent Close returned E_INVALIDARG with no open query. With #7880, the same clear was followed by a successful Close. All eight proxy mock invocations passed under Proton, including the console descriptor-handle assertions. On our tested configuration PresentX accepted one plane, the 960 × 540 window appeared black, and the title stopped at Game Init, engine frame 0. We observed no PC ExecuteCommandLists or DrawInstanced in either trace. Queue slot 35 was still unimplemented in both builds. This check used the console ListProxy path. AI-assisted testing. |
|
Retail confirmation from Windows 11 + AMD RX 6900 XT ( AI-assisted (Claude Code). |
|
CachyOS, Wine 11.22, Vulkan, RTX 4070 (620.73.04), AI-assisted. With the slot-139 reset fix held constant, the runtime hunk from |
Integrate the runtime hunk from ItsNotRexed#7880 and extend its synthetic color/depth readback to cover slot 35 and all texels. AI-assisted.
|
Independent integration of 0aba6c3 on the boot ladder with #7949 and the slot-35 routing/array unwrapping from #7286. I ran the same synthetic clear fixture on both runtimes, with console queue slot 35 instead of PC slot 10 and checks for every texel.
Exact integration/test: hah346@389f361. The color/depth result is from synthetic WARP, not a title frame or a Vulkan clear test. AI-assisted; no game data or traces shared. |
|
Tested
I'd opened #8372 for the same change before I saw this PR; it's closed as a duplicate. AI-assisted (Claude Code). |
|
Reviewed Correctness reads clean:
Test limit here: This closes exactly the gap AAyberkU measured on retail (per-frame AI-assisted (Devin); no game files used. |
|
Independent title-path validation on Windows 11 / Vulkan / RTX 5070 Ti (621.24), no guest assertions skipped. Before translating the list-side handles, the first recording error was ClearRenderTargetView in all 29 failed lists in the instrumented run. With slots 50 and 52 translating hooked CPU handles before forwarding, 698 Close calls succeeded and none failed; the title made 106 DrawInstanced calls and 37 successful PresentX calls. Ten actual swapchain readbacks remained black. This covers the RTV fix in a real boot; I did not test the DSV or UAV parts of this PR in that run. |
|
Independent A/B for 0aba6c3 on Wine 11.22, RTX 5070 Ti, NVIDIA 620.73.04. I applied the runtime hunks from that commit to a local stack which already has console lists, heap hooks, #7448 and the #8591 window lookup. Same shader catalog in both runs. Through the first 1,000 successful PresentX calls to the visible title window, failed command-list Close calls dropped from 1,000 to 0 and successful Close calls increased from 1,624 to 2,624. The diagnosed invalid ClearRenderTargetView calls dropped from 1,000 to 0. The visible window still presented black in sampled frames, so the remaining display problem is separate from the RTV recording error fixed here. AI-assisted verification. No game files, images or traces attached. |
Claimed in the coordination issue as: #7694 (comment)
Depends on: #2490, #7021
What and why
#7021translates title-owned CPU descriptor handles (__XMemAllocationHooks__) on device slots 17–24, and#2490wraps console-ABI graphics command lists inListProxy, but neither PR wirestranslate_cpu_handleintoListProxy. When a title recordsClearRenderTargetView(console slot 52) orOMSetRenderTargets(console slot 50) using handles from a hooked descriptor heap, the raw console CPU address reaches the PC/Vulkan command list untranslated and fails.In addition, console slot 51 (
ClearDepthStencilView→ PC slot 47) passesFLOAT Depthas its 4th parameter (XMM3on Windows x64 ABI). The generic all-uint64_tlist_slottemplate readsR9instead ofXMM3, dropping/clobberingDepthbefore forwarding.This commit (
0aba6c361, stacked cleanly on#2490ef9d0759d+#7021355201c51):ID3D12GraphicsCommandListCPU-handle slots inListProxy:OMSetRenderTargets: translates RTV arrays into a stack copy (without mutating caller buffers), respectsRTsSingleHandleToDescriptorRange(reads only[0]), handles zero RTVs / null DSV, and avoids overrunning stack scratch whenNumRenderTargetDescriptors > 8;ClearDepthStencilView: installs a typedWINAPIthunk (list_clear_depth_stencil_view) invtable[51]that preservesFLOAT DepthinXMM3and translatesDepthStencilView;ClearRenderTargetView: translatesRenderTargetView;ClearUnorderedAccessViewUint/ClearUnorderedAccessViewFloat: preservesViewGPUHandleInCurrentHeapand translatesViewCPUHandle.xs_proxy_mock_test.cppcovering all five slots (confirmed red before the fix atom_rtvs[0]and green after) and an end-to-end GPU clear + readback test indevice_proxy_test.cppverifying title-backed RTV/DSV clears and exact0.25fdepth clear preservation throughXMM3.Tested
xs_proxy_mock_testfails on untranslatedOMSetRenderTargetsRTV handles (real_list->om_rtvs[0] == kMockHeapCpuStart + off1).xs_proxy_mock_test: PASS (0failures)device_proxy_test(WARP): OK (0failures, including RTV RGBA(255, 0, 128, 255)and DSV0.25freadback)device_proxy_test(LEONIDA_D3D12=vulkan LEONIDA_VK_VALIDATION=1): OK (0failures,0validation errors)ctest -R ^(xs_proxy_mock|device_proxy|queue_proxy|xbox_present|d3d12_present|d3d12_descriptor|d3d12_clear|d3d12_draw)$withLEONIDA_VK_VALIDATION=1: 8/8 passedscripts/check_no_game_data.pyon all modified files: PASSLEONIDA_D3D12=vulkan): clearedClearRenderTargetView(slot 52) andOMSetRenderTargets(slot 50) handle translation;Close586 ok / 0 failed, advancing intoDrawInstanced. Counts/outcomes only.AI-assisted: yes (Antigravity).
Checklist
docs/design.md, with how it was confirmed. (N/A — runtimed3d12_xsproxy only, no shader translator changes.)