Commit Graph

4696 Commits

Author SHA1 Message Date
7aa5d60ae3 Merge remote-tracking branch 'ubiq/main' into feat/xs-frame-pacing-presentx
# Conflicts:
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-24 03:03:24 -03:00
f423c90462 d3d12_xs_device: slot 73 retries a console list IID as ID3D12GraphicsCommandList
Reduced to what main does not already have: slots 25/26 (struct return) and
48 (queue desc sanitize) landed on main, and the slot 58 forwarder is dropped
(PC vtable slot 58 is ID3D12Device5::RemoveDevice, not
GetResourceAllocationInfo1, and no call to Xbox slot 58 is measured).

CreateCommandListX passes the title's console command-list IID, which the PC
device does not know (docs/retail_boot_chain.md 3.3). On E_NOINTERFACE for an
IID that is not a PC list IID, create the list once more as
ID3D12GraphicsCommandList and hand out the console list proxy. A PC list IID
the device refuses still fails as before.

AI-assisted. Tested: xs_proxy_mock_test new checks with clang 23 / mingw x64
(a pre-existing kLong allocation-injection check does not fire under mingw, so
the full run needs MSVC/CI).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:03:10 -03:00
bff649b34d Merge remote-tracking branch 'ubiq/main' into feat/xs-device-vm-options
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_device.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-24 03:01:27 -03:00
a02134a9c6 lifecycle: hook only the title window, end through ExitProcess, fix unregister race
- Only the title's first top-level window (no parent, not WS_CHILD, not
  WS_EX_TOOLWINDOW) is fitted to the work area and gets the SC_CLOSE hook;
  WM_NCDESTROY releases the claim. Other windows the title creates are left
  alone instead of ending the process on close.
- The suspend thread and the 1 s deadline end the run through the title's own
  ExitProcess shim (process.cpp end_run), so the host finishes its cleanup,
  instead of TerminateProcess.
- Suspend callbacks run under the (now recursive) registration lock and each
  id is looked up again before its call, so a routine never runs after
  UnregisterAppStateChangeNotification returned, and an unregister from inside
  a callback works.
- docs/runtime_imports.md: speech, XLauncher and XAppCapture text matches the
  code; new lifecycle shim paragraph.
- lifecycle_test: unregister-from-callback and title-window claim checks.

AI-assisted. Tested: lifecycle_test (29 checks), xgameruntime_offline_test
(69 checks), docs and gdk_runtime_calls pytest; clang 23 / mingw x64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:00:33 -03:00
86ba7556ba test: gate VIDEO_ENCODE allocator parity on host video support 2026-11-24 08:58:15 +03:00
9f9a503406 Submission barrier: not on a context without vkCmdPipelineBarrier
The full memory barrier each submission now starts with (0589ffe88) called
vkCmdPipelineBarrier unconditionally; replay_query_edges_test's mocked
query-only context supplies no such entry point and crashed (access
violation) in its queue segment case. A real device always has it; the
barrier is skipped when the pointer is null.

Test: replay_query_edges_test passes again (crashed after 0589ffe88);
vk_queue_test still sees 4 of 4 submissions start with the barrier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:50:59 -08:00
6e81b92199 Every submission starts with a full memory barrier (ExecuteCommandLists boundary)
D3D12 ends every ExecuteCommandLists with its work done and its writes
visible to the next one on the queue (implicit state decay relies on it), so
a list may touch memory an earlier submission wrote without any barrier: two
submissions copying into one buffer, say. Vulkan orders submissions on a
queue only by what their barriers say, and nothing in a VulkanQueue's command
buffer ordered it after the previous one. Synchronization validation
reported it on leonida/work: vk_queue_test's back-to-back copies into one
buffer, WRITE_AFTER_WRITE between submissions (10 errors, the test failed
under LEONIDA_VK_VALIDATION=1).

execute_now now records an ALL_COMMANDS -> ALL_COMMANDS memory barrier
(MEMORY_WRITE -> MEMORY_READ | MEMORY_WRITE) right after
vkBeginCommandBuffer.

