Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0a71454
d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and tra…
Khuraie Nov 23, 2026
8563343
d3d12_xs: device slot 25 pads a render target to whole console tiles …
tedin7 Nov 23, 2026
584ef36
d3d12_xs: device slot 25 gives the PC device clean resource descripti…
tedin7 Nov 23, 2026
f1a68ee
d3d12_xs: console render target sizes follow each resource's alignmen…
tedin7 Nov 23, 2026
35e687f
d3d12_xs: committed resources lease their size through the title's XM…
jacksonslab Nov 23, 2026
20936e8
d3d12_xs: a console indirect argument of type 105 is created as DISPA…
mrp1no Nov 23, 2026
58ce13c
d3d12_xs: read the console argument type as its 32 bits (clang-cl)
mrp1no Nov 23, 2026
3b86f5f
d3d12: CreateCommandSignature creates a DISPATCH_MESH signature on a …
NiiRoZz Nov 23, 2026
f54cf31
d3d12_xs: Xbox device slot 61 is CreateSamplerX, routed to the PC Cre…
mrp1no Nov 23, 2026
6d4cf2c
d3d12_xs: slot 61 is CreateSamplerX only for the title's calls; a hos…
mrp1no Nov 23, 2026
25826cd
d3d12_xs: device slot 74 (pointer, u32, pointer) returns S_OK instead…
tedin7 Nov 23, 2026
6a9edfe
d3d12_xs: slot 74's stand-in is for the title's calls; a host caller …
Mumogg Nov 24, 2026
5d5afde
d3d12_xs: route command queue slot 35 to ExecuteCommandLists
Vadson159 Nov 23, 2026
6d5b2d4
d3d12_xs: handle ID3D12CommandAllocator slot 9 (SetAllocatorCallbackX…
DevilNine Nov 23, 2026
7d58fa5
d3d12_xs: console list slot 139 is Reset, routed to the PC slot 10
Mumogg Nov 24, 2026
e7044cb
d3d12_xs: the title's queue slot 18 is the frequency getter, not PC G…
Mumogg Nov 24, 2026
0619616
d3d12_xs: the queue's console slot 32 is PresentX, wired to the prese…
Mumogg Nov 24, 2026
21a6c61
PresentX: device-side WaitFrameEventX and the frame pacer share one t…
Cattn Nov 23, 2026
11d44ee
queue_proxy_test: the PresentX slot is called and counted
Mumogg Nov 24, 2026
ce3e515
d3d12_xs: keep the fallback PresentX window responsive during rendering
Rain156 Nov 24, 2026
4ed6229
Merge remote-tracking branch 'origin/main' into fix/windows-present-w…
Rain156 Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,29 @@ The trace will enumerate them.
Intel Raptor Lake-S (101.7092) and RTX 5060 Laptop (621.24) hosts wrap, two 2^63 buffers to 0, and WARP on that
PC still saturates. A wrapped total could make a caller allocate less than one of its resources, so the layer
keeps saturating, and the test accepts a host that wraps.
Behind the Xbox-ABI proxy (device slots 25 and 56) a 2D render target of a listed colour format with one sample is
padded to whole console tiles: the size is the sum over its mips (MipLevels 0 is the full chain, an odd extent
rounds up), each mip rounded up to the RDNA2 SW_64KB_D tile shape (`runtime/src/gfx10_tiling.h`: 256 x 128 pixels
for 2-byte elements, 128 x 128 for 4-byte, 128 x 64 for 8-byte, 64 x 64 for 16-byte), with the first mip that fits
in half a tile's width and a whole tile's height, and the mips after it, sharing one tail tile, times the array
size. A 1920 x 1080 RGBA8 target is 135 tiles, 8,847,360 bytes, where the PC answer is 8,323,072. The proxy lays
the descriptions out as the PC device does (each at its own alignment, the total rounded up to the largest
alignment, sums saturating) with each render target at the larger of its console size and its PC size; a 4 MiB
aligned multisampled neighbour therefore keeps its place (a 1 x 1 four-sample target and a 1080p target need 16 MiB,
not 12.5). Slot 56 reports the same offsets. The PC layout stands when no description grows
(`d3d12_xs_alloc_size.h`; `xs_proxy_mock_test`). **Assumption**: the
retail title's own sizes are not measured (#6982, stop 17), so that its allocation is these shapes and no DCC or
CMask memory is open until they are.
The descriptions the title passes to slot 25 carry console values (layout word `0x101`/`0x1`, flag bits above the PC
ones). The proxy gives the PC device a copy with the PC flags only and ROW_MAJOR (buffer) or UNKNOWN (texture); the
title's array is never written (`d3d12_xs_desc_clean.h`, the same cleaning as slot 76; #6982 section 3.7).
A committed resource made through slots 76 and 127 also allocates that size through the title's
`__XMemAllocationHooks__`, as the console runtime's `XMemAlloc` for the resource does, and frees it when the
resource is destroyed (a lease kept with `SetPrivateDataInterface`; the bytes are not used). The retail title
budgets its first full-screen render targets with such a hook: it bump-allocates the allocations whose XALLOC
page-size field is 2 out of a range it reserved and asserts that less than 2 MiB is left (RT-5 stop 17). The
lease's attribute word (allocator ID 0x80, page-size field 2, object type 0) is an **assumption**; the measured
hook reads only the page-size field.
- `GetAdapterLuid` (implemented): `VkPhysicalDeviceIDProperties::deviceLUID`, which on Windows is the DXGI
adapter's LUID; `d3d12_fence_timing_test` finds it with `IDXGIFactory4::EnumAdapterByLuid` (RTX 4090, driver
621.14). A driver that reports `deviceLUIDValid = VK_FALSE` gets a zero LUID, logged.
Expand All @@ -2263,8 +2286,9 @@ The trace will enumerate them.
RDX, node mask in R8 and heap type in R9: three calls right after device creation, node mask 1 and types 1, 2
and 3 (measured under `gta6rt --run` with a register probe in the slot's thunk). A PC C++ method has the device
in RCX and the buffer in RDX, so the Xbox-ABI proxy takes the console form when RDX holds the proxy
(`d3d12_xs_device.cpp`; `xs_proxy_mock_test`, `device_proxy_test`). Slots 25 and 43 return structs too; the
executable has not been seen calling them yet, so the proxy still forwards them in the PC form.
(`d3d12_xs_device.cpp`; `xs_proxy_mock_test`, `device_proxy_test`). Slot 43 returns a struct too and the
proxy still forwards it in the PC form: no call of slot 43 has been seen. Slots 25 and 56 take the same form by the
same rule (reported later in the boot, #6982; not measured), as #6973 first did for slot 25.
- Residency and power (D3D-33) are no-ops that still check their arguments (`d3d12_vulkan_device.cpp`, tested in
`d3d12_vulkan_device_test`). Vulkan has no residency API: memory from `vkAllocateMemory` stays usable until
`vkFreeMemory`, and paging under pressure is the kernel driver's job, so every pageable object is always resident.
Expand Down Expand Up @@ -3506,6 +3530,8 @@ to be recovered from call sites (or the NDA GDK headers, if a developer has acce
| DCC / texture compatibility | Public release note for `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` | Let Vulkan choose compression; fail if the game aliases/reads raw compressed data. |
| PresentX / present planes / frame events | Public GDK samples (MIT/zlib), §4.5 | Likely the only present path of a GDKX title. Presenter + vblank-timed frame events; 1-2 planes composed into the Vulkan swapchain (placement, filter, alpha overlay, HDR10 conversions). Call shapes known; slots/layouts **Open**. |
| Device slots 48/73/78/79/80 | Public HLE `Freminet`/`ScarlettX` (third-party, not Microsoft documentation) | `d3d12_xs_device.cpp` routes `CreateCommandQueueX` (48), `CreateCommandListX` (73), `SetFrameIntervalX` (78), `ScheduleFrameEventX` (79) and `WaitFrameEventX` (80) before it indexes the PC vtable. Queue and list creation use the existing create paths. The frame-event calls are a per-device token counter: `WaitFrameEventX` returns at once with a fresh non-zero token, because there is no vblank source before a presenter exists. The five indices can be moved with `LEONIDA_XS_QUEUE_X_SLOT`, `LEONIDA_XS_LIST_X_SLOT`, `LEONIDA_XS_FRAME_INTERVAL_SLOT`, `LEONIDA_XS_SCHEDULE_EVENT_SLOT` and `LEONIDA_XS_WAIT_EVENT_SLOT` (3..127; a value that names a slot the proxy already handles keeps that slot's handler); a trace that disagrees wins. |
| Indirect argument type 105 | The retail title's startup creates five one-argument command signatures (device slot 41) with no root signature; one has type 105 and a 12-byte stride. Its two `ExecuteIndirect` sites, read statically, set the compute state first, as the `DISPATCH` sites do, and pass one command from the same argument buffer, on a second command list | `d3d12_xs_device.cpp` creates it as `DISPATCH` (`D3D12_DISPATCH_ARGUMENTS`). What the console does differently for it is **Open**. |
| Device slot 61 | The retail title's boot under `gta6rt --run` (stop 20 of the RT-5 measurements in #6910): called as `(desc, dest handle)` once per sampler | `d3d12_xs_device.cpp` routes it to the PC `CreateSampler` (slot 22) with the description's PC `D3D12_SAMPLER_DESC` prefix, for a caller in an image the guest loader mapped; the PC slot 61 is `CreateMetaCommand`, which any other caller (a host test driving the device through the proxy) still gets. The layout of the description beyond the PC fields is **Open**. |
| VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. |
| Mesh shader tier | Public `D3D12_MESH_SHADER_TIER` | `VK_EXT_mesh_shader`; the 9,282 translated mesh shaders make this a hard requirement for any content that uses them. |
| Wave MMA | Public `D3D12_WAVE_MMA_TIER` | Not used: no shader sets `WAVE_MMA` in SFI0 and none contains `v_mfma`/`v_wmma` (all 26,503, `tools/feature_scan.py`). Answer the tier query truthfully; no cooperative-matrix mapping is needed. |
Expand Down
8 changes: 8 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,13 @@ if(BUILD_TESTING)
add_test(NAME startup_trace COMMAND startup_trace_test)
endif()

if(WIN32)
add_executable(present_window_test test/present_window_test.cpp)
target_link_libraries(present_window_test PRIVATE user32)
add_test(NAME present_window COMMAND present_window_test)
set_tests_properties(present_window PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 15)
endif()

if(TARGET device_proxy_test)
add_test(NAME device_proxy COMMAND device_proxy_test)
set_tests_properties(device_proxy PROPERTIES SKIP_RETURN_CODE 77) # no WARP adapter (Wine)
Expand All @@ -1025,6 +1032,7 @@ if(BUILD_TESTING)
# The routes are read once per process, so each override case is its own test.
add_test(NAME xs_proxy_mock_env_slots COMMAND xs_proxy_mock_test --env-slots)
add_test(NAME xs_proxy_mock_env_slots_invalid COMMAND xs_proxy_mock_test --env-slots-invalid)
add_test(NAME xs_proxy_mock_env_slots_74 COMMAND xs_proxy_mock_test --env-slots-74)
endif()
if(TARGET root_sig_test)
add_test(NAME root_sig COMMAND root_sig_test)
Expand Down
22 changes: 9 additions & 13 deletions runtime/shims/d3d12_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,19 +834,15 @@ class GraphicsCommandList final
} else if (count_buffer_offset != 0) {
return check(false);
}
// The record size is checked for every call: D3D12 rejects a signature whose stride cannot hold a record
// even when no command runs. The argument span is what the signature can walk, max_command_count * stride:
// the host refuses a range that ends past the buffer (`240` with stride `20` in a `256`-byte buffer), and
// it checks the offset itself when max_command_count is 0, where the required bytes are none.
const UINT64 record_size =
kind == leonida::IndirectKind::draw ? sizeof(D3D12_DRAW_ARGUMENTS)
: kind == leonida::IndirectKind::draw_indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS)
: kind == leonida::IndirectKind::dispatch ? sizeof(D3D12_DISPATCH_ARGUMENTS)
: 0;
if (!record_size || stride < record_size || stride % 4 != 0) return check(false);
if (argument_buffer_offset > arg_desc.Width ||
UINT64(max_command_count) > (arg_desc.Width - argument_buffer_offset) / stride)
return check(false);
if (kind == leonida::IndirectKind::dispatch_mesh) {
// Not replayed yet (#3777 replays it as vkCmdDrawMeshTasksIndirectEXT): nothing is recorded, and the
// first such call says so. The list stays valid.
static std::atomic<bool> logged{false};
if (!logged.exchange(true, std::memory_order_relaxed))
std::fprintf(stderr, "[rt] d3d12: ExecuteIndirect with a DISPATCH_MESH signature is not replayed yet; "
"nothing was recorded\n");
return;
}
leonida::ExecuteIndirect cmd{};
cmd.kind = kind;
cmd.stride = stride;
Expand Down
5 changes: 5 additions & 0 deletions runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5833,6 +5833,11 @@ class Device final
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW: kind = leonida::IndirectKind::draw; break;
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED: kind = leonida::IndirectKind::draw_indexed; break;
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH: kind = leonida::IndirectKind::dispatch; break;
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH:
// As DispatchMesh: only a device with mesh shaders (MeshShaderTier 1) takes it.
if (!state_.info.mesh_shader) return E_NOTIMPL;
kind = leonida::IndirectKind::dispatch_mesh;
break;
default: return E_NOTIMPL;
}
return create_command_signature(kind, desc->ByteStride, riid, out, identity());
Expand Down
17 changes: 17 additions & 0 deletions runtime/shims/d3d12_xs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,22 @@ HRESULT WINAPI create_root_signature_deserializer(const void* data, SIZE_T size,
return fn(data, size, iid, out);
}

void* xmem_descriptor_heap_alloc(std::size_t byte_size, std::uint64_t attributes) {
const rt::shims::XMemAllocationHooks* hooks = rt::shims::xmem_allocation_hooks();
return (hooks && hooks->alloc) ? hooks->alloc(byte_size, attributes) : nullptr;
}

void xmem_descriptor_heap_free(void* ptr, std::uint64_t attributes) {
const rt::shims::XMemAllocationHooks* hooks = rt::shims::xmem_allocation_hooks();
if (hooks && hooks->free) hooks->free(ptr, attributes);
}

// Measured shape: D3D12XboxCreateDevice(adapter, params, riid, out), where params is a 24-word block that is only
// logged and not used to create the device. The struct's total size is unknown, so the log reads 24 x 32-bit words
// (96 bytes) and no more. The PC D3D12CreateDevice needs a minimum feature level instead, so 12_0 is used as the
// least restrictive floor; higher feature levels are still exposed by the created device.
HRESULT WINAPI D3D12XboxCreateDevice(IUnknown* adapter, const void* params, const IID* riid, void** out) {
rt::d3d12_xs::set_default_descriptor_heap_allocator(&xmem_descriptor_heap_alloc, &xmem_descriptor_heap_free);
constexpr auto method = "D3D12XboxCreateDevice";
using rt::d3d12_trace::result;
if (!out) return result(method, E_POINTER);
Expand Down Expand Up @@ -155,6 +166,12 @@ HRESULT WINAPI D3D12XboxCreateDevice(IUnknown* adapter, const void* params, cons
std::fprintf(stderr,
"[rt] d3d12_xs: D3D12XboxCreateDevice: wrapping the PC ID3D12Device in the Xbox-ABI proxy "
"(slot 62 -> CreateComputePipelineState, slot 76 -> CreateCommittedResource).\n");
// A console method whose slot is another PC method (61) is served only to the title: a caller in an image
// this loader mapped.
rt::d3d12_xs::set_console_caller([](std::uint64_t address) {
std::uint64_t base = 0;
return rt::shims::mapped_image_base(address, base);
});
}

#ifdef LEONIDA_VULKAN_DEVICE
Expand Down
Loading