1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

[dxgi] Notify presenter about display mode changes

This commit is contained in:
Philip Rebohle 2021-06-09 03:47:50 +02:00 committed by Philip Rebohle
parent e281eee795
commit 6044e63eb0
2 changed files with 34 additions and 1 deletions

View File

@ -365,8 +365,10 @@ namespace dxvk {
} }
// If the swap chain allows it, change the display mode // If the swap chain allows it, change the display mode
if (m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH) if (m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH) {
ChangeDisplayMode(output.ptr(), pNewTargetParameters); ChangeDisplayMode(output.ptr(), pNewTargetParameters);
NotifyModeChange(m_monitor, FALSE);
}
// Resize and reposition the window to // Resize and reposition the window to
DXGI_OUTPUT_DESC desc; DXGI_OUTPUT_DESC desc;
@ -622,6 +624,7 @@ namespace dxvk {
ReleaseMonitorData(); ReleaseMonitorData();
} }
NotifyModeChange(m_monitor, FALSE);
return S_OK; return S_OK;
} }
@ -642,6 +645,8 @@ namespace dxvk {
} }
// Restore internal state // Restore internal state
HMONITOR monitor = m_monitor;
m_descFs.Windowed = TRUE; m_descFs.Windowed = TRUE;
m_monitor = nullptr; m_monitor = nullptr;
m_target = nullptr; m_target = nullptr;
@ -667,6 +672,7 @@ namespace dxvk {
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
SWP_FRAMECHANGED | SWP_NOACTIVATE); SWP_FRAMECHANGED | SWP_NOACTIVATE);
NotifyModeChange(monitor, TRUE);
return S_OK; return S_OK;
} }
@ -776,4 +782,27 @@ namespace dxvk {
m_monitorInfo->ReleaseMonitorData(); m_monitorInfo->ReleaseMonitorData();
} }
void DxgiSwapChain::NotifyModeChange(
HMONITOR hMonitor,
BOOL Windowed) {
DEVMODEW devMode = { };
devMode.dmSize = sizeof(devMode);
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
if (GetMonitorDisplayMode(hMonitor, ENUM_CURRENT_SETTINGS, &devMode)) {
DXGI_MODE_DESC displayMode = { };
displayMode.Width = devMode.dmPelsWidth;
displayMode.Height = devMode.dmPelsHeight;
displayMode.RefreshRate = { devMode.dmDisplayFrequency, 1 };
displayMode.Format = m_desc.Format;
displayMode.ScanlineOrdering = m_descFs.ScanlineOrdering;
displayMode.Scaling = m_descFs.Scaling;
m_presenter->NotifyModeChange(Windowed, &displayMode);
} else {
Logger::warn("Failed to query current display mode");
m_presenter->NotifyModeChange(Windowed, nullptr);
}
}
} }

View File

@ -219,6 +219,10 @@ namespace dxvk {
void ReleaseMonitorData(); void ReleaseMonitorData();
void NotifyModeChange(
HMONITOR hMonitor,
BOOL Windowed);
}; };
} }