mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d9] Use new common monitor functions
This commit is contained in:
parent
a623e8e7d6
commit
5e41e00456
@ -674,16 +674,10 @@ namespace dxvk {
|
|||||||
if (pRotation != nullptr)
|
if (pRotation != nullptr)
|
||||||
*pRotation = D3DDISPLAYROTATION_IDENTITY;
|
*pRotation = D3DDISPLAYROTATION_IDENTITY;
|
||||||
|
|
||||||
MONITORINFOEXW monInfo = { };
|
|
||||||
monInfo.cbSize = sizeof(monInfo);
|
|
||||||
|
|
||||||
if (!::GetMonitorInfoW(GetDefaultMonitor(), reinterpret_cast<MONITORINFO*>(&monInfo)))
|
|
||||||
throw DxvkError("D3D9Adapter::GetAdapterDisplayModeEx: Failed to query monitor info");
|
|
||||||
|
|
||||||
DEVMODEW devMode = DEVMODEW();
|
DEVMODEW devMode = DEVMODEW();
|
||||||
devMode.dmSize = sizeof(devMode);
|
devMode.dmSize = sizeof(devMode);
|
||||||
|
|
||||||
if (!::EnumDisplaySettingsW(monInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode)) {
|
if (!GetMonitorDisplayMode(GetDefaultMonitor(), ENUM_CURRENT_SETTINGS, &devMode)) {
|
||||||
Logger::err("D3D9Adapter::GetAdapterDisplayModeEx: Failed to enum display settings");
|
Logger::err("D3D9Adapter::GetAdapterDisplayModeEx: Failed to enum display settings");
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
@ -694,7 +688,6 @@ namespace dxvk {
|
|||||||
pMode->RefreshRate = devMode.dmDisplayFrequency;
|
pMode->RefreshRate = devMode.dmDisplayFrequency;
|
||||||
pMode->Format = D3DFMT_X8R8G8B8;
|
pMode->Format = D3DFMT_X8R8G8B8;
|
||||||
pMode->ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
|
pMode->ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,14 +751,6 @@ namespace dxvk {
|
|||||||
if (!m_modes.empty() && m_modeCacheFormat == Format)
|
if (!m_modes.empty() && m_modeCacheFormat == Format)
|
||||||
return; // We already cached the modes for this format. No need to do it again.
|
return; // We already cached the modes for this format. No need to do it again.
|
||||||
|
|
||||||
::MONITORINFOEXW monInfo;
|
|
||||||
monInfo.cbSize = sizeof(monInfo);
|
|
||||||
|
|
||||||
if (!::GetMonitorInfoW(GetDefaultMonitor(), reinterpret_cast<MONITORINFO*>(&monInfo))) {
|
|
||||||
Logger::err("D3D9Adapter::CacheModes: failed to query monitor info");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_modes.clear();
|
m_modes.clear();
|
||||||
m_modeCacheFormat = Format;
|
m_modeCacheFormat = Format;
|
||||||
|
|
||||||
@ -784,7 +769,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
const auto forcedRatio = Ratio<DWORD>(options.forceAspectRatio);
|
const auto forcedRatio = Ratio<DWORD>(options.forceAspectRatio);
|
||||||
|
|
||||||
while (::EnumDisplaySettingsW(monInfo.szDevice, modeIndex++, &devMode)) {
|
while (GetMonitorDisplayMode(GetDefaultMonitor(), modeIndex++, &devMode)) {
|
||||||
// Skip interlaced modes altogether
|
// Skip interlaced modes altogether
|
||||||
if (devMode.dmDisplayFlags & DM_INTERLACED)
|
if (devMode.dmDisplayFlags & DM_INTERLACED)
|
||||||
continue;
|
continue;
|
||||||
|
@ -59,46 +59,4 @@ namespace dxvk {
|
|||||||
|| BackBufferFormat == D3D9Format::R5G6B5;
|
|| BackBufferFormat == D3D9Format::R5G6B5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT SetMonitorDisplayMode(
|
|
||||||
HMONITOR hMonitor,
|
|
||||||
const D3DDISPLAYMODEEX* pMode) {
|
|
||||||
::MONITORINFOEXW monInfo;
|
|
||||||
monInfo.cbSize = sizeof(monInfo);
|
|
||||||
|
|
||||||
if (!::GetMonitorInfoW(hMonitor, reinterpret_cast<MONITORINFO*>(&monInfo))) {
|
|
||||||
Logger::err("D3D9: Failed to query monitor info");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEVMODEW devMode = { };
|
|
||||||
devMode.dmSize = sizeof(devMode);
|
|
||||||
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
|
||||||
devMode.dmPelsWidth = pMode->Width;
|
|
||||||
devMode.dmPelsHeight = pMode->Height;
|
|
||||||
devMode.dmBitsPerPel = GetMonitorFormatBpp(EnumerateFormat(pMode->Format));
|
|
||||||
|
|
||||||
if (pMode->RefreshRate != 0) {
|
|
||||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
|
||||||
devMode.dmDisplayFrequency = pMode->RefreshRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::info(str::format("D3D9: Setting display mode: ",
|
|
||||||
devMode.dmPelsWidth, "x", devMode.dmPelsHeight, "@",
|
|
||||||
devMode.dmDisplayFrequency));
|
|
||||||
|
|
||||||
LONG status = ::ChangeDisplaySettingsExW(
|
|
||||||
monInfo.szDevice, &devMode, nullptr, CDS_FULLSCREEN, nullptr);
|
|
||||||
|
|
||||||
if (status != DISP_CHANGE_SUCCESSFUL) {
|
|
||||||
// Try again but without setting the frequency.
|
|
||||||
devMode.dmFields &= ~DM_DISPLAYFREQUENCY;
|
|
||||||
devMode.dmDisplayFrequency = 0;
|
|
||||||
status = ::ChangeDisplaySettingsExW(
|
|
||||||
monInfo.szDevice, &devMode, nullptr, CDS_FULLSCREEN, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return status == DISP_CHANGE_SUCCESSFUL ? D3D_OK : D3DERR_NOTAVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -35,15 +35,4 @@ namespace dxvk {
|
|||||||
D3D9Format BackBufferFormat,
|
D3D9Format BackBufferFormat,
|
||||||
BOOL Windowed);
|
BOOL Windowed);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Sets monitor display mode
|
|
||||||
*
|
|
||||||
* \param [in] hMonitor Monitor handle
|
|
||||||
* \param [in] pMode Display mode properties
|
|
||||||
* \returns S_OK on success
|
|
||||||
*/
|
|
||||||
HRESULT SetMonitorDisplayMode(
|
|
||||||
HMONITOR hMonitor,
|
|
||||||
const D3DDISPLAYMODEEX* pMode);
|
|
||||||
|
|
||||||
}
|
}
|
@ -32,8 +32,6 @@ namespace dxvk {
|
|||||||
, m_frameLatencyCap (pDevice->GetOptions()->maxFrameLatency)
|
, m_frameLatencyCap (pDevice->GetOptions()->maxFrameLatency)
|
||||||
, m_frameLatencySignal(new sync::Fence(m_frameId))
|
, m_frameLatencySignal(new sync::Fence(m_frameId))
|
||||||
, m_dialog (pDevice->GetOptions()->enableDialogMode) {
|
, m_dialog (pDevice->GetOptions()->enableDialogMode) {
|
||||||
UpdateMonitorInfo();
|
|
||||||
|
|
||||||
this->NormalizePresentParameters(pPresentParams);
|
this->NormalizePresentParameters(pPresentParams);
|
||||||
m_presentParams = *pPresentParams;
|
m_presentParams = *pPresentParams;
|
||||||
m_window = m_presentParams.hDeviceWindow;
|
m_window = m_presentParams.hDeviceWindow;
|
||||||
@ -437,7 +435,7 @@ namespace dxvk {
|
|||||||
DEVMODEW devMode = DEVMODEW();
|
DEVMODEW devMode = DEVMODEW();
|
||||||
devMode.dmSize = sizeof(devMode);
|
devMode.dmSize = sizeof(devMode);
|
||||||
|
|
||||||
if (!::EnumDisplaySettingsW(m_monInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode)) {
|
if (!GetMonitorDisplayMode(m_monitor, ENUM_CURRENT_SETTINGS, &devMode)) {
|
||||||
Logger::err("D3D9SwapChainEx::GetDisplayModeEx: Failed to enum display settings");
|
Logger::err("D3D9SwapChainEx::GetDisplayModeEx: Failed to enum display settings");
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
@ -1277,7 +1275,6 @@ namespace dxvk {
|
|||||||
SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
|
SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
|
||||||
|
|
||||||
m_monitor = GetDefaultMonitor();
|
m_monitor = GetDefaultMonitor();
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1318,7 +1315,9 @@ namespace dxvk {
|
|||||||
const D3DDISPLAYMODEEX* pFullscreenDisplayMode) {
|
const D3DDISPLAYMODEEX* pFullscreenDisplayMode) {
|
||||||
D3DDISPLAYMODEEX mode;
|
D3DDISPLAYMODEEX mode;
|
||||||
|
|
||||||
if (pFullscreenDisplayMode == nullptr) {
|
if (pFullscreenDisplayMode) {
|
||||||
|
mode = *pFullscreenDisplayMode;
|
||||||
|
} else {
|
||||||
mode.Width = pPresentParams->BackBufferWidth;
|
mode.Width = pPresentParams->BackBufferWidth;
|
||||||
mode.Height = pPresentParams->BackBufferHeight;
|
mode.Height = pPresentParams->BackBufferHeight;
|
||||||
mode.Format = pPresentParams->BackBufferFormat;
|
mode.Format = pPresentParams->BackBufferFormat;
|
||||||
@ -1327,7 +1326,21 @@ namespace dxvk {
|
|||||||
mode.Size = sizeof(D3DDISPLAYMODEEX);
|
mode.Size = sizeof(D3DDISPLAYMODEEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SetMonitorDisplayMode(GetDefaultMonitor(), pFullscreenDisplayMode == nullptr ? &mode : pFullscreenDisplayMode);
|
DEVMODEW devMode = { };
|
||||||
|
devMode.dmSize = sizeof(devMode);
|
||||||
|
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
||||||
|
devMode.dmPelsWidth = mode.Width;
|
||||||
|
devMode.dmPelsHeight = mode.Height;
|
||||||
|
devMode.dmBitsPerPel = GetMonitorFormatBpp(EnumerateFormat(mode.Format));
|
||||||
|
|
||||||
|
if (mode.RefreshRate != 0) {
|
||||||
|
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||||
|
devMode.dmDisplayFrequency = mode.RefreshRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetMonitorDisplayMode(GetDefaultMonitor(), &devMode)
|
||||||
|
? D3D_OK
|
||||||
|
: D3DERR_NOTAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1335,25 +1348,9 @@ namespace dxvk {
|
|||||||
if (hMonitor == nullptr)
|
if (hMonitor == nullptr)
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
DEVMODEW devMode = { };
|
return RestoreMonitorDisplayMode(hMonitor)
|
||||||
devMode.dmSize = sizeof(devMode);
|
? D3D_OK
|
||||||
|
: D3DERR_NOTAVAILABLE;
|
||||||
if (!::EnumDisplaySettingsW(m_monInfo.szDevice, ENUM_REGISTRY_SETTINGS, &devMode))
|
|
||||||
return D3DERR_INVALIDCALL;
|
|
||||||
|
|
||||||
Logger::info(str::format("D3D9: Setting display mode: ",
|
|
||||||
devMode.dmPelsWidth, "x", devMode.dmPelsHeight, "@",
|
|
||||||
devMode.dmDisplayFrequency));
|
|
||||||
|
|
||||||
D3DDISPLAYMODEEX mode;
|
|
||||||
mode.Width = devMode.dmPelsWidth;
|
|
||||||
mode.Height = devMode.dmPelsHeight;
|
|
||||||
mode.RefreshRate = devMode.dmDisplayFrequency;
|
|
||||||
mode.Format = D3DFMT_X8R8G8B8; // Fix me
|
|
||||||
mode.ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
|
|
||||||
mode.Size = sizeof(D3DDISPLAYMODEEX);
|
|
||||||
|
|
||||||
return SetMonitorDisplayMode(GetDefaultMonitor(), &mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool D3D9SwapChainEx::UpdatePresentRegion(const RECT* pSourceRect, const RECT* pDestRect) {
|
bool D3D9SwapChainEx::UpdatePresentRegion(const RECT* pSourceRect, const RECT* pDestRect) {
|
||||||
@ -1397,13 +1394,6 @@ namespace dxvk {
|
|||||||
std::max<uint32_t>(m_dstRect.bottom - m_dstRect.top, 1u) };
|
std::max<uint32_t>(m_dstRect.bottom - m_dstRect.top, 1u) };
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D9SwapChainEx::UpdateMonitorInfo() {
|
|
||||||
m_monInfo.cbSize = sizeof(m_monInfo);
|
|
||||||
|
|
||||||
if (!::GetMonitorInfoW(GetDefaultMonitor(), reinterpret_cast<MONITORINFO*>(&m_monInfo)))
|
|
||||||
throw DxvkError("D3D9SwapChainEx::GetDisplayModeEx: Failed to query monitor info");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkFullScreenExclusiveEXT D3D9SwapChainEx::PickFullscreenMode() {
|
VkFullScreenExclusiveEXT D3D9SwapChainEx::PickFullscreenMode() {
|
||||||
return m_dialog
|
return m_dialog
|
||||||
|
@ -152,8 +152,6 @@ namespace dxvk {
|
|||||||
HWND m_window = nullptr;
|
HWND m_window = nullptr;
|
||||||
HMONITOR m_monitor = nullptr;
|
HMONITOR m_monitor = nullptr;
|
||||||
|
|
||||||
MONITORINFOEXW m_monInfo;
|
|
||||||
|
|
||||||
WindowState m_windowState;
|
WindowState m_windowState;
|
||||||
|
|
||||||
void PresentImage(UINT PresentInterval);
|
void PresentImage(UINT PresentInterval);
|
||||||
@ -215,8 +213,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
HRESULT RestoreDisplayMode(HMONITOR hMonitor);
|
HRESULT RestoreDisplayMode(HMONITOR hMonitor);
|
||||||
|
|
||||||
void UpdateMonitorInfo();
|
|
||||||
|
|
||||||
bool UpdatePresentRegion(const RECT* pSourceRect, const RECT* pDestRect);
|
bool UpdatePresentRegion(const RECT* pSourceRect, const RECT* pDestRect);
|
||||||
|
|
||||||
VkExtent2D GetPresentExtent();
|
VkExtent2D GetPresentExtent();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user