From 91574993dfe027ff2045c4b71626936e03ab4025 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Mon, 6 Jan 2020 04:06:45 +0000 Subject: [PATCH] [d3d9] Return current display mode in GetAdapterDisplayModeEx rather than last mode Fixes fullscreen at < native res in Vampire: The Masquerade Bloodlines 1/2 --- src/d3d9/d3d9_adapter.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/d3d9/d3d9_adapter.cpp b/src/d3d9/d3d9_adapter.cpp index c9081f82c..29f558db3 100644 --- a/src/d3d9/d3d9_adapter.cpp +++ b/src/d3d9/d3d9_adapter.cpp @@ -667,15 +667,34 @@ namespace dxvk { HRESULT D3D9Adapter::GetAdapterDisplayModeEx( D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation) { + if (pMode == nullptr) + return D3DERR_INVALIDCALL; + if (pRotation != nullptr) *pRotation = D3DDISPLAYROTATION_IDENTITY; - D3DDISPLAYMODEFILTER filter; - filter.Size = sizeof(filter); - filter.Format = D3DFMT_X8R8G8B8; - filter.ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE; + MONITORINFOEXW monInfo = { }; + monInfo.cbSize = sizeof(monInfo); - return this->EnumAdapterModesEx(&filter, 0, pMode); + if (!::GetMonitorInfoW(GetDefaultMonitor(), reinterpret_cast(&monInfo))) + throw DxvkError("D3D9Adapter::GetAdapterDisplayModeEx: Failed to query monitor info"); + + DEVMODEW devMode = DEVMODEW(); + devMode.dmSize = sizeof(devMode); + + if (!::EnumDisplaySettingsW(monInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode)) { + Logger::err("D3D9Adapter::GetAdapterDisplayModeEx: Failed to enum display settings"); + return D3DERR_INVALIDCALL; + } + + pMode->Size = sizeof(D3DDISPLAYMODEEX); + pMode->Width = devMode.dmPelsWidth; + pMode->Height = devMode.dmPelsHeight; + pMode->RefreshRate = devMode.dmDisplayFrequency; + pMode->Format = D3DFMT_X8R8G8B8; + pMode->ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE; + + return D3D_OK; }