Skip to content

Commit

Permalink
[dxgi] Do not interact with other DXGI objects during swapchain destr…
Browse files Browse the repository at this point in the history
…uction

This trips up Stalker Anomaly for some reason, but initializing an output
is not meaningful anyway in this situation since we either know the output
in question already, or we don't and it cannot be in a non-default state.

Closes #3531.
  • Loading branch information
doitsujin committed Jun 24, 2023
1 parent 3b3ebc9 commit a7278cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dxgi/dxgi_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ namespace dxvk {

HRESULT hr = m_monitorInfo->AcquireMonitorData(hMonitor, ppData);

if (FAILED(hr)) {
if (FAILED(hr) && HasLiveReferences()) {
// We may need to initialize a DXGI output to populate monitor data.
// If acquiring monitor data has failed previously, do not try again.
if (hMonitor == m_monitor && !m_monitorHasOutput)
Expand Down
8 changes: 6 additions & 2 deletions src/util/com/com_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ namespace dxvk {
}
}

ULONG GetPrivateRefCount() {
ULONG GetPrivateRefCount() const {
return m_refPrivate.load();
}


bool HasLiveReferences() const {
return bool(m_refCount.load() | m_refPrivate.load());
}

protected:

std::atomic<uint32_t> m_refCount = { 0ul };
Expand Down

0 comments on commit a7278cd

Please sign in to comment.