From 68bbc356a48feca2e1ace4c5edcc27ee6af4cffb Mon Sep 17 00:00:00 2001 From: Nicholas Howe Date: Mon, 8 Jul 2019 12:18:24 -0400 Subject: [PATCH] Only modify static resource maps in the replay app. This prevents static data like WrappedTexture<>::m_TextureList from being accessed from different device instances on different threads. Each device instance has its own mutex, and so is unable to protect the static data from access through other instances. The static data is only used in the replay app, which is single threaded, so accessing the static maps is not a problem there. --- renderdoc/driver/d3d11/d3d11_resources.h | 32 ++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_resources.h b/renderdoc/driver/d3d11/d3d11_resources.h index c1061d480..4117c729a 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.h +++ b/renderdoc/driver/d3d11/d3d11_resources.h @@ -448,18 +448,24 @@ public: WrappedID3D11Buffer(ID3D11Buffer *real, uint32_t byteLength, WrappedID3D11Device *device) : WrappedResource11(real, device) { - SCOPED_LOCK(m_pDevice->D3DLock()); + if(RenderDoc::Inst().IsReplayApp()) + { + SCOPED_LOCK(m_pDevice->D3DLock()); - RDCASSERT(m_BufferList.find(GetResourceID()) == m_BufferList.end()); - m_BufferList[GetResourceID()] = BufferEntry(this, byteLength); + RDCASSERT(m_BufferList.find(GetResourceID()) == m_BufferList.end()); + m_BufferList[GetResourceID()] = BufferEntry(this, byteLength); + } } virtual ~WrappedID3D11Buffer() { SCOPED_LOCK(m_pDevice->D3DLock()); - if(m_BufferList.find(GetResourceID()) != m_BufferList.end()) - m_BufferList.erase(GetResourceID()); + if(RenderDoc::Inst().IsReplayApp()) + { + if(m_BufferList.find(GetResourceID()) != m_BufferList.end()) + m_BufferList.erase(GetResourceID()); + } Shutdown(); } @@ -492,10 +498,13 @@ public: { if(type != TEXDISPLAY_UNKNOWN) { - SCOPED_LOCK(m_pDevice->D3DLock()); + if(RenderDoc::Inst().IsReplayApp()) + { + SCOPED_LOCK(m_pDevice->D3DLock()); - RDCASSERT(m_TextureList.find(GetResourceID()) == m_TextureList.end()); - m_TextureList[GetResourceID()] = TextureEntry(this, type); + RDCASSERT(m_TextureList.find(GetResourceID()) == m_TextureList.end()); + m_TextureList[GetResourceID()] = TextureEntry(this, type); + } } } @@ -503,8 +512,11 @@ public: { SCOPED_LOCK(m_pDevice->D3DLock()); - if(m_TextureList.find(GetResourceID()) != m_TextureList.end()) - m_TextureList.erase(GetResourceID()); + if(RenderDoc::Inst().IsReplayApp()) + { + if(m_TextureList.find(GetResourceID()) != m_TextureList.end()) + m_TextureList.erase(GetResourceID()); + } Shutdown(); }