mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 12:58:38 +00:00
One squashed commit of a fork that was developed on a Linux/Proton machine and tested on two native Windows machines. On all of them the retail 1.0.2.1 package now launches, shows its launch movie, first-run pages and landing prompt, runs the story load to its end with the loading slideshow drawing its artwork, and enters the world phase. A first world frame is not verified yet. docs/linux_proton.md has the setup, a healthy boot's timeline, the machines and where it stops. Runtime: frames in the title's own window; DirectStorage pinned reads, page-list scatter/gather, BCPack and unshuffle with a locally generated predictor file; pooled, device-local and deferred image backing for streamed and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table that degrades instead of refusing a submission; a descriptor hash finalizer (off until a library carries it); directly indexed heap offsets for compute dispatches and VS/PS/GS draws; title buffer windows outside a fragmented arena; opt-in device-local copies of streamed buffer views; write-fault retries under the tracker lock, shared trackers and write-watched title memory for native Windows; device-loss, compute-input and memory probes. Translator: loop bounds at structured exits, the eight FidelityFX programs that use a packed-dot form the disassembler skips, buffer bounds modes per view kind, a compaction option, the hash finalizer option. Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows boot script, the paired compute translation script. No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted by people on the machines named in docs/linux_proton.md. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
53 lines
2.6 KiB
C++
53 lines
2.6 KiB
C++
#pragma once
|
|
|
|
// The window a GDKX title shows its frames in, for PresentX.
|
|
//
|
|
// On the console PresentX puts a frame on the display: it names no window. A GDKX title still makes its own top-level
|
|
// Win32 window (CreateWindowExW with its own class, a message loop on its own thread) before it presents, so on the PC
|
|
// that window is where the frames belong. Measured on a retail executable: by its first PresentX the title has one
|
|
// visible, unowned top-level window on a thread of its own; the other windows of the process at that point are hidden
|
|
// (the IME windows Windows adds, a driver's dummy window).
|
|
//
|
|
// The lookup sends no message to any window. The present thread is not the title's window thread, and that thread can
|
|
// be busy (or waiting on the present thread) when the first PresentX comes: GetWindowTextW, or any call that sends a
|
|
// message across threads, would block the present thread there. Measured: a lookup that read the window titles with
|
|
// GetWindowTextW stopped the retail title at its first PresentX. EnumWindows, GetWindowThreadProcessId, IsWindowVisible,
|
|
// GetWindow(GW_OWNER), GetWindowLongPtrW and GetClientRect read the window manager's own state and send nothing.
|
|
|
|
#include <windows.h>
|
|
|
|
namespace rt::d3d12 {
|
|
|
|
// The visible, unowned, non-tool top-level window of `process_id` with the largest client area, `exclude` aside (the
|
|
// runtime's own fallback window); null when the process has none. Ties keep the first one in Z order (the topmost).
|
|
inline HWND find_title_window(DWORD process_id, HWND exclude = nullptr) {
|
|
struct Search {
|
|
DWORD process_id;
|
|
HWND exclude;
|
|
HWND best;
|
|
LONGLONG best_area;
|
|
} search{process_id, exclude, nullptr, -1};
|
|
EnumWindows(
|
|
[](HWND window, LPARAM context) -> BOOL {
|
|
auto& s = *reinterpret_cast<Search*>(context);
|
|
DWORD owner_process = 0;
|
|
if (window == s.exclude || !GetWindowThreadProcessId(window, &owner_process) ||
|
|
owner_process != s.process_id)
|
|
return TRUE;
|
|
if (!IsWindowVisible(window) || GetWindow(window, GW_OWNER)) return TRUE;
|
|
if (GetWindowLongPtrW(window, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) return TRUE;
|
|
RECT client{};
|
|
const LONGLONG area =
|
|
GetClientRect(window, &client) ? LONGLONG(client.right - client.left) * (client.bottom - client.top) : 0;
|
|
if (area > s.best_area) {
|
|
s.best = window;
|
|
s.best_area = area;
|
|
}
|
|
return TRUE;
|
|
},
|
|
reinterpret_cast<LPARAM>(&search));
|
|
return search.best;
|
|
}
|
|
|
|
} // namespace rt::d3d12
|