Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,7 @@ 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. |
| Device slot 81, queue `PresentX`/`SuspendX`/`ResumeX` | XCL (GPL-2.0-only, third-party): `GetFrameStatisticsX` at device slot 81, `PresentX` at queue slot 30 (older runtime layout) or 32 (newer); `SuspendX`/`ResumeX` slots unmeasured | `set_presentation_handler` forwards 78-81 and the queue routes to a presenter (`attach_xbox_presentation`; `gta6rt` creates no `XboxPresentation` yet). Without one, slot 81 answers `S_FALSE` with a zero count (no statistics yet) and the queue slots stay refused. Moved with `LEONIDA_XS_FRAME_STATISTICS_SLOT` (3..127) and `LEONIDA_XS_PRESENT_X_SLOT` (default 30); `SuspendX` and `ResumeX` are routed only when `LEONIDA_XS_SUSPEND_X_SLOT` / `LEONIDA_XS_RESUME_X_SLOT` are set (queue slots 19..127; two routes on one slot are refused with a log). |
| 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
171 changes: 146 additions & 25 deletions runtime/shims/d3d12_xs_device.cpp

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions runtime/shims/d3d12_xs_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ using ConsoleDescriptorHeapHandler = HRESULT (*)(ID3D12Device* real, const D3D12
REFIID riid, void** out);
void set_console_descriptor_heap_handler(ConsoleDescriptorHeapHandler handler);

// Presentation wiring: connects device frame-event slots (78/79/80/81: SetFrameIntervalX, ScheduleFrameEventX,
// WaitFrameEventX, GetFrameStatisticsX; 81 is LEONIDA_XS_FRAME_STATISTICS_SLOT) and queue presentation slots (PresentX
// at 30, or LEONIDA_XS_PRESENT_X_SLOT; SuspendX and ResumeX are routed only when LEONIDA_XS_SUSPEND_X_SLOT /
// LEONIDA_XS_RESUME_X_SLOT are set) to an external presenter such as rt::d3d12::XboxPresentation without coupling
// d3d12_xs_device to Vulkan headers. Passing nullptr detaches the handler and restores the default mock/fallback
// behavior.
struct PresentationHandler {
void* context = nullptr;
HRESULT (*set_frame_interval)(void* context, IUnknown* output, UINT interval_us, UINT latency, UINT flags) = nullptr;
HRESULT (*schedule_frame_event)(void* context, UINT event, UINT offset_us, UINT flags) = nullptr;
HRESULT (*wait_frame_event)(void* context, UINT event, DWORD timeout_ms, UINT flags, std::uint64_t* token) = nullptr;
HRESULT (*get_frame_statistics)(void* context, std::uint64_t token, UINT type_mask, UINT* count, void* out) = nullptr;
HRESULT (*present_x)(void* context, UINT plane_count, const void* planes, const void* params) = nullptr;
HRESULT (*suspend_x)(void* context, UINT flags) = nullptr;
HRESULT (*resume_x)(void* context) = nullptr;
};
bool set_presentation_handler(void* device, const PresentationHandler* handler);

// True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue
// proxies), 9 (allocator proxies), 14, 26 (the console's struct-return form),
// 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 48/73 and
Expand Down
36 changes: 36 additions & 0 deletions runtime/shims/xbox_present.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "xbox_present.h"

#include "d3d12_trace.h"
#include "d3d12_xs_device.h"

#include "../src/vulkan_present.h"

Expand Down Expand Up @@ -314,4 +315,39 @@ HRESULT XboxPresentation::ResumeX() {
return S_OK;
}

bool attach_xbox_presentation(void* device_proxy, XboxPresentation* presentation) {
if (!presentation) return rt::d3d12_xs::set_presentation_handler(device_proxy, nullptr);
rt::d3d12_xs::PresentationHandler handler{};
handler.context = presentation;
handler.set_frame_interval = [](void* ctx, IUnknown* output, UINT interval_us, UINT latency, UINT flags) {
return static_cast<XboxPresentation*>(ctx)->SetFrameIntervalX(output, interval_us, latency, flags);
};
handler.schedule_frame_event = [](void* ctx, UINT event, UINT offset_us, UINT flags) {
return static_cast<XboxPresentation*>(ctx)->ScheduleFrameEventX(event, offset_us, flags);
};
handler.wait_frame_event = [](void* ctx, UINT event, DWORD timeout_ms, UINT flags, std::uint64_t* token) {
return static_cast<XboxPresentation*>(ctx)->WaitFrameEventX(event, timeout_ms, flags, token);
};
handler.get_frame_statistics = [](void* ctx, std::uint64_t token, UINT type_mask, UINT* count, void* out) {
return static_cast<XboxPresentation*>(ctx)->GetFrameStatisticsX(
token, type_mask, count, static_cast<leonida::FrameStatistic*>(out));
};
handler.present_x = [](void* ctx, UINT plane_count, const void* planes, const void* params) {
return static_cast<XboxPresentation*>(ctx)->PresentX(
plane_count, static_cast<const XboxPresentPlaneParameters*>(planes),
static_cast<const XboxPresentParameters*>(params));
};
handler.suspend_x = [](void* ctx, UINT flags) {
return static_cast<XboxPresentation*>(ctx)->SuspendX(flags);
};
handler.resume_x = [](void* ctx) {
return static_cast<XboxPresentation*>(ctx)->ResumeX();
};
return rt::d3d12_xs::set_presentation_handler(device_proxy, &handler);
}

bool detach_xbox_presentation(void* device_proxy) {
return rt::d3d12_xs::set_presentation_handler(device_proxy, nullptr);
}

} // namespace rt::d3d12
10 changes: 10 additions & 0 deletions runtime/shims/xbox_present.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,15 @@ class XboxPresentation {
};

inline constexpr UINT xbox_frame_event_origin = leonida::frame_event_origin;
inline constexpr UINT xbox_frame_event_vblank = leonida::frame_event_vblank;
inline constexpr UINT xbox_frame_event_flip = leonida::frame_event_flip;
inline constexpr UINT xbox_frame_wait_token_on_timeout = leonida::frame_wait_flag_token_on_timeout;

// Seam for the presenter, not yet called by the runtime: gta6rt creates no XboxPresentation, and only
// d3d12_boot_movie_test and xbox_present_test construct one. Wires it into a d3d12_xs device proxy's frame-event
// slots (78–81) and queue PresentX (slot 30, or LEONIDA_XS_PRESENT_X_SLOT); SuspendX and ResumeX are routed only
// when LEONIDA_XS_SUSPEND_X_SLOT / LEONIDA_XS_RESUME_X_SLOT are set. Passing nullptr detaches the presentation.
bool attach_xbox_presentation(void* device_proxy, XboxPresentation* presentation);
bool detach_xbox_presentation(void* device_proxy);

} // namespace rt::d3d12
Loading
Loading