mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-22 07:54:15 +01:00
[dxgi] Use new mode switch API for DxgiSwapChain
This commit is contained in:
parent
1594a20b94
commit
d9cf8fdc58
@ -43,10 +43,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
DxgiSwapChain::~DxgiSwapChain() {
|
DxgiSwapChain::~DxgiSwapChain() {
|
||||||
Com<IDXGIOutput> output;
|
RestoreDisplayMode(m_monitor);
|
||||||
|
|
||||||
if (SUCCEEDED(GetOutputFromMonitor(m_monitor, &output)))
|
|
||||||
RestoreDisplayMode(output.ptr());
|
|
||||||
|
|
||||||
// Decouple swap chain from monitor if necessary
|
// Decouple swap chain from monitor if necessary
|
||||||
DXGI_VK_MONITOR_DATA* monitorInfo = nullptr;
|
DXGI_VK_MONITOR_DATA* monitorInfo = nullptr;
|
||||||
@ -584,13 +581,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
HRESULT DxgiSwapChain::LeaveFullscreenMode() {
|
HRESULT DxgiSwapChain::LeaveFullscreenMode() {
|
||||||
Com<IDXGIOutput> output;
|
|
||||||
|
|
||||||
if (!IsWindow(m_window))
|
if (!IsWindow(m_window))
|
||||||
return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
|
return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
|
||||||
|
|
||||||
if (FAILED(GetOutputFromMonitor(m_monitor, &output))
|
if (FAILED(RestoreDisplayMode(m_monitor)))
|
||||||
|| FAILED(RestoreDisplayMode(output.ptr())))
|
|
||||||
Logger::warn("DXGI: LeaveFullscreenMode: Failed to restore display mode");
|
Logger::warn("DXGI: LeaveFullscreenMode: Failed to restore display mode");
|
||||||
|
|
||||||
// Reset gamma control and decouple swap chain from monitor
|
// Reset gamma control and decouple swap chain from monitor
|
||||||
@ -633,19 +627,20 @@ namespace dxvk {
|
|||||||
HRESULT DxgiSwapChain::ChangeDisplayMode(
|
HRESULT DxgiSwapChain::ChangeDisplayMode(
|
||||||
IDXGIOutput* pOutput,
|
IDXGIOutput* pOutput,
|
||||||
const DXGI_MODE_DESC* pDisplayMode) {
|
const DXGI_MODE_DESC* pDisplayMode) {
|
||||||
auto output = static_cast<DxgiOutput*>(pOutput);
|
if (!pOutput)
|
||||||
|
|
||||||
if (output == nullptr)
|
|
||||||
return DXGI_ERROR_INVALID_CALL;
|
return DXGI_ERROR_INVALID_CALL;
|
||||||
|
|
||||||
// Find a mode that the output supports
|
// Find a mode that the output supports
|
||||||
|
DXGI_OUTPUT_DESC outputDesc;
|
||||||
|
pOutput->GetDesc(&outputDesc);
|
||||||
|
|
||||||
DXGI_MODE_DESC preferredMode = *pDisplayMode;
|
DXGI_MODE_DESC preferredMode = *pDisplayMode;
|
||||||
DXGI_MODE_DESC selectedMode;
|
DXGI_MODE_DESC selectedMode;
|
||||||
|
|
||||||
if (preferredMode.Format == DXGI_FORMAT_UNKNOWN)
|
if (preferredMode.Format == DXGI_FORMAT_UNKNOWN)
|
||||||
preferredMode.Format = m_desc.Format;
|
preferredMode.Format = m_desc.Format;
|
||||||
|
|
||||||
HRESULT hr = output->FindClosestMatchingMode(
|
HRESULT hr = pOutput->FindClosestMatchingMode(
|
||||||
&preferredMode, &selectedMode, nullptr);
|
&preferredMode, &selectedMode, nullptr);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
@ -657,26 +652,24 @@ namespace dxvk {
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return output->SetDisplayMode(&selectedMode);
|
return SetMonitorDisplayMode(outputDesc.Monitor, &selectedMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT DxgiSwapChain::RestoreDisplayMode(IDXGIOutput* pOutput) {
|
HRESULT DxgiSwapChain::RestoreDisplayMode(HMONITOR hMonitor) {
|
||||||
auto output = static_cast<DxgiOutput*>(pOutput);
|
if (!hMonitor)
|
||||||
|
|
||||||
if (output == nullptr)
|
|
||||||
return DXGI_ERROR_INVALID_CALL;
|
return DXGI_ERROR_INVALID_CALL;
|
||||||
|
|
||||||
// Restore registry settings
|
// Restore registry settings
|
||||||
DXGI_MODE_DESC mode;
|
DXGI_MODE_DESC mode;
|
||||||
|
|
||||||
HRESULT hr = output->GetDisplayMode(
|
HRESULT hr = GetMonitorDisplayMode(
|
||||||
&mode, ENUM_REGISTRY_SETTINGS);
|
hMonitor, ENUM_REGISTRY_SETTINGS, &mode);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
return output->SetDisplayMode(&mode);
|
return SetMonitorDisplayMode(hMonitor, &mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ namespace dxvk {
|
|||||||
const DXGI_MODE_DESC* pDisplayMode);
|
const DXGI_MODE_DESC* pDisplayMode);
|
||||||
|
|
||||||
HRESULT RestoreDisplayMode(
|
HRESULT RestoreDisplayMode(
|
||||||
IDXGIOutput* pOutput);
|
HMONITOR hMonitor);
|
||||||
|
|
||||||
HRESULT GetSampleCount(
|
HRESULT GetSampleCount(
|
||||||
UINT Count,
|
UINT Count,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user