Test: vk_queue_test 4b counts the command buffers begun and those whose first
barrier is that one, over two submissions each on the direct and the copy
queue: 4 of 4 (0 before). Under LEONIDA_VK_VALIDATION=1 the whole test now
has 0 validation errors (RTX 3080 Laptop).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:50:58 -08:00
82dcf6dedc Merge remote-tracking branch 'ubiq/main' into feat/gdk-speech-display-lifecycle 2026-11-24 02:46:10 -03:00
d7cdfcf255 ws2_offline: per-socket extension pointers, refuse name-service lookups, close connect-by-name and octal bypasses, cover wsock32
Review fixes for #357:
- ConnectEx / WSASendMsg wrappers ask the host for the pointer of the socket they run on, instead of one
  process-wide pointer that the last WSAIoctl on any provider overwrote.
- WSALookupServiceBeginA/W fail with WSASERVICE_NOT_FOUND.
- WSAConnectByNameA/W hand the host the literal 127.0.0.1 for "localhost", so the hosts file is never read.
- A dotted octet with a leading zero (0127.0.0.1) is refused: Windows reads it as octal.
- wsock32.dll maps bind/connect/sendto/gethostby*/WSAAsyncGetHostBy* (names and ordinals) to the same wrappers and
  stays host-owned in owns_dll, like ws2_32.dll.
- docs/runtime_imports.md no longer says a --run can open real sockets; it names the dnsapi.dll gap.

Tested: ws2_offline_test built with clang 23 (msys2 clang64) on Windows: 52 checks, 0 failures. MSVC build not
available locally; CI covers it. tests/test_docs_*.py, test_text_write_line_endings.py, test_runtime_paths.py pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 02:42:07 -03:00
1c69700851 store: offline *Async slots start and complete their XAsyncBlock with E_FAIL (M11)
The offline XStore table returned E_FAIL synchronously without ever starting the caller's XAsyncBlock, so a title that waits on the block (XAsyncGetStatus wait=true) or on its completion callback hung forever. Each *Async slot now locates its block by argument position and runs it through XAsyncRun, failing with E_FAIL; the Result partners keep returning E_FAIL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:38:18 -08:00
7f7a596856 Merge remote-tracking branch 'ubiq/main' into feat/ws2-offline-shim
# Conflicts:
#	scripts/build_runtime.ps1
2026-11-24 02:34:35 -03:00
77f44fbe3b xg_xs: lay out console textures and serve the texture computer (RT-XG-TEXTURE-COMPUTER)
XGSuggestSwizzleMode and every texture-computer slot returned E_NOTIMPL, so the
title's texture layout and copy calls did nothing. They now run on a model of
the GFX10 texture layouts (runtime/src/console_texture_layout.h, AMD addrlib's
rules for the linear, 256 B, 4 KiB and 64 KiB modes): the suggested mode, the
layout structure (slot 2), element offsets (slot 6), copies into and out of a
subresource (slots 8 and 9) and the 64 KiB tiling (slot 10).

A description the model cannot lay out still gets a computer in *out (with
E_INVALIDARG), as before, because two measured callers use *out without
checking the HRESULT. Not modelled: compression metadata planes and the XOR
and MSAA modes' addressing (E_NOTIMPL).

