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 committed Sep 6, 2024
1 parent daccde7 commit b80d69b
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 @@ -670,6 +670,12 @@ namespace dxvk {
}
}

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

DXGI_MODE_DESC1 displayMode = { };
displayMode.Width = m_desc.Width;
displayMode.Height = m_desc.Height;
Expand Down Expand Up @@ -731,7 +737,13 @@ namespace dxvk {
SetGammaControl(0, nullptr);
ReleaseMonitorData();
}


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

// 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 b80d69b

Please sign in to comment.