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 |
Only the PR's own commit is applied (its branch is ItsNotRexed#2490ef9d075 + ItsNotRexed#7021, both already here): list slots 50/52/53/54 translate title-owned CPU handles through ItsNotRexed#7021's translate_cpu_handle, slot 51 gets the typed thunk that keeps FLOAT depth. List routing (139, 73, queue 35 unwrap) is unchanged. Mock test keeps every earlier field and check. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
checked: #7880 at 0aba6c3, merged onto main 867d922 (clean merge) | on: Wine 11 on RunPod RTX 4090 (Linux), clang-cl cross-build; not native Windows, host D3D12/WARP comparisons do not run | scope note: this branch is a stack. ran: diff review of What this does not cover (not fixed by this PR, still true at this head): (a) the PC-list path. @fladit123 reproduced on WARP that a PC list ( Not verified: native Windows, WARP or real-device behaviour (the GPU readback test is skipped under Wine), retail boot, the guest runners. agent: yes |
|
Retail boot check on NVIDIA Ampere: this PR clears the per-frame Setup: Windows 11, RTX 3060 Ti, NVIDIA 610.88, MSVC 19.52 RelWithDebInfo, own 1.0.2.1 copy,
No game data. AI-assisted (Claude Code). |
throny
left a comment
There was a problem hiding this comment.
Tested 0aba6c3 on the retail exe boot stack (Windows 11, RTX 4080 610.88): the per-frame Close failure is gone. Failed Close calls go from 196 to 0.
- Base:
ramenbellic:boot/retail-stack(current main) plus about 20 open boot PRs and #7180, MSVC 14.44, RelWithDebInfo,LEONIDA_D3D12=vulkan, translated shaders, offline. Only this PR's own commit was cherry-picked; its dependencies (#2490, #7021) were already in the stack. - Before (one run, stopped at 115 s): 68,902 D3D12 calls, 196
Closefailed, one per frame, on the list that holdsClearRenderTargetViewand the frame'sDrawInstanced. - After (one run, stopped at 214 s): 66,056 D3D12 calls, 0
Closefailed, 837Closeok, 107ClearRenderTargetView, 106DrawInstanced, 213ExecuteCommandListsok. - Not changed by it: no
PresentXcall in either run. - The two runs differ in one local setting besides this PR (driver pipeline compiles limited to 2 at a time before, 1 after), so compare the
Closecounts, not the times. Both runs were stopped by a local memory watchdog, not by a fault. - Merge:
d3d12_xs_device.cppanddevice_proxy_test.cppapplied cleanly;xs_proxy_mock_test.cppconflicted with other open PRs in the stack and I kept the stack's copy, so this PR's mock tests were not run. - Read: the
d3d12_xs_device.cppchange of that commit only, so this is a comment, not an approval.
AI-assisted (Claude Code). Counts and slot numbers only, no game data.
|
Tested Merged onto @tibzejoker's
The run then stops at the same title |
|
checked: #78800aba6c3 | with: Integration note for
|
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
|
Independent Windows/MSVC check of head 0aba6c3 in a temporary integration stack: all 12 targeted startup, XMem, GameInput, proxy and host-memory CTest cases passed. The WARP proxy test exercised title-backed RTV/DSV clears and verified the GPU readback, including depth 0.25. With Vulkan in a Windows Sandbox configured with networking disabled (and guest checks for no active adapters/default routes), dry-run and init succeeded. The retail run passed descriptor heap slots 9/10, recorded 1,187 successful D3D12 calls, and next stopped with a host write access violation after the first forwarded device slot 70. This is consistent with the separate existing slot-70 work in #7066/#8304/#9285; I have not independently proven the exact host instruction's cause. This is progression evidence only, not a rendering or retail memory-coherence validation. |
|
checked: the #7880 own delta passes its mock checks, but our older integration also needed #2490's separate list-139 Reset fix to clear its first Close failure. Linux, Wine 11.18, RX 7900 XT/RADV, clang-cl 23.1.6 + xwin. This is the frozen older integration from our #7746 comparison, not current main or the forge. Same five shader indexes, runner, prefix and display setting throughout; source, patch, executable/PDB and index hashes verified locally. Existing diagnostic stand-ins remain in that base. Three snapshots:
We did not take the newer #2490 IID/default-list-shaping commits or 084c8bd's GameInput change. #7880 production merged with a constants union only. Its mock needed three declared adaptations to the older harness: two Kind::command_list alternatives reduced to Kind::list, and the fifth make_device argument omitted because this harness already defaults to console lists. All #7880 assertions were retained. The typed slot-51 thunk stayed in c3s. Each added snapshot built and ran the same 51-test subset: 45 pass, one corpus skip without its environment, five unchanged failures (device_proxy/device_proxy_trace, the two known Wine startup/TLS cases, d3d12_mesh). All eight xs_proxy_mock modes pass. The WARP device-creation failure prevents #7880's end-to-end clear/readback cases from being exercised here. Two separate negative controls retain byte-identical tests: removing only slot-52 handle translation fails the new translated-RTV assertion; removing only the slot-139 mapping fails the Reset-routing/allocator-unwrapping assertion. Retail: fresh c3q/c3r runs have the same method/outcome counts (2,334 calls, one failed Close), with a queue-event ordering variation. c3s uses that recent c3r run as its hash-verified control: 2,336 calls, zero failed traced outcomes, one new successful Reset, and Close changes from failed to successful. A console-only queue event occurs twice rather than once. The old failure's HRESULT is not logged, so “already closed” remains a mechanism inferred from source; the isolated Reset change demonstrably removes the failure. All three still hit the same worker-thread title breakpoint and exit 3. The 11 untraced slot-67 failures (eight missing programs), format-65 allocation warning and allocator-slot-9 refusal remain. PresentX is ready, but no PresentX call or rendered frame is established on these runs. Clearing Close is therefore insufficient to clear that assertion. This is an older-base integration result, not a general failure verdict on #7880. AI-assisted (Codex review; Claude execution). agent: yes |
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.)