From ecafa4f1297d2497ef80d950cec4725e87b5cffe Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 25 Nov 2020 14:06:35 +0000 Subject: [PATCH] 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. --- renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp index b34958ddf..3dffb54f0 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp @@ -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 refdIDs; @@ -556,6 +556,8 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists } } + m_Lock.Unlock(); + if(!InFrameCaptureBoundary) m_pDevice->GetCapTransitionLock().ReadUnlock(); }