Commit Graph

24 Commits

Author SHA1 Message Date
81e8a6f2a4 d3d12_xs: device slot 127 creates the committed resource (CreateCommittedResource3 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 #6982.

(cherry picked from commit 8d622049ae)
2026-11-23 22:14:29 -06:00
9bc1f8f1a8 xs_proxy_mock_test: device slot 25 in the console's form and the PC's
The mock device answers GetResourceAllocationInfo, and the new case calls slot 25 with the return buffer in RCX
and the device in RDX, then in the PC form: both reach the PC method with the mask, count and descriptions, and
only the struct is written.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 21:54:57 -06:00
f9d20bf9b0 d3d12_xs: Xbox device slot 70 writes a null shader-resource view instead of reaching PC CreatePlacedResource1 (retail boot chain stop 14)
(cherry picked from commit 3073250df5)
2026-11-23 21:52:25 -06:00
9e6f8ae133 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>
(cherry picked from commit 0cde63d618)

Adapted to main by Mumogg: main already routes slot 48 through its Xbox slot table (LEONIDA_XS_QUEUE_X_SLOT),
so the route now calls proxy_create_command_queue_xbox instead of a fixed slot 48 branch, and xs_proxy_mock's
check_xbox_slots and the environment case pass the console's 32-byte description.
2026-11-23 21:48:33 -06:00
c4954581ae 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.

(cherry picked from commit 86b8e04e4c)
2026-11-23 21:46:43 -06:00
868002b0d8 Merge remote-tracking branch 'origin/pr/9745' 2026-11-23 17:24:48 -05:00
cb29a2b88f d3d12_xs: slot 133 commits the buffer's xmem pages before the host-pointer import
xmem commits physical pages on first touch (#7556), so a range the title has
mapped but not written yet is still MEM_RESERVE when it places a buffer on it
through device slot 133, and the Vulkan layer's import (#7218) refuses reserved
pages and answers with its fallback buffer, which the title's writes never reach.

Slot 133 now calls a registered pages hook (set_placed_at_va_pages_hook, next to
set_placed_at_va_handler) with the buffer's range before the handler; gta6rt
registers rt::xmem::commit_physical_range. A failed commit is logged once and the
handler still runs. Textures don't call it. The Vulkan layer doesn't link xmem.

Tests: xs_proxy_mock_test checks the hook order, arguments, failure and texture
cases; the new d3d12_xmem_placed_test places a buffer on untouched xmem physical
pages and checks the fallback without the hook, and with it the import and a GPU
copy reading the CPU's writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 18:51:49 -03:00
d90903a631 d3d12_xs: implement console ListProxy with cursor pinning and queue unwrapping
- Implement ListProxy for Xbox-ABI command lists returned by slot 73
  (CreateCommandListX) with 160-slot vtable and inline cursor pinned to limit
- Keep slot 12 (CreateCommandList) returning unwrapped PC-shaped list so
  desktop test harnesses (run_tiny_frame, tiny_frame.cpp) keep slot 48
  (ClearRenderTargetView) working without regression
- Route console command list slots:
  * 0..26: PC order
  * 27..30: unforwarded console extras
  * 31: ExecuteBundle (unwraps bundle command list proxy)
  * 32: SetDescriptorHeaps (unwraps heap proxies via UnwrappedArray)
  * 33..59: shifted +4 to PC slots 29..55
  * 60: EndEvent -> PC slot 58
  * 61: ExecuteIndirect -> PC slot 59
  * 85: CopyTextureRegionX -> PC slot 16
  * 146: Barrier -> PC slot 80 (ID3D12GraphicsCommandList7)
  * 148: AllocateUploadMemory stub (returns null, logged once)
  * 10: Reset unwraps allocator proxy and re-pins inline cursor
- Unwrap command list proxies in queue slot 10 (ExecuteCommandLists)
- Add comprehensive mock tests verifying routing, pinning, and unwrapping
2026-11-23 21:09:38 +01:00
57a0fc4caf d3d12_xs: declare console_to_pc_list_slot and verify slot mapping 2026-11-23 19:48:12 +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
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
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
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
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
9b693ecd8a d3d12_xs: name the measured list tail slots in the first-call log
D3-445, contributed by shdann (tested on Windows 11, MSVC 14.51, RTX
4090; xs_proxy_mock passes, negative control fails as designed).

From CopyTextureRegionX on, the newer console layout sits two slots
later than the older one (docs/d3d12_xs_console_abi.md 5.3). A table
keyed by the older-layout slot gives every measured pair one name, so
list slot 85 under the newer layout and 83 under the older both log
"CopyTextureRegionX"; the seven unmeasured pairs print "tail method,
older slot N". A slot gets no name while the layout is unknown or when
it is not a measured slot of that layout, so a number never wears the
other layout's name. Naming only - console_to_pc_list_slot and the
forwarding are untouched.

Co-Authored-By: shdann <28006689+shdann@users.noreply.github.com>

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 19:00:35 -07:00
92848ba954 shims: undetected queue slot 18 answers the frequency getter
shdann's second case on #2490: a title reads the timestamp frequency at
start-up, before any fence call has detected the layout. Slot 18 then
went to the PC GetDesc - a struct-return write of a whole desc through
a caller that passed an 8-byte out pointer - so the frequency came
back unset (and the write overran).

While the layout is still unknown the call is served as the newer
layout's GetTimestampFrequency instead: an 8-byte write stays inside
either interpretation's buffer. A queue or device already proven
older keeps the generic GetDesc forward; slots 19 and 20 stay no-ops
because their newer interpretations write through caller pointers an
unmodelled older method might not supply.

The mock queue's slot 16 now writes a fixed frequency (unless the
argument is a mock object - then it is a newer Signal's fence), and
check_signalx_detection covers the undetected query and the post-
detection shifted path.
2026-11-22 18:34:12 -07:00
3693ce73e6 d3d12_xs: let a fence at SignalX slot 25 carry the newer-layout evidence
shdann's report on #2490: on a device whose queue layout is still
undetected, the first SignalX at slot 25 answered S_OK without
signalling — the fence never completes and a title waiting on that
value hangs. The Signal/Wait detection at slots 16/17 only helps a
title that calls them; one that signals exclusively through SignalX
(the console-native path) would lose every signal, not just the first.

Per the measured table (docs/d3d12_xs_console_abi.md §4) the
fence-first queue methods are Signal/Wait/SignalX only, so a proxy
fence arriving at slot 25 while the layout is fully unknown is the
newer layout's SignalX: mark the shared detection newer and forward it
as Signal. A proven-older device still leaves slot 25 to the
console-only no-op, and a fence at slot 23 forwards without pinning so
a newer title's own SignalX detection stays open.

The mock's new check_signalx_detection covers the lost-signal repro
(hr=0 calls=0 on the first SignalX), detection inheritance on a second
queue, the proven-older no-op at 25 and the non-pinning forward at 23.

Written with AI assistance (Devin). Verified with the clang-cl/xwin
cross-build under Wine: xs_proxy_mock_test PASS, loader_test 87/0.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 18:00:25 -07:00
6e81f46bbc shims: translate the two VAs of each stream-output view
SOSetTargets (console 49) carries BufferLocation and
BufferFilledSizeLocation, both GPU VAs; both now translate through the
upload arena in the proxy's scratch copy.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:05:48 -07:00
2de9fce57c shims: translate upload-arena VAs inside the IA view structs
IASetIndexBuffer (console 47) and IASetVertexBuffers (console 48) carry
GPU VAs inside their view structs rather than in an argument word. The
list proxy now rewrites BufferLocation through upload_translate on a
copy — a stack copy for the index view, a scratch array on the proxy
for the vertex views — so a pointer AllocateUploadMemory handed out is
usable for index and vertex data the same way a root descriptor is.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:05:48 -07:00
3c04837381 shims: AllocateUploadMemory and root-descriptor VA translation
Console list slot 148 carves from a bump arena of persistently-mapped
UPLOAD-heap buffers, so the pointer a title writes is the same memory
the GPU samples. The six root descriptor setters (console 41-46)
translate an arena address to the chunk's buffer device address before
forwarding; other VAs pass through. A device that cannot hand out a
mapped buffer falls back to private memory so the call still returns
something writable.

The mock test now models command lists end to end: creation unwraps
the allocator proxy, the console body exposes the pinned cursor,
console-only slots are recorded without forwarding, slot 148 hands out
aligned arena pointers and slot 43/146 reach the real list.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:02:45 -07:00
2be25cee2c shims: wire the measured PresentX queue slots to the presentation core
Queue slots 30 (older layout) and 32 (newer) are the measured PresentX
entry points, with SignalX at 23/25. The queue proxy now detects which
of the two documented console layouts a title uses — a fence reaching
slot 16/17 marks the newer layout — forwards SignalX as PC Signal, and
lazily builds the windowed presentation core for PresentX under
LEONIDA_VULKAN_DEVICE.

Unmodelled console-only queue methods answer S_OK instead of E_NOTIMPL
because frame pacing flows through them; they are still never forwarded.
The mock test now asserts that contract.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 16:57:41 -07:00
2123a02506 Runtime: Xbox-ABI proxy for the command allocator (device slot 9)
Device slot 9 (CreateCommandAllocator) now returns an allocator proxy,
the fourth command object after the queue and fence (BUILD-231) and the
list (D3D-136): the public chain (9 slots, Reset at 8) is forwarded, a
slot past it up to the end of a 64-slot table is logged and refused with
E_NOTIMPL, and a read past the table faults in its own guard region. The
console allocator's extra methods are not measured and not guessed.

A list takes the title's allocator in CreateCommandList and Reset, so a
proxy is only safe where the list side resolves it. Slot 9 therefore
wraps an allocator only when it answers kLeonidaCommandAllocatorTag (the
Vulkan layer's CommandAllocator, whose from() resolves the proxy for both
calls); a PC runtime allocator is handed out unchanged, logged once,
until a command-list proxy unwraps it at Reset. Allocator proxies are
unwrapped in the residency calls like heap, queue and fence proxies.
Device slot 12 is not touched.

Tests: allocator_proxy_test (WARP, a hardware adapter, the Vulkan device:
forwarding, refused tail, guard region, identity, D3D12's allocator rules,
a list created and Reset on the proxy with GPU copies through the queue
and fence proxies read back), mock cases for allocators with and without
the tag and their failure paths, and device_proxy_test's slot-9
expectations. No game files.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:11:53 +01:00
62593f47ca Runtime: Xbox-ABI proxies for the command queue and the fence (BUILD-231)
Device slots 8 (CreateCommandQueue), 75 (CreateCommandQueue1), 36
(CreateFence) and 32 (OpenSharedHandle of a fence) now return queue and
fence proxies. They forward the public chain in PC order (19 queue slots,
11 or 12 fence slots), refuse and log a slot past it up to the end of the
proxy's table, and name a read past the table through a guard region and
a vectored handler.

Heap, queue and fence proxies are unwrapped wherever a device or queue
method hands them to the real runtime: queue Signal/Wait, device slots
31/34/35/45/46/50. Arrays are copied without exceptions. QueryInterface
answers only the modelled interfaces, and logs one the real object has
but the proxy does not model. Outputs are cleared on failure as for
slots 14/62/76. --trace-d3d12 records proxy calls in the README grammar.
Every function a thunk hands its words to keeps them in the same
positions, because a title passes only as many as the method takes.

Tests: queue_proxy_test (host WARP, host hardware, Vulkan device;
differential per-process error cases, guard faults, identity, threads,
raw-slot client, child-runner self-test), xs_proxy_mock_test (older
devices, fences without Fence1, OpenSharedHandle branches, allocation
failures; three guard-setup fault modes), and device_proxy_test through
the D3D12XboxCreateDevice shim. No game files.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:08:53 +01:00