The layout model, the computer's method table and the layout structure are
ported from Marvisak/VIctory (GPL-3.0), crates/victory-formats/src/texture.rs
and crates/victory-hle/src/modules/xg.rs at d2a4bae1f, credited in the files;
the addrlib notice is kept. xg_xs_test now checks the model (hand-checked
addresses, mip tails, a two-plane depth-stencil, a bijection and round trip
over every element of ten layouts) and the shim's slots: 106 checks, MSVC /W4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 06:32:30 +01:00
6c1d939509 runtime: honor LEONIDA_TITLE_MEMORY_MB in XSystemGetAppMemoryUsageLimit and XMemGetWorkingSetStatistics 2026-11-24 00:21:59 -05:00
cfb3436369 vulkan_replay: honor format alignment, block size, and depth in tile_footprint staging 2026-11-24 13:11:13 +08:00
8f481cf16f Merge pull request #393 from oddmaniv/fix/test-fs-host-drive
test: keep host fixtures unambiguous on G: and T: (TEST-FS-HOST-DRIVE)
2026-11-24 00:09:56 -05:00
29f66ba0fe Merge pull request #389 from lines9686-rgb/dxgi-resizebuffers-lost
OLD-8171: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host
2026-11-24 00:09:51 -05:00
e210804659 Merge pull request #369 from Mumogg/slot127-committed-resource3
d3d12_xs: device slot 127 creates the committed resource, again (RT-SLOT127)
2026-11-24 00:04:49 -05:00
11d44eee9f queue_proxy_test: the PresentX slot is called and counted
The coverage gate asks for every queue slot to have been called, and skips the overridden ones in its sweep of
the refused tail. Slot 32 is overridden since the PresentX wiring, so nothing called it and the gate failed
("queue slot 32 never called"). The test now calls it where it calls the console ExecuteCommandLists slot: this
build of the proxy has no presenter, so the answer is S_OK.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 23:03:47 -06:00
2a2b1680c6 Merge pull request #362 from Mumogg/slot25-struct-return
d3d12_xs: device slot 25 takes the console's struct-return form too (RT-SLOT25)
2026-11-24 00:00:31 -05:00
361e8455a2 cpu_emulation: run a whole CLZERO zeroing loop in one emulated step 2026-11-24 05:54:10 +01:00
c9099b0cad vulkan_replay: validate backing buffer_offset alignment in prepare_buffer_uav_clear (VK-UAV-CLEAR-ALIGN) 2026-11-24 12:52:58 +08:00
21a6c617bc PresentX: device-side WaitFrameEventX and the frame pacer share one token source
Device slot 80 (WaitFrameEventX, from #6935) numbered its tokens with a
counter of its own, while XboxPresentation's pacer refuses any token above
the ones it issued itself. A title that waits through the device and
presents through the device's XboxPresentation therefore had every
PresentX refused with E_INVALIDARG once its tokens ran ahead of the
pacer's.

leonida::FrameTokenSource is now the counter both use: a pacer takes an
optional shared source (a standalone pacer still owns its own and numbers
as before), the device proxy owns one and exposes it through
rt::d3d12_xs::device_frame_tokens, and XboxPresentation passes a given
source to its pacer. A token that was never issued is still refused.

Reported by rafaelpssz in #7496.

(cherry picked from commit afb14d56c6)

Adapted to main by Mumogg: main's uncapped pacer path issues its token from the shared source too, the device
proxy keeps the PresentX state next to the token source, and the queue's PresentX hands the device's source to
its XboxPresentation, which is what makes the title's tokens valid there.
2026-11-23 22:47:24 -06:00
06196160fe d3d12_xs: the queue's console slot 32 is PresentX, wired to the presentation core
The retail title presents through command-queue slot 32, past the PC queue's 19 slots, so main refused it with
E_NOTIMPL and nothing could be shown. The slot now calls XboxPresentation::PresentX (xbox_present.h) with the
title's plane count, planes and parameters. The first call on a device builds a window and the Vulkan layer's
presenter for it, once; a device that cannot present answers S_OK and shows nothing, so the title's frame loop
runs either way. The mock and COM builds of this file have no presenter and answer S_OK.

The wiring follows old PR 2490's (Nolan Cotter, 2be25cee2), written again for main's queue proxy, where that
commit does not apply. Not carried over: the queue layout detection (the older layout has PresentX at slot 30)
and presenting into the title's own window (old PR 8591); the window here is one this layer creates.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 22:47:24 -06:00
a44e66e9a3 Runtime: propagate device loss found by the retire-ticket progress query
VulkanContext::completed_retire_ticket() queried each pending submission's
timeline semaphore with vkGetSemaphoreCounterValue but treated every
non-VK_SUCCESS result as "not completed yet". A VK_ERROR_DEVICE_LOST seen
there was swallowed, so the context was never marked lost and the queue went
on to acquire, record and submit new command buffers.

Every other counter query in the layer (the queue's own progress query in
VulkanQueue::completed(), VulkanFence::completed(), the wait and submit
paths) already calls mark_device_lost() on VK_ERROR_DEVICE_LOST; this one
was the exception.

acquire() runs completed_retire_ticket() before recycle_finished()'s
completed(), so whichever query runs first observes the loss. When the
retire-ticket query is the first to see it, it consumes the error and the
queue's own query then reads a healthy counter. That is why
vk_queue_query_sync's section 5 (00832c18) failed on the RX 9070 XT /
AMD 26.11.2 but passed on NVIDIA: the retire ticket is still pending there,
so its query runs first.

Mark the context lost here too, outside submit_mutex_ as submit() does, and
report no completed ticket so nothing is retired against a lost device.

Fixes D3D-599.

(cherry picked from commit 3a21e3aea481bb9f9d9bfe9360c5b972fb19f7bb)
2026-11-24 07:45:22 +03:00
eaa2859076 test(shader): order shared memory in the subdword LDS fixture 2026-11-23 23:44:45 -05:00
9b77601d08 CPU subresource copies wait for their own submission only (review D9)
WriteToSubresource/ReadFromSubresource without host image copy replay a
CopyTextureRegion on a staging VulkanQueue and wait for it. The wait was
VulkanQueue::idle(): vkQueueWaitIdle on info.queue, the VkQueue the first
D3D12 direct queue also uses, under the device's submit lock. Every such
CPU copy waited for all the game work queued there, and no queue could
submit meanwhile.

- VulkanQueue::wait_submitted waits on the queue's own progress timeline
  for what it submitted, without the submit lock (bounded slices, wakes on
  device loss). The staging copy uses it instead of idle().
- The staging queue is on a VkQueue the game's first queues are not on
  (CreateCommandQueue hands each family's out from the first, so the
  last): the copy family's for colour textures, whose engine runs beside
  queued graphics work; the graphics family's for depth/stencil and rgb96
  textures, whose copies may run the D24/rgb96 compute pass. A second
  graphics VkQueue alone did not help on NVIDIA: the timeline wait still
  took the whole 32 ms, the copy ran behind the busy queue. Where the
  family has one VkQueue the copy shares info.queue as before.
- No waits on other queues are attached: D3D12 requires the application
  to have seen the texture's GPU work complete before a CPU copy (it waits
  on a fence its queue signalled), and that host wait followed by this
  submission orders the work before the copy and makes its writes visible.
  Pending work of other queues would only be waited for needlessly.

