Commit Graph

159 Commits

Author SHA1 Message Date
54840e3e92 Merge branch 'pr7201' into ladder-frame
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 19:29:28 +01:00
ccf7bb95dd Merge branch 'pr7323' into ladder-frame
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 19:28:39 +01:00
1c2cfd6087 Merge branch 'pr7115' into ladder-frame
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 19:25:43 +01:00
bbe2b4a759 Merge branch 'pr7163' into ladder-frame
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 19:24:25 +01:00
a3eae955dc d3d12: slot 133's third argument is a barrier layout; a placed texture starts in the matching state
The title's third word at slot 133 is a D3D12_BARRIER_LAYOUT, not a resource state (measured by
@dracbat on a retail boot: 0x6 SHADER_RESOURCE for its RT/DS textures, 0x3 UNORDERED_ACCESS for its
RT+UAV ones, 0xFFFFFFFF UNDEFINED for the 182 MiB buffer), as PC CreatePlacedResource2 takes it. The
proxy passes it to the handler, and a texture's ordinary committed fallback starts in the equivalent
legacy state (UNDEFINED and unlisted values give COMMON; a state the description refuses retries with
COMMON, so the title always gets its resource). Buffers are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 19:10:29 +01:00
ffc6f6da01 ladder: port the xs_proxy_mock checks of #7110, #7052 and #7240
One PC slot 76 mock records for both the slot 133 and the slot 127 checks;
one slot 27 mock keeps #7075's record and #7240's generic path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 19:04:51 +01:00
3eba4c9c9a Merge branch 'pr7066' into ladder
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 18:54:06 +01:00
4081189163 Merge branch 'pr7021' into ladder
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 18:53:28 +01:00
e7e97ab223 Merge branch 'pr7075' into ladder
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
2026-11-23 18:53:05 +01:00
31d7caf987 Merge branch 'pr6953' into ladder 2026-11-23 18:52:50 +01:00
175dc3f2da Merge branch 'pr2490' into ladder
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 18:52:49 +01:00
ec75996541 Merge branch 'pr6954' into ladder
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 18:52:17 +01:00
e29e989980 d3d12_xs: handle ID3D12CommandAllocator slot 9 (SetAllocatorCallbackX) on allocator proxy 2026-11-23 14:46:12 -03:00
0aba6c3611 d3d12_xs: translate title-owned CPU descriptor handles in ListProxy and preserve ClearDepthStencilView FLOAT Depth
#7021 translates title-owned CPU descriptor handles (__XMemAllocationHooks__) on
device slots 17-24, and #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.
2026-11-23 17:41:55 +00:00
ce3f2dbdef Merge #7021 (descriptor heap XMem hooks) into #2490 (console command-list proxy) 2026-11-23 17:34:26 +00:00
ef9d0759d2 d3d12_xs: route console list slot 139 (Reset) to PC slot 10
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>
2026-11-23 10:14:43 -07:00
04fdf377f0 Refresh the Xbox fence value after a rewind
Refresh the slot 12 mirror when the completion wait times out. Keep the existing pending fence event so a rewind cannot accumulate duplicate registrations.

The mock test covers a CPU rewind followed by progress below the old threshold and a rewind from outside the proxy. Original fails and patched passes in five runs each on Wine 11.20. AI-assisted.
2026-11-23 16:52:09 +00:00
310773a01c d3d12: slot 133 review fixes: no write-combined import, committed-range check, immediate free, proxy test
- A write-combined (or uncached) page in the range is not imported: an RTX 5090 imported such a range
  and read wrong bytes back (found in review). It takes the ordinary-buffer fallback.
- The whole range must be committed, walked with VirtualQuery across allocations (the retail buffer
  spans three mapped windows); otherwise E_INVALIDARG instead of undefined behaviour in Vulkan.
- The imported memory is freed as soon as the submitted work has retired (wait_retire_ticket), not
  after the next submission: VK_EXT_external_memory_host needs the caller's pages to outlive it, and a
  title may free them right after releasing the resource.
- The PC flag mask is 0x5ff: 0x200, which the host refuses, is dropped. Slot 133 is listed in
  device_slot_overridden.
- xs_proxy_mock_test registers a handler and checks slot 133's argument positions, the flag mask
  (0x20204 -> 0x4), the ROW_MAJOR rewrite and the iid; d3d12_existing_heap_test checks the
  write-combined fallback and the partly committed refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:49:03 +01:00
5be2fd2873 d3d12_xs: default direct device-proxy callers to PC-shaped lists
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.
2026-11-23 09:48:58 -07:00
e0b300f02b d3d12_xs: slot 133's fourth word is a barrier layout; create through CreateCommittedResource3 with it
The word slot 133 passes after the description is a D3D12_BARRIER_LAYOUT, not a resource state:
the title passes all ones (UNDEFINED) for its first buffer and 6 (SHADER_RESOURCE) for 1x1
render-target and depth textures. Read as a state, 6 is INDEX_BUFFER | RENDER_TARGET, which the
PC device refuses for a texture, and the title then asserts on the missing resource.

