Only add wrapped resources to list on replay (which is single threaded)

This commit is contained in:
baldurk
2016-10-27 11:35:03 +02:00
parent 0832bff675
commit 88939d1f21
5 changed files with 25 additions and 13 deletions
+3 -3
View File
@@ -1825,9 +1825,9 @@ void D3D12DebugManager::BuildShader(string source, string entry, const uint32_t
void D3D12DebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_t length,
vector<byte> &retData)
{
auto it = WrappedID3D12Resource::m_List.find(buff);
auto it = WrappedID3D12Resource::GetList().find(buff);
if(it == WrappedID3D12Resource::m_List.end())
if(it == WrappedID3D12Resource::GetList().end())
{
RDCERR("Getting buffer data for unknown buffer %llu!", buff);
return;
@@ -2241,7 +2241,7 @@ bool D3D12DebugManager::RenderTextureInternal(D3D12_CPU_DESCRIPTOR_HANDLE rtv, T
pixelData.FlipY = cfg.FlipY ? 1 : 0;
ID3D12Resource *resource = WrappedID3D12Resource::m_List[cfg.texid];
ID3D12Resource *resource = WrappedID3D12Resource::GetList()[cfg.texid];
D3D12_RESOURCE_DESC resourceDesc = resource->GetDesc();
pixelData.SampleIdx = (int)RDCCLAMP(cfg.sampleIdx, 0U, resourceDesc.SampleDesc.Count - 1);
+6
View File
@@ -176,6 +176,8 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
m_DescriptorIncrements[i] =
realDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE(i));
WrappedID3D12Resource::m_List = NULL;
// refcounters implicitly construct with one reference, but we don't start with any soft
// references.
m_SoftRefCounter.Release();
@@ -208,6 +210,8 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
m_State = READING;
m_pSerialiser = NULL;
WrappedID3D12Resource::m_List = new std::map<ResourceId, WrappedID3D12Resource *>();
m_FrameCaptureRecord = NULL;
ResourceIDGen::SetReplayResourceIDs();
@@ -325,6 +329,8 @@ WrappedID3D12Device::~WrappedID3D12Device()
{
RenderDoc::Inst().RemoveDeviceFrameCapturer((ID3D12Device *)this);
SAFE_DELETE(WrappedID3D12Resource::m_List);
for(size_t i = 0; i < m_QueueFences.size(); i++)
{
GPUSync(m_Queues[i], m_QueueFences[i]);
+8 -6
View File
@@ -78,7 +78,8 @@ vector<ResourceId> D3D12Replay::GetBuffers()
{
vector<ResourceId> ret;
for(auto it = WrappedID3D12Resource::m_List.begin(); it != WrappedID3D12Resource::m_List.end(); it++)
for(auto it = WrappedID3D12Resource::GetList().begin();
it != WrappedID3D12Resource::GetList().end(); it++)
if(it->second->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
ret.push_back(it->first);
@@ -89,7 +90,8 @@ vector<ResourceId> D3D12Replay::GetTextures()
{
vector<ResourceId> ret;
for(auto it = WrappedID3D12Resource::m_List.begin(); it != WrappedID3D12Resource::m_List.end(); it++)
for(auto it = WrappedID3D12Resource::GetList().begin();
it != WrappedID3D12Resource::GetList().end(); it++)
{
if(it->second->GetDesc().Dimension != D3D12_RESOURCE_DIMENSION_BUFFER &&
m_pDevice->GetResourceManager()->GetOriginalID(it->first) != it->first)
@@ -104,9 +106,9 @@ FetchBuffer D3D12Replay::GetBuffer(ResourceId id)
FetchBuffer ret;
ret.ID = m_pDevice->GetResourceManager()->GetOriginalID(id);
auto it = WrappedID3D12Resource::m_List.find(id);
auto it = WrappedID3D12Resource::GetList().find(id);
if(it == WrappedID3D12Resource::m_List.end())
if(it == WrappedID3D12Resource::GetList().end())
return ret;
D3D12_RESOURCE_DESC desc = it->second->GetDesc();
@@ -153,9 +155,9 @@ FetchTexture D3D12Replay::GetTexture(ResourceId id)
FetchTexture ret;
ret.ID = m_pDevice->GetResourceManager()->GetOriginalID(id);
auto it = WrappedID3D12Resource::m_List.find(id);
auto it = WrappedID3D12Resource::GetList().find(id);
if(it == WrappedID3D12Resource::m_List.end())
if(it == WrappedID3D12Resource::GetList().end())
return ret;
D3D12_RESOURCE_DESC desc = it->second->GetDesc();
+1 -1
View File
@@ -28,7 +28,7 @@
#include "d3d12_command_queue.h"
GPUAddressRangeTracker WrappedID3D12Resource::m_Addresses;
std::map<ResourceId, WrappedID3D12Resource *> WrappedID3D12Resource::m_List;
std::map<ResourceId, WrappedID3D12Resource *> *WrappedID3D12Resource::m_List = NULL;
std::map<WrappedID3D12PipelineState::DXBCKey, WrappedID3D12PipelineState::ShaderEntry *>
WrappedID3D12PipelineState::m_Shaders;
+7 -3
View File
@@ -660,8 +660,9 @@ class WrappedID3D12Resource : public WrappedDeviceChild12<ID3D12Resource>
public:
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12Resource);
static std::map<ResourceId, WrappedID3D12Resource *> m_List;
static std::map<ResourceId, WrappedID3D12Resource *> *m_List;
static std::map<ResourceId, WrappedID3D12Resource *> &GetList() { return *m_List; }
static void RefBuffers(D3D12ResourceManager *rm);
static void GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr, ResourceId &id, UINT64 &offs)
@@ -688,7 +689,9 @@ public:
WrappedID3D12Resource(ID3D12Resource *real, WrappedID3D12Device *device)
: WrappedDeviceChild12(real, device)
{
m_List[GetResourceID()] = this;
if(m_List)
(*m_List)[GetResourceID()] = this;
SetResident(true);
// assuming only valid for buffers
@@ -706,7 +709,8 @@ public:
}
virtual ~WrappedID3D12Resource()
{
m_List.erase(GetResourceID());
if(m_List)
(*m_List).erase(GetResourceID());
// assuming only valid for buffers
if(m_pReal->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)