Skip to content

Commit

Permalink
[dxgi] Prevent recursive fullscreen mode change.
Browse files Browse the repository at this point in the history
  • Loading branch information
gofman authored and doitsujin committed Sep 17, 2024
1 parent 5cf0783 commit 758dc80
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/dxgi/dxgi_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,12 @@ namespace dxvk {


HRESULT DxgiSwapChain::EnterFullscreenMode(IDXGIOutput1* pTarget) {
if (m_ModeChangeInProgress) {
Logger::warn("Nested EnterFullscreenMode");
return DXGI_STATUS_MODE_CHANGE_IN_PROGRESS;
}
scoped_bool in_progress(m_ModeChangeInProgress);

Com<IDXGIOutput1> output = pTarget;

if (!wsi::isWindow(m_window))
Expand Down Expand Up @@ -718,6 +724,12 @@ namespace dxvk {


HRESULT DxgiSwapChain::LeaveFullscreenMode() {
if (m_ModeChangeInProgress) {
Logger::warn("Nested LeaveFullscreenMode");
return DXGI_STATUS_MODE_CHANGE_IN_PROGRESS;
}
scoped_bool in_progress(m_ModeChangeInProgress);

if (FAILED(RestoreDisplayMode(m_monitor)))
Logger::warn("DXGI: LeaveFullscreenMode: Failed to restore display mode");

Expand All @@ -731,7 +743,7 @@ namespace dxvk {
SetGammaControl(0, nullptr);
ReleaseMonitorData();
}

// Restore internal state
m_descFs.Windowed = TRUE;
m_target = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/dxgi/dxgi_swapchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ namespace dxvk {
DXGI_SWAP_CHAIN_DESC1 m_desc;
DXGI_SWAP_CHAIN_FULLSCREEN_DESC m_descFs;
UINT m_presentId;
bool m_ModeChangeInProgress = false;

Com<IDXGIVkSwapChain> m_presenter;
Com<IDXGIVkSwapChain1> m_presenter1;
Expand Down
12 changes: 11 additions & 1 deletion src/util/util_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ namespace dxvk {
return duration.count() / refreshPeriod.count();
}

}
struct scoped_bool {
scoped_bool(bool &v) : m_val(v) {
m_val = true;
}
~scoped_bool() {
m_val = false;
}

bool& m_val;
};
}

0 comments on commit 758dc80

Please sign in to comment.