Enclose resource list usage in critical sections. Refs #157

This commit is contained in:
baldurk
2015-09-30 21:52:55 +02:00
parent 271475410b
commit d4ffbe417b
4 changed files with 20 additions and 2 deletions
+2
View File
@@ -477,6 +477,8 @@ void WrappedID3D11DeviceContext::EndCaptureFrame()
void WrappedID3D11DeviceContext::FreeCaptureData()
{
SCOPED_LOCK(m_pDevice->D3DLock());
for(auto it = WrappedID3D11Buffer::m_BufferList.begin(); it != WrappedID3D11Buffer::m_BufferList.end(); ++it)
{
D3D11ResourceRecord *record = m_pDevice->GetResourceManager()->GetResourceRecord(it->first);
+2
View File
@@ -289,6 +289,8 @@ public:
D3D11Replay *GetReplay() { return &m_Replay; }
Threading::CriticalSection &D3DLock() { return m_D3DLock; }
WrappedID3D11DeviceContext *GetImmediateContext() { return m_pImmediateContext; }
size_t GetNumDeferredContexts() { return m_DeferredContexts.size(); }
void AddDeferredContext(WrappedID3D11DeviceContext *defctx);
@@ -61,6 +61,7 @@ map<ResourceId,WrappedID3D11Texture2D::TextureEntry> WrappedTexture<ID3D11Textur
map<ResourceId,WrappedID3D11Texture3D::TextureEntry> WrappedTexture<ID3D11Texture3D, D3D11_TEXTURE3D_DESC>::m_TextureList;
map<ResourceId,WrappedID3D11Buffer::BufferEntry> WrappedID3D11Buffer::m_BufferList;
map<ResourceId,WrappedShader::ShaderEntry*> WrappedShader::m_ShaderList;
Threading::CriticalSection WrappedShader::m_ShaderListLock;
UINT GetMipForSubresource(ID3D11Resource *res, int Subresource)
{
+15 -2
View File
@@ -769,12 +769,16 @@ public:
WrappedID3D11Buffer(ID3D11Buffer* real, uint32_t byteLength, WrappedID3D11Device* device)
: WrappedResource(real, device)
{
SCOPED_LOCK(m_pDevice->D3DLock());
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());
@@ -805,6 +809,8 @@ public:
{
if(type != TEXDISPLAY_UNKNOWN)
{
SCOPED_LOCK(m_pDevice->D3DLock());
RDCASSERT(m_TextureList.find(GetResourceID()) == m_TextureList.end());
m_TextureList[GetResourceID()] = TextureEntry(this, type);
}
@@ -812,6 +818,8 @@ public:
virtual ~WrappedTexture()
{
SCOPED_LOCK(m_pDevice->D3DLock());
if(m_TextureList.find(GetResourceID()) != m_TextureList.end())
m_TextureList.erase(GetResourceID());
@@ -1115,14 +1123,19 @@ public:
};
static map<ResourceId, ShaderEntry*> m_ShaderList;
static Threading::CriticalSection m_ShaderListLock;
WrappedShader(ResourceId id, const byte *code, size_t codeLen) : m_ID(id)
{
SCOPED_LOCK(m_ShaderListLock);
RDCASSERT(m_ShaderList.find(m_ID) == m_ShaderList.end());
m_ShaderList[m_ID] = new ShaderEntry(code, codeLen);
}
virtual ~WrappedShader()
{
SCOPED_LOCK(m_ShaderListLock);
auto it = m_ShaderList.find(m_ID);
if(it != m_ShaderList.end())
{
@@ -1131,8 +1144,8 @@ public:
}
}
DXBC::DXBCFile *GetDXBC() { return m_ShaderList[m_ID]->GetDXBC(); }
ShaderReflection *GetDetails() { return m_ShaderList[m_ID]->GetDetails(); }
DXBC::DXBCFile *GetDXBC() { SCOPED_LOCK(m_ShaderListLock); return m_ShaderList[m_ID]->GetDXBC(); }
ShaderReflection *GetDetails() { SCOPED_LOCK(m_ShaderListLock); return m_ShaderList[m_ID]->GetDetails(); }
private:
ResourceId m_ID;
};