On a PC device with ID3D12Device10 the resource is created through CreateCommittedResource3 with
the layout as given (UNDEFINED for a buffer). An older device gets CreateCommittedResource with the
legacy state of that layout, COMMON for UNDEFINED and for layouts that have none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:47:47 +01:00
1d8d1d355d d3d12_xs: slot 70 takes its buffer reference under the registry lock and asks for a buffer that holds the whole width (review of the raw view)
AI-assisted.
2026-11-23 17:46:16 +01:00
9c8522d224 d3d12_xs: slot 70 writes a raw buffer view when its words are the measured raw-buffer shape and the VA is a buffer the layer knows (retail boot chain stop 14)
AI-assisted.
2026-11-23 17:43:57 +01:00
8e765684ce xs_proxy_mock_test: use fixed array for 1025-descriptor slot 108 check 2026-11-23 17:43:23 +01:00
3c95a4a95f d3d12_xs: map the console list IID in QI and CreateCommandListX
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) #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.
2026-11-23 09:42:45 -07:00
343e171890 d3d12_xs: remove 1024-descriptor cap in slot 108 and test 1025-element batch 2026-11-23 17:41:48 +01:00
a30e78ee77 d3d12_xs: slot 74 counts its hit before an override can take it; the precedence test now proves the override ran (#7231) 2026-11-23 17:30:36 +01:00
cdeee35aa8 d3d12_xs: device slot 74 (pointer, u32, pointer) returns S_OK instead of reaching PC ShaderCacheControl (#7231)
The retail title calls slot 74 once; the PC slot 74 reads the first pointer as kinds and returns E_INVALIDARG, so the title hits an int3. The proxy handler does not call the PC device, writes nothing, logs the three words once, and yields to an env slot override that moves a route onto 74.
2026-11-23 17:28:57 +01:00
662ef24c46 d3d12_xs: wrap slot-73 CreateCommandListX lists in the console proxy
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.
2026-11-23 09:26:36 -07:00
a2efc80b93 d3d12_xs: use 56-byte D3D12_RESOURCE_DESC stride for slot 108 descriptor array 2026-11-23 17:26:35 +01:00
08490f05d2 d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path
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 #2490 (third of three): fixes the run_tiny_frame failure
the revert reported. AI-assisted. Hardware verification on the
earlier identical code is in #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>
2026-11-23 09:24:20 -07:00
626beeb8f7 Merge remote-tracking branch 'origin/main' into slot133-host-va
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
2026-11-23 17:23:22 +01:00
5ac4deaa2c d3d12_xs: fence slot 12 returns the address of a live completed value
The retail executable calls fence slot 12, one past ID3D12Fence1, as
(value, descriptor, flags) and reads the return as a pointer to the
fence's 64-bit completed value: it compares it with ~0 and subtracts the
value it waits for. The proxy refused it with E_NOTIMPL, which the title
then dereferenced.

Each fence now gets a mirror on its first slot 12 call. A wait-thread
callback reads the real fence's completed value into it and re-arms
SetEventOnCompletion(value + 1), so it follows every completion without
another call; slot 12 and the CPU Signal refresh it at once, under a lock.
After device removal it holds ~0 and nothing is re-armed. The release of
the proxy unregisters the wait before the real fence goes. The
descriptor's code pointer is not called.

Tests: xs_proxy_mock_test (mock fences now keep a completed value and
arm one event) and queue_proxy_test (a real queue signal reaches the
mirror).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:23:17 +00:00
72ab7623e2 xs proxy test: 32-byte queue desc for slot 48; docs credit #6954
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:19:47 +01:00
084c8c60e7 d3d12_xs: read the console argument type as its 32 bits (clang-cl)
105 is outside D3D12_INDIRECT_ARGUMENT_TYPE's range [0, 15], so clang-cl
rejects a constant expression that casts it to the enum (reported by
umnitus on #7163). The handler now reads each argument's Type field as a
uint32_t through memcpy and compares it with 105; the test writes and reads
the raw value the same way, and the mock records it the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:17:22 +01:00
dc29ee3471 d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8 2026-11-23 17:10:24 +01:00
cac1fc0cd7 xs_proxy_mock_test: the slot 133 case sits after the allocator section and runs on its own line, clear of the slot 73/list changes in #7076
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:07:44 +01:00
4c04c0f4e3 d3d12_xs: a console indirect argument of type 105 is created as DISPATCH (slot 41)
The retail title creates five one-argument command signatures with no root
signature at startup (device slot 41, CreateCommandSignature at its PC
position). One has the console argument type 105 and a 12-byte stride, next
to a DISPATCH and a DISPATCH_MESH of 12 bytes. The PC layer refuses the
unknown type, which is stop 19 of the RT-5 boot measurements.

Read statically from the title's call sites (shapes only): the two
ExecuteIndirect sites of that signature pass MaxCommandCount 1 and an offset
into the same argument buffer as the DISPATCH sites. Right before, they set
the same compute state as the DISPATCH path (pipeline, compute root signature,
tables, constants, SRV and UAV); they record on a second command list of the
title's context. So the argument is taken as a D3D12_DISPATCH_ARGUMENTS.

Slot 41 now has its own handler. A description that holds type 105 is copied
with that type replaced by DISPATCH (logged once). Any other description is
forwarded as the same pointer. What the console does differently for type 105
is left open in docs/d3d12_vulkan.md (section 4.9).

xs_proxy_mock_test: a two-argument description (a root constant, then type
105) reaches the PC slot 41 as a copy with DISPATCH, the same stride, count,
root signature, IID and output, and the caller's description is untouched; a
PC description is passed through unchanged. With main's d3d12_xs_device.cpp
the new check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:05:11 +01:00
edd0091db6 Merge remote-tracking branch 'origin/main' into rt-xs-slot133-placed-resource
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-23 17:03:46 +01:00
0d73e8b95d Merge origin/main: slot 26 next to the Xbox slot routes
AI-assisted.
2026-11-23 16:59:58 +01:00
d5c9490611 d3d12_xs: an env override that moves an Xbox route onto device slot 70 wins over the built-in slot 70 handler
With LEONIDA_XS_FRAME_INTERVAL_SLOT=70, (0, 16667, 1, 0) reached the null-SRV writer and sent latency 1 as the CPU descriptor handle. The routes now live in route_xbox_device_slot, which slot 70 asks first. New xs_proxy_mock_env_slots_70 test fails before and passes after.
2026-11-23 16:59:43 +01:00
e22994464b d3d12_xs: Xbox device slot 61 is CreateSamplerX, routed to the PC CreateSampler
The retail title calls device slot 61 as CreateSamplerX(desc, dest handle), once
per sampler, after its descriptor heaps exist (stop 20 of the RT-5 boot
measurements in the coordination issue). The generic thunk forwarded it to the
PC slot 61, which is CreateMetaCommand, so the sampler was never written.

Slot 61 now has its own handler, like 62 and 67. It passes the description's
PC D3D12_SAMPLER_DESC prefix and the handle to the PC CreateSampler (slot 22).
That was enough to get the title past this call under Wine. Whatever follows
the prefix in the console description is not known and is not read. A null
description is skipped and logged once. A handle in the title's own heap range
is #7021's translation.

xs_proxy_mock_test: slot 61 reaches the mock's slot 22 with the same two words
and never its slot 61; a null description reaches nothing. With main's
d3d12_xs_device.cpp the new check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:57:30 +01:00
f20e99a528 Merge main 108c36ef7 into #6954
Slot 48 goes through proxy_create_command_queue_xbox (filtered 16-byte prefix) via main's
queue_x route; the explicit slot 48 branch and the duplicate note_slot are gone. The
slot-48 header, slot name and tests follow, and device_proxy_test passes a 32-byte desc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:56:08 +01:00
3073250df5 d3d12_xs: Xbox device slot 70 writes a null shader-resource view instead of reaching PC CreatePlacedResource1 (retail boot chain stop 14) 2026-11-23 16:50:56 +01:00
11aee7e0a8 d3d12_xs: device slot 133 places a resource as a committed DEFAULT one (CreatePlacedResourceX stand-in)
Xbox device slot 133 is (va, desc, initial_state, clear_value, riid, out), the shape of the console's
CreatePlacedResourceX. With #6953 the call reaches the beyond-table refusal and the title asserts on the
E_NOTIMPL. The proxy now answers it before that refusal: a committed DEFAULT-heap resource from the
description with the PC flag bits only, slot 76's layout rule, COMMON for a buffer or the all-ones state,
and the clear value only for render-target and depth textures. The resource is not backed by the memory
at va; that needs the physical-page mapper.

xs_proxy_mock_test: a mock CreateCommittedResource that records its arguments, and a slot 133 case over a
76-slot device (buffer, render target, all-ones state, null arguments, a failed creation). The
beyond-table check moves to slot 134.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:47:55 +01:00
2dbcb882c9 d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 (#6935)
Squash-merged after diff review of PR #6935 - d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80
2026-11-23 09:42:42 -06:00
355201c51e d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles 2026-11-23 23:42:40 +08:00
86b8e04e4c d3d12_xs: device slot 26 takes the console's struct-return form
The retail executable calls GetCustomHeapProperties with the return buffer in RCX and the device in RDX. The forwarder took RCX for the proxy and faulted.

AI-assisted.
2026-11-23 16:33:12 +01:00
0cde63d618 d3d12_xs: device slot 48 creates a command queue proxy from the 32-byte Xbox description
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:30:47 +01:00
4b76715cf6 d3d12_xs: extend the device proxy table to 192 slots so slots past the PC vtable refuse with E_NOTIMPL
The retail title calls device slot 133, past the 128-entry table; the call read an empty entry and jumped to 0.
Every slot beyond the PC device's vtable now reaches the generic thunk. Mock test covers slot 133.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:30:44 +01:00
57c175391d Revert #2490: its console-ABI list proxy breaks run_tiny_frame (please rebase and split)
With it, d3d12_xs reads list slot 48 as the console's IASetVertexBuffers, so the PC-shaped fixture list's
ClearRenderTargetView never runs and Close fails. The branch also changes runtime/src/pe_loader.cpp and carried
committed conflict markers in docs/fssm_crosscheck.md. Its docs rows go with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:42:53 -05:00