Tweak lock order to avoid a deadlock during capture

* During capture we hold the transition lock for writing, so we need to try to
  lock that first (if we're going to) before locking the queue's lock. Otherwise
  another thread could come in and get the queue's lock while we're holding the
  transition lock, then we deadlock against each other.
This commit is contained in:
baldurk
2020-11-25 14:06:35 +00:00
parent 883e023259
commit ecafa4f129
@@ -357,11 +357,11 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
if(IsCaptureMode(m_State))
{
SCOPED_LOCK(m_Lock);
if(!InFrameCaptureBoundary)
m_pDevice->GetCapTransitionLock().ReadLock();
m_Lock.Lock();
bool capframe = IsActiveCapturing(m_State);
std::set<ResourceId> refdIDs;
@@ -556,6 +556,8 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
}
}
m_Lock.Unlock();
if(!InFrameCaptureBoundary)
m_pDevice->GetCapTransitionLock().ReadUnlock();
}