Measured (d3d12_staged_copy_wait_test, RTX 3080 Laptop, standalone
device): a staged 64x64 WriteToSubresource while the direct queue has 32 ms
of buffer copies queued took 31.8 ms before, 0.10 ms now (the direct queue
still busy after it); the bytes round-trip. d3d12_subresource_copy (both
paths, 109 steps against the host and Microsoft's answers), d3d12_rgb96 and
the new test are clean under LEONIDA_VK_VALIDATION=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:44:11 -08:00
4750df6a06 acphal: add portable XMA2 decoder, ACP message queue, and SHAPE XMA worker
- Add portable C++20 XMA2 packet parser and WMA Pro frame decoder
  (runtime/src/xma2_decoder.{h,cpp}, following FFmpeg wmaprodec.c /
  wmaprodata.h LGPL-2.1-or-later under Leonida's GPL-3.0-or-later)
  with cross-platform xma2_decoder_test.
- Implement IAcpHal command/message queue protocol (REGISTER_MESSAGES,
  UNREGISTER_MESSAGES, LOAD_FLOWGRAPH, COMMAND_COMPLETED, DISCONNECTED,
  queue-full dropped counters, and APU notification word writes) in
  runtime/shims/acphal.cpp.
- Wire a lazily-started, cleanly-joined background XMA2 decoder thread
  pumping enabled SHAPE_XMA_CONTEXT output rings in APU memory.
2026-11-24 01:44:00 -03:00
ddafa07b46 d3d12_xs: multi-event FramePacer TOKEN_ON_TIMEOUT and XboxPresentation proxy wiring
- Support origin (0), vblank (1), and flip (2) frame events and
  frame_wait_flag_token_on_timeout (flag 2, returning S_FALSE with a
  fresh consecutive token on timeout) in runtime/src/frame_pacer.h.
- Add a decoupled PresentationHandler interface to d3d12_xs_device.{h,cpp}
  routing device slots 78-81 and queue PresentX/SuspendX/ResumeX slots
  (default 30/31/32, env-overridable via LEONIDA_XS_*_SLOT).
- Add attach_xbox_presentation / detach_xbox_presentation in
  runtime/shims/xbox_present.{h,cpp}.
2026-11-24 01:43:53 -03:00
43c4f104c9 xgameruntime/lifecycle: speech WAV stream, display power request, XAppCapture, suspend-on-close
- Implement silent 44-byte 16 kHz mono 16-bit PCM WAVE streams for
  XSpeechSynthesizer in XAccessibilityImpl.
- Back XLauncherImpl::XDisplayAcquireTimeoutDeferral / Close with Win32
  PowerCreateRequest / PowerSetRequest(PowerRequestDisplayRequired).
- Add offline XAppCaptureImpl stub returning ERROR_NOT_SUPPORTED.
- Add runtime/shims/lifecycle.{h,cpp} providing app-state notification
  registration and CreateWindowExA/W oversized-window fitting plus
  suspend-on-SC_CLOSE dispatch.
2026-11-24 01:43:46 -03:00
e7044cb9bb d3d12_xs: the title's queue slot 18 is the frequency getter, not PC GetDesc
Queue slot 18 is ID3D12CommandQueue::GetDesc on the PC: a struct return that writes a 16-byte description through
the hidden pointer. The retail title calls slot 18 with one pointer to 8 bytes, the shape of
GetTimestampFrequency(UINT64*), which the console queue has there (two methods are inserted at 14/15, so the PC
slots 16 to 18 sit two later). Forwarded as GetDesc, the call wrote a description over the title's 8 bytes and
what follows them; the title then went wrong a little later, after its first submission.

The title's call (set_console_caller, as device slots 61 and 74) now goes to the PC slot 16. A host caller, and
every caller when no classifier is installed, keeps the PC GetDesc.

The reading of slot 18 is that of the console queue work in old PR 2490 (Nolan Cotter), which answers an
undetected slot 18 as the frequency getter because it is the only reading that cannot overrun its argument. That
work's layout detection does not apply to main's queue proxy; this is the one rule the boot needs, written for
it. xs_proxy_mock_test: the guest call reaches the mock queue's slot 16 with its pointer and leaves the words
around it; a host call, with a classifier and with none, reaches slot 18.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 22:43:37 -06:00
7d58fa5790 d3d12_xs: console list slot 139 is Reset, routed to the PC slot 10
The retail title resets its command lists through list slot 139, with (allocator proxy, pipeline state). main's
slot map had no entry for it, so the call was recorded and dropped and the list stayed closed. The map sends it
to the PC slot 10, and the unwrap keys on the PC slot, so console slot 10 and console slot 139 both hand the real
list its real allocator (and a wrapped pipeline state the same way) and re-pin the inline cursor.

The mapping and the unwrap rule are those of ef9d0759d (Nolan Cotter; measured by Pipodi), written again for
main's list proxy, where that commit does not apply. xs_proxy_mock_test checks the map entry and a slot 139 call.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 22:36:22 -06:00
6d5b2d4c2f d3d12_xs: handle ID3D12CommandAllocator slot 9 (SetAllocatorCallbackX) on allocator proxy
(cherry picked from commit e29e989980)
2026-11-23 22:36:22 -06:00
5d5afdeb4c d3d12_xs: route command queue slot 35 to ExecuteCommandLists
(cherry picked from commit e925b63455)

Adapted to main by Mumogg: main has command-list proxies, so the shared execute function replaces them by their
real lists in a copy of the array (UnwrappedArray), for the console slot 35 as for the PC slot 10, whose test
failed otherwise. The slot 35 mock case passes two mock lists instead of two numbers and checks that they arrive
and that the caller's array is not written.
2026-11-23 22:36:22 -06:00
6a9edfe37f d3d12_xs: slot 74's stand-in is for the title's calls; a host caller gets PC ShaderCacheControl
The stand-in also took a host's ID3D12Device9::ShaderCacheControl call through the proxy and answered S_OK
without reaching the device (found on native Windows by BadgersMC in the review of this change). Slot 74 now
asks the caller classifier slot 61 uses (set_console_caller): a caller in an image the guest loader mapped gets
the stand-in, any other caller, and every caller when no classifier is installed, is forwarded to the PC slot 74
or refused past the PC device's table.

xs_proxy_mock_test: the guest case under a classifier, and the host case with a classifier and with none, on a
device that has ShaderCacheControl and on one that does not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 22:36:22 -06:00
d2cd6c0d97 Merge pull request #328 from Mumogg/xmem-view-protect
xmem: map physical pages without a cache modifier in the view protection, again (RT-XMEM-VIEW-PROTECT)
2026-11-23 23:31:15 -05:00
e57a7558ac test: keep host fixtures unambiguous on G: and T: (TEST-FS-HOST-DRIVE) 2026-11-24 15:25:51 +11:00
eeeda84c90 dxgi_swapchain_count_test: every chain is the offscreen ring on main now, so the failed-resize cases with matching counts expect it too
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:19:41 +03:00
3746bff239 dxgi: SetSourceSize checks the requested size after a failed ResizeBuffers; the comparison treats DXGI_STATUS_OCCLUDED as S_OK
Review by @KarolKurzyna in the original repository:
- The host answers DXGI_STATUS_OCCLUDED from Present for a window that isn't on screen, which depends on the
  desktop, so compare_failed_resize now counts it as S_OK. The failures stay strict.
- After a failed ResizeBuffers the host checks SetSourceSize against the size that was asked for (RTX 3060 Ti:
  after 16x16385, 100x10 is DXGI_ERROR_INVALID_CALL; after 16385x16 it is S_OK), so the layer does too. The
  comparison gains those two steps (17 now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:16:48 +03:00
a3090aab2d dxgi: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host
Measured against the host runtime (RTX 3060 Ti, NVIDIA 610.88, and WARP): once ResizeBuffers accepts its arguments
the old buffers are gone. If the new ones can't be made it fails, and the swap chain stays without buffers. GetDesc1
already reports the requested size and count, GetBuffer and Present are DXGI_ERROR_INVALID_CALL, and the next
successful ResizeBuffers restores everything. A side above 16384 is E_INVALIDARG on the hardware device. A call
refused for its arguments (a back buffer still held) changes nothing.

The layer answered E_FAIL and kept describing the old buffers. It now answers E_INVALIDARG for a side above 16384
before calling Vulkan (it used to pass the extent to vkCreateImage, past the device's limits) and E_OUTOFMEMORY when
Vulkan fails. It reports the requested description, refuses Present, and recovers on the next ResizeBuffers.

dxgi_swapchain_test compares 15 steps of that with the host's default adapter. dxgi_swapchain_count_test gets
failure injection on its fake Vulkan table: whether the offscreen ring or vkCreateSwapchainKHR fails (the latter
retires the old swapchain anyway), on the offscreen and on the direct path, the next resize builds a working
swapchain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:16:33 +03:00
25826cdddd 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.

(cherry picked from commit cdeee35aa8)

Adapted to main by Mumogg: the queue route inside route_xbox_device_slot calls proxy_create_command_queue_xbox
(the 32-byte description of 0cde63d61), as the inline route did before this commit moved the routes into a
function.
2026-11-23 22:16:28 -06:00
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
992b19bd44 device_proxy_test: the slot 26 hit-count checks measure from the start of their block
The slot 25/26 cases added before this block call slot 26 four times, so its absolute counts (3, then 4) failed
on Windows. The counts are now increases from the block's start, and the forwarding check no longer shares a
line with a counter, so a counter failure is not reported as a forwarding failure.

Patch by BadgersMC, from the review of #362 (found and tested on native Windows with WARP; device_proxy_test
does not run under Wine here).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 22:14:29 -06:00
6d4cf2ceb7 d3d12_xs: slot 61 is CreateSamplerX only for the title's calls; a host caller gets PC CreateMetaCommand
The proxy also serves host callers: d3d12_vulkan_device_test drives the Vulkan device through it,
and its ID3D12Device5::CreateMetaCommand call (PC slot 61) landed in proxy_create_sampler_x
(found by nullmarsh on #7115: the test stopped at line 5763 instead of main's known line 6574).

Slot 61 now checks the caller's return address with a classifier the runtime installs
(set_console_caller, the name #7490 uses): D3D12XboxCreateDevice installs
rt::shims::mapped_image_base, so only a caller in an image the guest loader mapped gets
CreateSamplerX. Any other caller, and every caller when no classifier is installed, is forwarded
to the PC slot 61.

xs_proxy_mock_test checks all three cases: no classifier (PC slot 61), a guest caller (PC
CreateSampler with the same words; a null description skipped) and a host caller under an
installed classifier (PC slot 61). d3d12_vulkan_device_test again stops at line 6574, as on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8f756ebe048af042638ce51a61490f35f4f44ee3)
(cherry picked from commit c915e1da45)
2026-11-23 22:14:29 -06:00
f54cf315b4 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>
(cherry picked from commit e22994464b)
2026-11-23 22:14:29 -06:00
3b86f5fb3c d3d12: CreateCommandSignature creates a DISPATCH_MESH signature on a device with mesh shaders
The Vulkan layer created signatures for draw, draw-indexed and dispatch only and answered E_NOTIMPL
for DISPATCH_MESH, which the PC runtime creates on any mesh-shader tier 1 device. A title that
creates such a signature at startup and asserts on the result stopped there.

The signature is created when the device has VK_EXT_mesh_shader (MeshShaderTier 1), as a new
IndirectKind::dispatch_mesh (the name and value #3777 uses, so the two merge). ExecuteIndirect with
it records nothing yet and says so once; #3777 replays it as vkCmdDrawMeshTasksIndirectEXT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit efc347830b)
2026-11-23 22:14:29 -06:00
58ce13c12d 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>
(cherry picked from commit 084c8c60e7)
2026-11-23 22:14:29 -06:00
20936e8453 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>
(cherry picked from commit 4c04c0f4e3)
2026-11-23 22:14:29 -06:00
35e687f2ac d3d12_xs: committed resources lease their size through the title's XMem hooks (RT-5 stop 17)
On the console a committed resource's memory is allocated with XMemAlloc, so it goes
through the title's __XMemAllocationHooks__. The retail title budgets its first
full-screen render targets with a per-thread hook that bump-allocates out of a range it
reserved and asserts that less than 2 MiB is left; PC resources never allocated through
the hooks, so the assert always fired. Slots 76 and 127 now allocate the slot-25 size of
each resource through the hooks, held by the resource with SetPrivateDataInterface and
freed when it is destroyed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ae322dafc5)

Adapted to main by Mumogg: the lease size is the later form of this series (d61755d4d, a render target's console
tile size, else the PC size), since console_render_target_extra is gone after 359390833.
2026-11-23 22:14:29 -06:00
f1a68eeffb d3d12_xs: console render target sizes follow each resource's alignment, slot 56 offsets, full mip chains, rounded-up mip extents, B5G5R5A1, saturating sums
(cherry picked from commit 359390833f)
2026-11-23 22:14:29 -06:00
584ef36fa8 d3d12_xs: device slot 25 gives the PC device clean resource descriptions (RT-5 stop 16)
The title's descriptions carry the Xbox layout word and flag bits above the PC ones. Slot 25 now passes a copy with PC flags and a PC layout; the title's array is not written. Depends on #7078.

(cherry picked from commit c7ca0f2d1c)
2026-11-23 22:14:29 -06:00