diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 7f7040fdd9..5e2f041b70 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -38,8 +38,9 @@ #include #include #include -#include #include +#include +#include #include namespace rt::d3d12_xs { @@ -76,8 +77,20 @@ struct DeviceProxy { std::atomic frame_latency{1}; std::atomic frame_event_scheduled{false}; std::atomic frame_next_token{1}; + std::atomic frame_suspended{false}; + std::atomic present_calls{0}; + std::mutex presentation_mutex; + void* presentation_ctx = nullptr; + const XboxPresentationOps* presentation_ops = nullptr; }; +bool get_device_presentation(DeviceProxy* self, void*& ctx, const XboxPresentationOps*& ops) { + const std::lock_guard lock(self->presentation_mutex); + ctx = self->presentation_ctx; + ops = self->presentation_ops; + return ctx != nullptr && ops != nullptr; +} + constexpr unsigned kHeapSlots = 11; // IUnknown + ID3D12Object + DeviceChild + Pageable + GetDesc + 2 handles struct HeapProxy { @@ -157,6 +170,7 @@ const char* slot_name(unsigned slot) { case 78: return "Xbox SetFrameIntervalX"; case 79: return "Xbox ScheduleFrameEventX"; case 80: return "Xbox WaitFrameEventX"; + case 81: return "Xbox GetFrameStatisticsX"; case 133: return "Xbox CreatePlacedResourceX (a buffer on the title's pages)"; default: return "forwarded"; } @@ -178,11 +192,18 @@ void note_slot(unsigned slot) { // that disagrees). A value outside that range is logged once and ignored. The table is read once, on the first // generic slot call, so a test that wants other slots sets the variables before it creates a device. struct XboxDeviceSlotRoutes { - unsigned frame_interval = 78; // SetFrameIntervalX(output, interval_us, latency, flags) - unsigned schedule_event = 79; // ScheduleFrameEventX(event, offset_us, reserved, flags) - unsigned wait_event = 80; // WaitFrameEventX(event, timeout_ms, reserved, flags, &token) - unsigned queue_x = 48; // CreateCommandQueueX(desc, riid, out) - unsigned list_x = 73; // CreateCommandListX(desc, allocator, initial_state, riid, out) + unsigned frame_interval = 78; // SetFrameIntervalX(output, interval_us, latency, flags) + unsigned schedule_event = 79; // ScheduleFrameEventX(event, offset_us, reserved, flags) + unsigned wait_event = 80; // WaitFrameEventX(event, timeout_ms, reserved, flags, &token) + unsigned frame_statistics = 81; // GetFrameStatisticsX(token, type_mask, &count, stats) + unsigned queue_x = 48; // CreateCommandQueueX(desc, riid, out) + unsigned list_x = 73; // CreateCommandListX(desc, allocator, initial_state, riid, out) +}; + +struct XboxQueueSlotRoutes { + unsigned suspend = 23; // SuspendX(flags) + unsigned resume = 24; // ResumeX() + unsigned present = 32; // PresentX(plane_count, planes, params) }; unsigned env_device_slot(const char* name, unsigned fallback) { @@ -210,20 +231,41 @@ const XboxDeviceSlotRoutes& xbox_device_slot_routes() { const unsigned frame_interval = env_device_slot("LEONIDA_XS_FRAME_INTERVAL_SLOT", r.frame_interval); const unsigned schedule_event = env_device_slot("LEONIDA_XS_SCHEDULE_EVENT_SLOT", r.schedule_event); const unsigned wait_event = env_device_slot("LEONIDA_XS_WAIT_EVENT_SLOT", r.wait_event); + const unsigned frame_statistics = env_device_slot("LEONIDA_XS_FRAME_STATISTICS_SLOT", r.frame_statistics); const unsigned queue_x = env_device_slot("LEONIDA_XS_QUEUE_X_SLOT", r.queue_x); const unsigned list_x = env_device_slot("LEONIDA_XS_LIST_X_SLOT", r.list_x); const bool moved = frame_interval != r.frame_interval || schedule_event != r.schedule_event || - wait_event != r.wait_event || queue_x != r.queue_x || list_x != r.list_x; + wait_event != r.wait_event || frame_statistics != r.frame_statistics || + queue_x != r.queue_x || list_x != r.list_x; r.frame_interval = frame_interval; r.schedule_event = schedule_event; r.wait_event = wait_event; + r.frame_statistics = frame_statistics; r.queue_x = queue_x; r.list_x = list_x; if (moved) std::fprintf(stderr, "[rt] d3d12_xs: Xbox device slots: SetFrameIntervalX=%u ScheduleFrameEventX=%u " - "WaitFrameEventX=%u CreateCommandQueueX=%u CreateCommandListX=%u\n", - r.frame_interval, r.schedule_event, r.wait_event, r.queue_x, r.list_x); + "WaitFrameEventX=%u GetFrameStatisticsX=%u CreateCommandQueueX=%u CreateCommandListX=%u\n", + r.frame_interval, r.schedule_event, r.wait_event, r.frame_statistics, r.queue_x, r.list_x); + return r; + }(); + return routes; +} + +const XboxQueueSlotRoutes& xbox_queue_slot_routes() { + static const XboxQueueSlotRoutes routes = [] { + XboxQueueSlotRoutes r; + const unsigned suspend = env_device_slot("LEONIDA_XS_SUSPEND_SLOT", r.suspend); + const unsigned resume = env_device_slot("LEONIDA_XS_RESUME_SLOT", r.resume); + const unsigned present = env_device_slot("LEONIDA_XS_PRESENT_SLOT", r.present); + const bool moved = suspend != r.suspend || resume != r.resume || present != r.present; + r.suspend = suspend; + r.resume = resume; + r.present = present; + if (moved) + std::fprintf(stderr, "[rt] d3d12_xs: Xbox queue slots: SuspendX=%u ResumeX=%u PresentX=%u\n", + r.suspend, r.resume, r.present); return r; }(); return routes; @@ -1213,6 +1255,55 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_ reinterpret_cast(a2))); } else { note_child_slot(Slot); + if constexpr (K == ChildKind::queue) { + const XboxQueueSlotRoutes& qroutes = xbox_queue_slot_routes(); + void* pres_ctx = nullptr; + const XboxPresentationOps* pres_ops = nullptr; + if (Slot == qroutes.suspend) { + log_xbox_route_once(Slot, "Queue::SuspendX", a1, a2, a3, a4, 0); + if (get_device_presentation(self->device, pres_ctx, pres_ops) && pres_ops->suspend_x) { + const HRESULT hr = pres_ops->suspend_x(pres_ctx, static_cast(a1)); + d3d12_trace::record("ID3D12CommandQueue::SuspendX", SUCCEEDED(hr) ? nullptr : "failed"); + return hr_to_u64(hr); + } + self->device->frame_event_scheduled.store(false, std::memory_order_relaxed); + self->device->frame_suspended.store(true, std::memory_order_relaxed); + d3d12_trace::record("ID3D12CommandQueue::SuspendX"); + return hr_to_u64(S_OK); + } + if (Slot == qroutes.resume) { + log_xbox_route_once(Slot, "Queue::ResumeX", a1, a2, a3, a4, 0); + if (get_device_presentation(self->device, pres_ctx, pres_ops) && pres_ops->resume_x) { + const HRESULT hr = pres_ops->resume_x(pres_ctx); + d3d12_trace::record("ID3D12CommandQueue::ResumeX", SUCCEEDED(hr) ? nullptr : "failed"); + return hr_to_u64(hr); + } + self->device->frame_suspended.store(false, std::memory_order_relaxed); + d3d12_trace::record("ID3D12CommandQueue::ResumeX"); + return hr_to_u64(S_OK); + } + if (Slot == qroutes.present) { + log_xbox_route_once(Slot, "Queue::PresentX", a1, a2, a3, a4, 0); + const auto plane_count = static_cast(a1); + if (get_device_presentation(self->device, pres_ctx, pres_ops) && pres_ops->present_x) { + const HRESULT hr = pres_ops->present_x(pres_ctx, plane_count, reinterpret_cast(a2), + reinterpret_cast(a3)); + d3d12_trace::record("ID3D12CommandQueue::PresentX", SUCCEEDED(hr) ? nullptr : "failed"); + return hr_to_u64(hr); + } + if (plane_count > 2 || (plane_count > 0 && a2 == 0)) { + d3d12_trace::record("ID3D12CommandQueue::PresentX", "invalid_arg"); + return hr_to_u64(E_INVALIDARG); + } + if (self->device->frame_suspended.load(std::memory_order_relaxed)) { + d3d12_trace::record("ID3D12CommandQueue::PresentX", "suspended"); + return hr_to_u64(HRESULT_FROM_WIN32(ERROR_INVALID_STATE)); + } + self->device->present_calls.fetch_add(1, std::memory_order_relaxed); + d3d12_trace::record("ID3D12CommandQueue::PresentX"); + return hr_to_u64(S_OK); + } + } if (Slot >= self->slot_count) { bool expected = false; if (ChildStats::beyond_warned[Slot].compare_exchange_strong(expected, true, @@ -1380,8 +1471,13 @@ HRESULT proxy_create_command_queue(DeviceProxy* self, const D3D12_COMMAND_QUEUE_ // 60 Hz), and latency is the allowed frames in flight. S_OK even for 0: a boot must not abort here, and nothing paces. HRESULT proxy_set_frame_interval_x(DeviceProxy* self, std::uint64_t output, std::uint64_t interval_us, std::uint64_t latency, std::uint64_t flags) { - (void)output; - (void)flags; + void* pres_ctx = nullptr; + const XboxPresentationOps* pres_ops = nullptr; + if (get_device_presentation(self, pres_ctx, pres_ops) && pres_ops->set_frame_interval) { + return pres_ops->set_frame_interval(pres_ctx, reinterpret_cast(output), + static_cast(interval_us), static_cast(latency), + static_cast(flags)); + } self->frame_interval_us.store(static_cast(interval_us), std::memory_order_relaxed); self->frame_latency.store(static_cast(latency ? latency : 1), std::memory_order_relaxed); return S_OK; @@ -1390,9 +1486,12 @@ HRESULT proxy_set_frame_interval_x(DeviceProxy* self, std::uint64_t output, std: // Xbox device slot 79 (public HLE): ScheduleFrameEventX(event, offset_us, pEvent, flags); our pacer has only the origin. HRESULT proxy_schedule_frame_event_x(DeviceProxy* self, std::uint64_t event, std::uint64_t offset_us, std::uint64_t flags) { - (void)event; - (void)offset_us; - (void)flags; + void* pres_ctx = nullptr; + const XboxPresentationOps* pres_ops = nullptr; + if (get_device_presentation(self, pres_ctx, pres_ops) && pres_ops->schedule_frame_event) { + return pres_ops->schedule_frame_event(pres_ctx, static_cast(event), static_cast(offset_us), + static_cast(flags)); + } self->frame_event_scheduled.store(true, std::memory_order_relaxed); return S_OK; } @@ -1402,10 +1501,13 @@ HRESULT proxy_schedule_frame_event_x(DeviceProxy* self, std::uint64_t event, std // a zero wait cannot stall the title. A null token pointer is E_POINTER, as a _Out_ parameter. HRESULT proxy_wait_frame_event_x(DeviceProxy* self, std::uint64_t event, std::uint64_t timeout_ms, std::uint64_t flags, std::uint64_t token_word) { - (void)event; - (void)timeout_ms; - (void)flags; auto* token = reinterpret_cast(token_word); + void* pres_ctx = nullptr; + const XboxPresentationOps* pres_ops = nullptr; + if (get_device_presentation(self, pres_ctx, pres_ops) && pres_ops->wait_frame_event) { + return pres_ops->wait_frame_event(pres_ctx, static_cast(event), static_cast(timeout_ms), + static_cast(flags), token); + } if (!token) return E_POINTER; std::uint64_t value = self->frame_next_token.fetch_add(1, std::memory_order_relaxed); if (value == 0) value = self->frame_next_token.fetch_add(1, std::memory_order_relaxed); // skip the null token @@ -1413,6 +1515,25 @@ HRESULT proxy_wait_frame_event_x(DeviceProxy* self, std::uint64_t event, std::ui return S_OK; } +// Xbox device slot 81 (measured in retail exe): GetFrameStatisticsX(token, type_mask, &count, stats). +// Before a window/presenter is attached, writes *count = 0 and returns S_FALSE (matches XboxPresentation). +HRESULT proxy_get_frame_statistics_x(DeviceProxy* self, std::uint64_t token, std::uint64_t type_mask, + std::uint64_t count_word, std::uint64_t stats_word) { + auto* count = reinterpret_cast(count_word); + void* pres_ctx = nullptr; + const XboxPresentationOps* pres_ops = nullptr; + if (get_device_presentation(self, pres_ctx, pres_ops) && pres_ops->get_frame_statistics) { + return pres_ops->get_frame_statistics(pres_ctx, token, static_cast(type_mask), count, + reinterpret_cast(stats_word)); + } + (void)token; + (void)type_mask; + (void)stats_word; + if (!count) return E_POINTER; + *count = 0; + return S_FALSE; +} + // Xbox device slot 73 (public HLE): CreateCommandListX(desc, allocator, initial_state, riid, out). The console call is // not the PC six-argument form: the type is the first word of D3D12XBOX_COMMAND_LIST_DESC and there is no node mask // (the HLE passes 0). The second desc word is logged, not interpreted: its public layout is not established. @@ -2038,6 +2159,10 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64 log_xbox_route_once(Slot, "WaitFrameEventX", a1, a2, a3, a4, a5); return hr_to_u64(proxy_wait_frame_event_x(self, a1, a2, a4, a5)); } + if (Slot == routes.frame_statistics) { + log_xbox_route_once(Slot, "GetFrameStatisticsX", a1, a2, a3, a4, a5); + return hr_to_u64(proxy_get_frame_statistics_x(self, a1, a2, a3, a4)); + } if (Slot == routes.queue_x) { log_xbox_route_once(Slot, "CreateCommandQueueX", a1, a2, a3, a4, a5); return hr_to_u64(proxy_create_command_queue_xbox(self, reinterpret_cast(a1), @@ -2220,6 +2345,18 @@ bool set_device_adapter_provider(void* device, DxgiAdapterProvider provider) { return true; } +bool set_device_presentation(void* device, void* ctx, const XboxPresentationOps* ops) { + auto* proxy = static_cast(device_proxy_primary(device)); + if (!proxy) { + std::fprintf(stderr, "[rt] d3d12_xs: set_device_presentation: %p is not a device proxy\n", device); + return false; + } + const std::lock_guard lock(proxy->presentation_mutex); + proxy->presentation_ctx = ctx; + proxy->presentation_ops = ops; + return true; +} + bool is_heap_proxy(const void* heap) { return heap && *reinterpret_cast(heap) == reinterpret_cast(get_heap_vtable()); } diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 7ee8809397..d6238e392f 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h @@ -95,6 +95,20 @@ void* device_proxy_from_dxgi_device(void* dxgi_device); // The device proxy itself, given the proxy or its DXGI pointer; null for anything else. void* device_proxy_primary(void* device); +// Optional presentation backend (e.g. rt::d3d12::XboxPresentation) bound to a device proxy. When set, device +// slots 78-81 (SetFrameIntervalX, ScheduleFrameEventX, WaitFrameEventX, GetFrameStatisticsX) and queue slots +// 23/24/32 (SuspendX, ResumeX, PresentX) forward to these callbacks instead of the headless HLE fallback. +struct XboxPresentationOps { + HRESULT (*set_frame_interval)(void* ctx, IUnknown* output, UINT interval_us, UINT latency, UINT flags) = nullptr; + HRESULT (*schedule_frame_event)(void* ctx, UINT event, UINT offset_us, UINT flags) = nullptr; + HRESULT (*wait_frame_event)(void* ctx, UINT event, DWORD timeout_ms, UINT flags, std::uint64_t* token) = nullptr; + HRESULT (*get_frame_statistics)(void* ctx, std::uint64_t token, UINT type_mask, UINT* count, void* out) = nullptr; + HRESULT (*present_x)(void* ctx, UINT plane_count, const void* planes, const void* params) = nullptr; + HRESULT (*suspend_x)(void* ctx, UINT flags) = nullptr; + HRESULT (*resume_x)(void* ctx) = nullptr; +}; +bool set_device_presentation(void* device, void* ctx, const XboxPresentationOps* ops); + // True when `heap` is a descriptor-heap proxy created by device slot 14. bool is_heap_proxy(const void* heap); ID3D12DescriptorHeap* heap_proxy_real_heap(const void* heap); diff --git a/runtime/shims/xbox_present.cpp b/runtime/shims/xbox_present.cpp index dd5f810cf7..1db5b55108 100644 --- a/runtime/shims/xbox_present.cpp +++ b/runtime/shims/xbox_present.cpp @@ -1,6 +1,7 @@ #include "xbox_present.h" #include "d3d12_trace.h" +#include "d3d12_xs_device.h" #include "../src/vulkan_present.h" @@ -314,4 +315,34 @@ HRESULT XboxPresentation::ResumeX() { return S_OK; } +bool bind_device_presentation(void* device, XboxPresentation* presentation) { + static const rt::d3d12_xs::XboxPresentationOps kOps{ + [](void* ctx, IUnknown* output, UINT interval_us, UINT latency, UINT flags) -> HRESULT { + return static_cast(ctx)->SetFrameIntervalX(output, interval_us, latency, flags); + }, + [](void* ctx, UINT event, UINT offset_us, UINT flags) -> HRESULT { + return static_cast(ctx)->ScheduleFrameEventX(event, offset_us, flags); + }, + [](void* ctx, UINT event, DWORD timeout_ms, UINT flags, std::uint64_t* token) -> HRESULT { + return static_cast(ctx)->WaitFrameEventX(event, timeout_ms, flags, token); + }, + [](void* ctx, std::uint64_t token, UINT type_mask, UINT* count, void* out) -> HRESULT { + return static_cast(ctx)->GetFrameStatisticsX( + token, type_mask, count, static_cast(out)); + }, + [](void* ctx, UINT plane_count, const void* planes, const void* params) -> HRESULT { + return static_cast(ctx)->PresentX( + plane_count, static_cast(planes), + static_cast(params)); + }, + [](void* ctx, UINT flags) -> HRESULT { + return static_cast(ctx)->SuspendX(flags); + }, + [](void* ctx) -> HRESULT { + return static_cast(ctx)->ResumeX(); + }, + }; + return rt::d3d12_xs::set_device_presentation(device, presentation, presentation ? &kOps : nullptr); +} + } // namespace rt::d3d12 diff --git a/runtime/shims/xbox_present.h b/runtime/shims/xbox_present.h index 60a317beec..759d887a66 100644 --- a/runtime/shims/xbox_present.h +++ b/runtime/shims/xbox_present.h @@ -200,4 +200,8 @@ class XboxPresentation { inline constexpr UINT xbox_frame_event_origin = leonida::frame_event_origin; +// Wires an XboxPresentation instance into a d3d12_xs device proxy (or its DXGI pointer) so Xbox device +// slots 78-81 and queue slots 23/24/32 drive this presentation object. Pass nullptr to unbind. +bool bind_device_presentation(void* device, XboxPresentation* presentation); + } // namespace rt::d3d12 diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index b3b3f0fc3e..3be05e5913 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp @@ -574,6 +574,107 @@ int main(int argc, char** argv) { ComPtr owner; check(SUCCEEDED(queue->GetDevice(IID_PPV_ARGS(owner.GetAddressOf()))) && owner.Get() == device.Get(), "the queue proxy's GetDevice is the device the shim returned"); + + using GetStatsFn = HRESULT(WINAPI*)(void*, UINT64, UINT32, UINT32*, void*); + using SuspendFn = HRESULT(WINAPI*)(void*, UINT32); + using ResumeFn = HRESULT(WINAPI*)(void*); + using PresentXFn = HRESULT(WINAPI*)(void*, UINT32, const void*, const void*); + void** qvtable = *reinterpret_cast(queue.Get()); + + UINT32 stat_count = 99; + check(reinterpret_cast(vtable[81])(device.Get(), 1, 1, nullptr, nullptr) == E_POINTER, + "device slot 81 GetFrameStatisticsX(nullptr count) returns E_POINTER"); + check(reinterpret_cast(vtable[81])(device.Get(), 1, 1, &stat_count, nullptr) == S_FALSE && + stat_count == 0, + "device slot 81 GetFrameStatisticsX writes count=0 and returns S_FALSE"); + + check(reinterpret_cast(qvtable[32])(queue.Get(), 0, nullptr, nullptr) == S_OK, + "queue slot 32 PresentX(0 planes) succeeds"); + check(reinterpret_cast(qvtable[32])(queue.Get(), 3, nullptr, nullptr) == E_INVALIDARG, + "queue slot 32 PresentX(>2 planes) returns E_INVALIDARG"); + check(reinterpret_cast(qvtable[23])(queue.Get(), 0) == S_OK, + "queue slot 23 SuspendX returns S_OK"); + check(reinterpret_cast(qvtable[32])(queue.Get(), 0, nullptr, nullptr) == + HRESULT_FROM_WIN32(ERROR_INVALID_STATE), + "queue slot 32 PresentX while suspended returns ERROR_INVALID_STATE"); + check(reinterpret_cast(qvtable[24])(queue.Get()) == S_OK, + "queue slot 24 ResumeX returns S_OK"); + check(reinterpret_cast(qvtable[32])(queue.Get(), 0, nullptr, nullptr) == S_OK, + "queue slot 32 PresentX succeeds again after ResumeX"); + + struct FakePresState { + int interval_calls = 0; + int schedule_calls = 0; + int wait_calls = 0; + int stats_calls = 0; + int present_calls = 0; + int suspend_calls = 0; + int resume_calls = 0; + std::uint64_t next_token = 42; + } pres_state; + const rt::d3d12_xs::XboxPresentationOps pres_ops{ + [](void* ctx, IUnknown*, UINT, UINT, UINT) -> HRESULT { + ++static_cast(ctx)->interval_calls; + return S_OK; + }, + [](void* ctx, UINT, UINT, UINT) -> HRESULT { + ++static_cast(ctx)->schedule_calls; + return S_OK; + }, + [](void* ctx, UINT, DWORD, UINT, std::uint64_t* token) -> HRESULT { + auto* s = static_cast(ctx); + ++s->wait_calls; + if (!token) return E_POINTER; + *token = s->next_token++; + return S_OK; + }, + [](void* ctx, std::uint64_t, UINT, UINT* count, void*) -> HRESULT { + ++static_cast(ctx)->stats_calls; + if (!count) return E_POINTER; + *count = 1; + return S_OK; + }, + [](void* ctx, UINT, const void*, const void*) -> HRESULT { + ++static_cast(ctx)->present_calls; + return S_OK; + }, + [](void* ctx, UINT) -> HRESULT { + ++static_cast(ctx)->suspend_calls; + return S_OK; + }, + [](void* ctx) -> HRESULT { + ++static_cast(ctx)->resume_calls; + return S_OK; + }, + }; + using SetIntervalFn = HRESULT(WINAPI*)(void*, void*, UINT32, UINT32, UINT32); + using ScheduleFn = HRESULT(WINAPI*)(void*, UINT32, UINT64, void*, UINT32); + using WaitEventFn = HRESULT(WINAPI*)(void*, UINT32, UINT32, void*, UINT32, std::uint64_t*); + + check(rt::d3d12_xs::set_device_presentation(device.Get(), &pres_state, &pres_ops), + "set_device_presentation binds callbacks to device proxy"); + std::uint64_t bound_token = 0; + UINT32 bound_stat_count = 0; + check(SUCCEEDED(reinterpret_cast(vtable[78])(device.Get(), nullptr, 16667, 2, 0)) && + SUCCEEDED(reinterpret_cast(vtable[79])(device.Get(), 0, 0, nullptr, 0)) && + SUCCEEDED(reinterpret_cast(vtable[80])(device.Get(), 0, 0, nullptr, 0, + &bound_token)) && + bound_token == 42, + "device slots 78-80 forward to bound XboxPresentationOps"); + check(reinterpret_cast(vtable[81])(device.Get(), bound_token, 1, &bound_stat_count, nullptr) == + S_OK && + bound_stat_count == 1, + "device slot 81 forwards to bound XboxPresentationOps"); + check(SUCCEEDED(reinterpret_cast(qvtable[32])(queue.Get(), 0, nullptr, nullptr)) && + SUCCEEDED(reinterpret_cast(qvtable[23])(queue.Get(), 0)) && + SUCCEEDED(reinterpret_cast(qvtable[24])(queue.Get())) && + pres_state.interval_calls == 1 && pres_state.schedule_calls == 1 && + pres_state.wait_calls == 1 && pres_state.stats_calls == 1 && + pres_state.present_calls == 1 && pres_state.suspend_calls == 1 && + pres_state.resume_calls == 1, + "queue slots 23/24/32 and device slots 78-81 all dispatch through XboxPresentationOps"); + check(rt::d3d12_xs::set_device_presentation(device.Get(), nullptr, nullptr), + "set_device_presentation(nullptr) unbinds presentation backend"); } }