If any list executed contains an ExecuteIndirect, ref all buffers

* Since buffers can be referenced indirectly on the GPU by their GPU
  address, there's no feasible way to know if the buffer is actually
  used or not. If an ExecuteIndirect is seen at all we just have to
  pessimistically include all buffers.
* Generally textures take up the bulk of VRAM usage, so this likely
  won't be too bad.
This commit is contained in:
baldurk
2016-10-21 21:44:24 +02:00
parent febe2b1ad9
commit ac53611f07
6 changed files with 26 additions and 2 deletions
@@ -263,6 +263,7 @@ HRESULT WrappedID3D12GraphicsCommandList::Reset(ID3D12CommandAllocator *pAllocat
// reset for new recording
m_ListRecord->DeleteChunks();
m_ListRecord->ContainsExecuteIndirect = false;
// free parents
m_ListRecord->FreeParents(GetResourceManager());
@@ -2843,6 +2844,8 @@ void WrappedID3D12GraphicsCommandList::ExecuteIndirect(ID3D12CommandSignature *p
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->ContainsExecuteIndirect = true;
m_ListRecord->MarkResourceFrameReferenced(GetResID(pCommandSignature), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pArgumentBuffer), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pCountBuffer), eFrameRef_Read);
@@ -340,6 +340,9 @@ void STDMETHODCALLTYPE WrappedID3D12CommandQueue::ExecuteCommandLists(
{
D3D12ResourceRecord *record = GetRecord(ppCommandLists[i]);
if(record->ContainsExecuteIndirect)
m_QueueRecord->ContainsExecuteIndirect = true;
m_pDevice->ApplyBarriers(record->bakedCommands->cmdInfo->barriers);
// need to lock the whole section of code, not just the check on
+5
View File
@@ -1386,6 +1386,11 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
Serialiser *m_pFileSerialiser = RenderDoc::Inst().OpenWriteSerialiser(
m_FrameCounter, &m_InitParams, jpgbuf, len, thwidth, thheight);
if(m_Queue->GetResourceRecord()->ContainsExecuteIndirect)
{
WrappedID3D12Resource::RefBuffers(GetResourceManager());
}
{
CACHE_THREAD_SERIALISER();
+6 -1
View File
@@ -351,7 +351,11 @@ struct D3D12ResourceRecord : public ResourceRecord
};
D3D12ResourceRecord(ResourceId id)
: ResourceRecord(id, true), type(Resource_Unknown), cmdInfo(NULL), bakedCommands(NULL)
: ResourceRecord(id, true),
type(Resource_Unknown),
ContainsExecuteIndirect(false),
cmdInfo(NULL),
bakedCommands(NULL)
{
}
~D3D12ResourceRecord() {}
@@ -384,6 +388,7 @@ struct D3D12ResourceRecord : public ResourceRecord
}
D3D12ResourceType type;
bool ContainsExecuteIndirect;
D3D12ResourceRecord *bakedCommands;
CmdListRecordingInfo *cmdInfo;
+7 -1
View File
@@ -29,7 +29,6 @@
std::vector<GPUAddressRange> WrappedID3D12Resource::m_Addresses;
std::map<ResourceId, WrappedID3D12Resource *> WrappedID3D12Resource::m_List;
std::map<WrappedID3D12PipelineState::DXBCKey, WrappedID3D12PipelineState::ShaderEntry *>
WrappedID3D12PipelineState::m_Shaders;
@@ -373,6 +372,13 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12Resource::WriteToSubresource(UINT DstSubr
return m_pReal->WriteToSubresource(DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch);
}
void WrappedID3D12Resource::RefBuffers(D3D12ResourceManager *rm)
{
// only buffers go into m_Addresses
for(size_t i = 0; i < m_Addresses.size(); i++)
rm->MarkResourceFrameReferenced(m_Addresses[i].id, eFrameRef_Read);
}
WrappedID3D12DescriptorHeap::WrappedID3D12DescriptorHeap(ID3D12DescriptorHeap *real,
WrappedID3D12Device *device,
const D3D12_DESCRIPTOR_HEAP_DESC &desc)
+2
View File
@@ -645,6 +645,8 @@ public:
static std::map<ResourceId, WrappedID3D12Resource *> m_List;
static void RefBuffers(D3D12ResourceManager *rm);
static void GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr, ResourceId &id, UINT64 &offs)
{
GPUAddressRange::GetResIDFromAddr(m_Addresses, addr, id, offs);