The render target is the size that was asked for
A crosshair off-centre on the second race, and underneath it every race after the first was a different race. Windowed, BackBufferWidth/Height were left at zero, so D3D sized the back buffer to the device window's client area at the moment the device was created. Everything downstream is built from the size we ASKED for instead - the projection matrix takes its aspect from it, the reticle is centred on it - so a window that was not exactly that size rendered at the wrong shape and got rescaled on the way to the viewscreen pane. -fit decided which window that was, and it decided differently for the first mission than for the rest. Its borderless full-monitor placement lived only in SVGA16's cockpit build, which does not run until a mission starts - just after that mission has built its device. So race one was set up against a still-bordered client and every race after it against the borderless monitor. On a 3440x1440 panel that is a 1.778 image drawn across a 2.389 target, against 1.816 the first time. That is not a cosmetic difference. The simulation advances on wall-clock deltas, so frame cost is physics: two render targets that size and scale differently are two different races from one lobby and one set of settings. A racing sim does not get to do that. So: the back buffer is the requested size windowed as well as full-screen, and -fit takes its shape at startup rather than four screens later. SVGA16 still applies the same rect when it builds the cockpit - that call is now a no-op instead of a change, which is the point. The first lobby also stops being the only one with a title bar. The reticle keeps its own share of the blame and is fixed on its own terms, so it cannot drift again if a target ever does move: - It is measured against the viewport at draw time and rebuilt when that changes, rather than baked once in the constructor from the renderer's requested size. One GetViewport a frame, no rewrite until it moves. - The arms are quads, not lines. D3D9 line rasterisation follows the diamond-exit rule and is free to differ between drivers on a segment running along a pixel boundary, which is how a crosshair loses one pair of arms and keeps the other - and full-screen, where both dimensions are usually even and both pairs sit on boundaries, how it can lose the lot. - Arm thickness follows the target rather than being one pixel whatever the resolution. One pixel is a width the presentation can throw away in a downscale, and it was a hairline at 1440 next to the pod's line at 480. The log names the viewport, the requested size and where the crosshair landed, and says TARGET DISAGREES with both aspects when the first two do not match - so the next report of this arrives with its own diagnosis. Window creation cleaned up while in there: it computed a style and then handed CreateWindowEx a literal WS_OVERLAPPEDWINDOW regardless, so the full-screen path never got the WS_POPUP it thought it was asking for. Borderless modes are now born borderless instead of being restyled a moment after. The requested size also goes through AdjustWindowRect, because -res is a render size and was being used as the OUTER rectangle with the chrome taken out of the middle - which is how -res 640 480 came to present into a 624x441 client and started all of this. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -302,6 +302,72 @@ void
|
||||
<< monitor_w << "x" << monitor_h << " monitor\n" << std::flush;
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// FitWindowToMonitor
|
||||
//#############################################################################
|
||||
//
|
||||
// -fit's borderless full-monitor placement, applied to the shell window.
|
||||
//
|
||||
// This has to happen BEFORE the first race, not during it. SVGA16 does the
|
||||
// same thing when it assembles the cockpit, but that is not until a mission
|
||||
// starts - and the D3D device is created just ahead of it, against whatever
|
||||
// the window is at that moment. So the first race got a device sized to a
|
||||
// still-bordered window and every race after it got one sized to the
|
||||
// borderless monitor: two different render targets, two different frame
|
||||
// costs, from one lobby and one set of settings.
|
||||
//
|
||||
// A racing sim cannot have that. The window reaches its final shape while
|
||||
// the front end is still up, so every mission of a session - the first one
|
||||
// included - is set up against exactly the same client area.
|
||||
//
|
||||
// SVGA16 still applies it when it builds the cockpit. That call becomes a
|
||||
// no-op rather than a change, which is the point.
|
||||
//
|
||||
void
|
||||
L4Application::FitWindowToMonitor(HWND window)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RECT monitor_rect;
|
||||
monitor_rect.left = 0;
|
||||
monitor_rect.top = 0;
|
||||
monitor_rect.right = GetSystemMetrics(SM_CXSCREEN);
|
||||
monitor_rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
MONITORINFO monitor;
|
||||
memset(&monitor, 0, sizeof(monitor));
|
||||
monitor.cbSize = sizeof(monitor);
|
||||
HMONITOR handle = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (GetMonitorInfoA(handle, &monitor))
|
||||
{
|
||||
monitor_rect = monitor.rcMonitor;
|
||||
}
|
||||
|
||||
//
|
||||
// Same style surgery SVGA16 performs, so the two agree exactly.
|
||||
//
|
||||
LONG_PTR style = GetWindowLongPtrA(window, GWL_STYLE);
|
||||
style &= ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU |
|
||||
WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_BORDER | WS_DLGFRAME);
|
||||
style |= WS_POPUP | WS_CLIPCHILDREN;
|
||||
SetWindowLongPtrA(window, GWL_STYLE, style);
|
||||
|
||||
SetWindowPos(window, NULL,
|
||||
monitor_rect.left, monitor_rect.top,
|
||||
monitor_rect.right - monitor_rect.left,
|
||||
monitor_rect.bottom - monitor_rect.top,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
||||
|
||||
DEBUG_STREAM << "L4Application: -fit placed the window borderless at "
|
||||
<< (monitor_rect.right - monitor_rect.left) << "x"
|
||||
<< (monitor_rect.bottom - monitor_rect.top)
|
||||
<< " before the first mission\n" << std::flush;
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// ParseCommandLine
|
||||
|
||||
Reference in New Issue
Block a user