mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
Make sure to frame-reference the contents of descriptor copy sources
This commit is contained in:
@@ -451,25 +451,7 @@ void STDMETHODCALLTYPE WrappedID3D12CommandQueue::ExecuteCommandLists(
|
||||
ResourceId id, id2;
|
||||
FrameRefType ref = eFrameRef_Read;
|
||||
|
||||
switch(desc.GetType())
|
||||
{
|
||||
case D3D12Descriptor::TypeUndefined:
|
||||
case D3D12Descriptor::TypeSampler:
|
||||
// nothing to do - no resource here
|
||||
break;
|
||||
case D3D12Descriptor::TypeCBV:
|
||||
id = WrappedID3D12Resource::GetResIDFromAddr(desc.nonsamp.cbv.BufferLocation);
|
||||
break;
|
||||
case D3D12Descriptor::TypeSRV: id = GetResID(desc.nonsamp.resource); break;
|
||||
case D3D12Descriptor::TypeUAV:
|
||||
id2 = GetResID(desc.nonsamp.uav.counterResource);
|
||||
// deliberate fall-through
|
||||
case D3D12Descriptor::TypeRTV:
|
||||
case D3D12Descriptor::TypeDSV:
|
||||
ref = eFrameRef_Write;
|
||||
id = GetResID(desc.nonsamp.resource);
|
||||
break;
|
||||
}
|
||||
desc.GetRefIDs(id, id2, ref);
|
||||
|
||||
if(id != ResourceId())
|
||||
{
|
||||
|
||||
@@ -1579,6 +1579,22 @@ void WrappedID3D12Device::CopyDescriptors(
|
||||
{
|
||||
D3D12Descriptor *desc = GetWrapped(pSrcDescriptorRangeStarts[i]);
|
||||
GetResourceManager()->MarkResourceFrameReferenced(GetResID(desc->samp.heap), eFrameRef_Read);
|
||||
|
||||
// make sure we reference the resources in the source descriptors too
|
||||
const UINT srcSize = pSrcDescriptorRangeSizes ? pSrcDescriptorRangeSizes[i] : 1;
|
||||
for(UINT d = 0; d < srcSize; d++)
|
||||
{
|
||||
ResourceId id, id2;
|
||||
FrameRefType ref = eFrameRef_Read;
|
||||
|
||||
desc[d].GetRefIDs(id, id2, ref);
|
||||
|
||||
if(id != ResourceId())
|
||||
GetResourceManager()->MarkResourceFrameReferenced(id, ref);
|
||||
|
||||
if(id2 != ResourceId())
|
||||
GetResourceManager()->MarkResourceFrameReferenced(id2, ref);
|
||||
}
|
||||
}
|
||||
|
||||
for(UINT i = 0; i < NumDestDescriptorRanges; i++)
|
||||
@@ -1627,6 +1643,21 @@ void WrappedID3D12Device::CopyDescriptorsSimple(UINT NumDescriptors,
|
||||
{
|
||||
D3D12Descriptor *desc = GetWrapped(SrcDescriptorRangeStart);
|
||||
GetResourceManager()->MarkResourceFrameReferenced(GetResID(desc->samp.heap), eFrameRef_Read);
|
||||
|
||||
// make sure we reference the resources in the source descriptors too
|
||||
for(UINT d = 0; d < NumDescriptors; d++)
|
||||
{
|
||||
ResourceId id, id2;
|
||||
FrameRefType ref = eFrameRef_Read;
|
||||
|
||||
desc[d].GetRefIDs(id, id2, ref);
|
||||
|
||||
if(id != ResourceId())
|
||||
GetResourceManager()->MarkResourceFrameReferenced(id, ref);
|
||||
|
||||
if(id2 != ResourceId())
|
||||
GetResourceManager()->MarkResourceFrameReferenced(id2, ref);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -256,6 +256,33 @@ void D3D12Descriptor::CopyFrom(const D3D12Descriptor &src)
|
||||
samp.idx = index;
|
||||
}
|
||||
|
||||
void D3D12Descriptor::GetRefIDs(ResourceId &id, ResourceId &id2, FrameRefType &ref)
|
||||
{
|
||||
id = ResourceId();
|
||||
id2 = ResourceId();
|
||||
ref = eFrameRef_Read;
|
||||
|
||||
switch(GetType())
|
||||
{
|
||||
case D3D12Descriptor::TypeUndefined:
|
||||
case D3D12Descriptor::TypeSampler:
|
||||
// nothing to do - no resource here
|
||||
break;
|
||||
case D3D12Descriptor::TypeCBV:
|
||||
id = WrappedID3D12Resource::GetResIDFromAddr(nonsamp.cbv.BufferLocation);
|
||||
break;
|
||||
case D3D12Descriptor::TypeSRV: id = GetResID(nonsamp.resource); break;
|
||||
case D3D12Descriptor::TypeUAV:
|
||||
id2 = GetResID(nonsamp.uav.counterResource);
|
||||
// deliberate fall-through
|
||||
case D3D12Descriptor::TypeRTV:
|
||||
case D3D12Descriptor::TypeDSV:
|
||||
ref = eFrameRef_Write;
|
||||
id = GetResID(nonsamp.resource);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE UnwrapCPU(D3D12Descriptor *handle)
|
||||
{
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE ret = {};
|
||||
|
||||
@@ -166,6 +166,7 @@ struct D3D12Descriptor
|
||||
void Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12Device *dev,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE handle);
|
||||
void CopyFrom(const D3D12Descriptor &src);
|
||||
void GetRefIDs(ResourceId &id, ResourceId &id2, FrameRefType &ref);
|
||||
|
||||
union
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user