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.
This commit is contained in:
Nicholas Howe
2019-07-08 12:18:24 -04:00
committed by Baldur Karlsson
parent bb3b94b092
commit 68bbc356a4
+22 -10
View File
@@ -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();
}