Repository navigation
Conversation
…its frames in A GDKX title makes its own top-level Win32 window before its first PresentX, and PresentX names no window: on the PC the frames belong in that window. Measured on a retail executable: by the first PresentX the process has one visible, unowned top-level window on a thread of its own, and only hidden windows besides (IME, a driver's dummy window). The PresentX wiring (ItsNotRexed#2490) built a hidden window of its own instead, so a running title showed a blank window. find_title_window picks the visible, unowned, non-tool top-level window of the process with the largest client area. It sends no message: a lookup that read window titles with GetWindowTextW (a WM_GETTEXT sent across threads) stopped the retail title at its first PresentX, because the title's window thread was not pumping at that moment. title_window_test makes the windows on a thread that never pumps; the negative control shows a sent WM_GETTEXT times out there, while the lookup answers at once and skips the larger hidden, owned and tool windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested commit Build & Test Verification
Code Review
AI-assisted. |
|
Tested
|
|
Tested ec41c22 on Wine 11.22 with RTX 5070 Ti (NVIDIA 620.73.04). The synthetic title_window CTest passed. A local integration with #7685 and #7448 selected the title's own visible window and recorded over 1,000 successful one-plane PresentX calls to it. Two sampled frames in that window remained black. The command-list diagnostics point to a separate RTV-handle recording failure covered by #7880, which is being tested separately. AI-assisted verification. No game files, screenshots or traces attached. |
|
The diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp
index af7f22599..efc4d1d68 100644
--- a/runtime/shims/d3d12_xs_device.cpp
+++ b/runtime/shims/d3d12_xs_device.cpp
@@ -25,6 +25,7 @@
// for a trace that disagrees. The frame-event calls answer from a per-device token counter: there is no vblank source
// behind the device before a presenter exists, so WaitFrameEventX returns at once with a fresh non-zero token.
#include "d3d12_xs_device.h"
+#include "title_window.h"
#include "d3d12_trace.h"
#include "d3d12_xs_alloc_size.h"
#include "d3d12_xs_desc_clean.h"
@@ -1294,9 +1295,10 @@ LONG CALLBACK table_overrun_handler(EXCEPTION_POINTERS* info) {
struct PresentState {
~PresentState() {
- if (window) DestroyWindow(window); // the presentation and its window die with the device proxy
+ if (window && owns_window) DestroyWindow(window); // the title's own window is never destroyed (#8591)
}
HWND window = nullptr;
+ bool owns_window = false;
std::unique_ptr<rt::d3d12::XboxPresentation> xbox;
bool tried = false; // creation is attempted once; a null xbox means this device cannot present
};
@@ -1317,17 +1319,25 @@ PresentState* present_state_for(DeviceProxy* device) {
if (!state) return nullptr;
device->present_state = state;
state->tried = true;
+ // The title's own top-level window, when it has one (#8591): frames go where the player looks.
+ if (HWND title = rt::d3d12::find_title_window(GetCurrentProcessId())) {
+ state->window = title;
+ std::fprintf(stderr, "[rt] d3d12_xs: PresentX presents into the title's window %p\n", static_cast<void*>(title));
+ }
WNDCLASSW window_class{};
window_class.lpfnWndProc = present_window_proc;
window_class.hInstance = GetModuleHandleW(nullptr);
window_class.lpszClassName = L"LeonidaPresentX";
- if (!RegisterClassW(&window_class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) {
+ if (!state->window && !RegisterClassW(&window_class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) {
std::fprintf(stderr, "[rt] d3d12_xs: PresentX window class failed (error %lu)\n", GetLastError());
return state;
}
- state->window = CreateWindowExW(0, window_class.lpszClassName, L"Leonida", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr,
- window_class.hInstance, nullptr);
+ if (!state->window) { // a title without a window of its own: the runtime's, hidden as before
+ state->window = CreateWindowExW(0, window_class.lpszClassName, L"Leonida", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr,
+ window_class.hInstance, nullptr);
+ state->owns_window = state->window != nullptr;
+ }
if (!state->window) {
std::fprintf(stderr, "[rt] d3d12_xs: PresentX window failed (error %lu)\n", GetLastError());
return state;AI-assisted (Claude Code). |
|
A33 integration follow-up for #8591. On Windows 11 28000.3501, I tested the exact Simple local wiring of the finder into the existing once-per-device latch, with borrowed-window teardown fixed, passed 14/19 checks. A visible 0×0 placeholder could be selected on the first call and stay pinned when a different, usable title window appeared. If the same HWND resized, the direct wiring worked. A local candidate passed 19/19. It distinguishes a ready client area, an existing but transient client, and a truly absent candidate. On transient it defers before caching any state. On absent it keeps the existing fallback. Teardown destroys only the runtime-owned fallback and leaves the title window alive. These checks cover binding and ownership before the Vulkan constructor. No full Vulkan or retail run. AI-assisted (Codex). |
|
Tested
AI-assisted (Claude Code). |
What and why
On the console, PresentX puts a frame on the display and names no window. A GDKX title still makes its own top-level Win32 window, with its own class and a message loop on its own thread, before it presents. On the PC the frames belong in that window.
Measured on a retail executable (Vulkan device, integration stack with #2490):
present_state_forbuilt a hidden window of its own (WS_OVERLAPPEDWINDOW, never shown, no message loop) and presented there. The title's window stayed white for the whole run (~3,000 PresentX calls in 44 s).GetWindowTextW. That sendsWM_GETTEXTacross threads, and it stopped the title at its first PresentX because the title's window thread was not pumping at that moment.The change
runtime/shims/title_window.h:rt::d3d12::find_title_window(process_id, exclude)returns the visible, unowned, non-tool top-level window of the process with the largest client area, or null. It only reads window-manager state (EnumWindows,GetWindowThreadProcessId,IsWindowVisible,GetWindow(GW_OWNER),GetWindowLongPtrW,GetClientRect) and sends no message.On its own it changes nothing on
main, becausemainhas no PresentX queue wiring. #2490'spresent_state_forshould present intofind_title_window(GetCurrentProcessId())when it finds one, keep its own window only for a title that has none, and not destroy the title's window. The local integration does exactly that. With #7685 applied there too (PresentX's tokens), the presents go to the title's window.Test
title_window_test(ctesttitle_window) makes five windows on a thread that never pumps its messages: the title window, a smaller visible one, and larger hidden, owned and tool windows. It checks that:Negative control: a
WM_GETTEXTsent to the title window times out (200 ms), so a lookup that sent messages would block there. Dropping the owner check makes the test fail (found == windows.title).🤖 Generated with Claude Code