mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-11 17:20:56 +00:00
Perform descriptor copies immediately. Closes #2009
* When we changed to serialise render target descriptor contents at list record time we also updated all descriptor writes to happen immediately so we'd get the latest contents. However we didn't also update copies, so copies before OMSetRenderTargets weren't properly reflected. * There's nothing that needs the 'old' copy of descriptors so we can remove any pending/deferring of updates and do it immediately, which also saves some tracking.
This commit is contained in:
@@ -2167,8 +2167,6 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
|
||||
|
||||
GetResourceManager()->FreeInitialContents();
|
||||
|
||||
FlushPendingDescriptorWrites();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2220,8 +2218,6 @@ bool WrappedID3D12Device::DiscardFrameCapture(void *dev, void *wnd)
|
||||
|
||||
GetResourceManager()->FreeInitialContents();
|
||||
|
||||
FlushPendingDescriptorWrites();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2456,32 +2452,6 @@ rdcarray<DebugMessage> WrappedID3D12Device::GetDebugMessages()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WrappedID3D12Device::FlushPendingDescriptorWrites()
|
||||
{
|
||||
rdcarray<DynamicDescriptorWrite> writes;
|
||||
rdcarray<DynamicDescriptorCopy> copies;
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
writes.swap(m_DynamicDescriptorWrites);
|
||||
copies.swap(m_DynamicDescriptorCopies);
|
||||
m_DynamicDescriptorRefs.clear();
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < writes.size(); i++)
|
||||
{
|
||||
writes[i].dest->CopyFrom(writes[i].desc);
|
||||
writes[i].dest->GetHeap()->Release();
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < copies.size(); i++)
|
||||
{
|
||||
copies[i].dst->CopyFrom(*copies[i].src);
|
||||
copies[i].src->GetHeap()->Release();
|
||||
copies[i].dst->GetHeap()->Release();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool WrappedID3D12Device::Serialise_SetShaderDebugPath(SerialiserType &ser,
|
||||
ID3D12DeviceChild *pResource, const char *Path)
|
||||
|
||||
@@ -472,14 +472,10 @@ private:
|
||||
D3D12ResourceRecord *m_DeviceRecord;
|
||||
|
||||
Threading::CriticalSection m_DynDescLock;
|
||||
rdcarray<DynamicDescriptorCopy> m_DynamicDescriptorCopies;
|
||||
rdcarray<DynamicDescriptorWrite> m_DynamicDescriptorWrites;
|
||||
rdcarray<D3D12Descriptor> m_DynamicDescriptorRefs;
|
||||
|
||||
GPUAddressRangeTracker m_GPUAddresses;
|
||||
|
||||
void FlushPendingDescriptorWrites();
|
||||
|
||||
// used both on capture and replay side to track resource states. Only locked
|
||||
// in capture
|
||||
std::map<ResourceId, SubresourceStateVector> m_ResourceStates;
|
||||
|
||||
@@ -988,8 +988,6 @@ void WrappedID3D12Device::CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_V
|
||||
write.dest = GetWrapped(DestDescriptor);
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorWrites.push_back(write);
|
||||
write.dest->GetHeap()->AddRef();
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
}
|
||||
|
||||
@@ -1029,12 +1027,10 @@ void WrappedID3D12Device::CreateShaderResourceView(ID3D12Resource *pResource,
|
||||
DynamicDescriptorWrite write;
|
||||
write.desc.Init(pResource, pDesc);
|
||||
write.dest = GetWrapped(DestDescriptor);
|
||||
if(pResource && pResource->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorWrites.push_back(write);
|
||||
write.dest->GetHeap()->AddRef();
|
||||
if(pResource && pResource->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1080,12 +1076,10 @@ void WrappedID3D12Device::CreateUnorderedAccessView(ID3D12Resource *pResource,
|
||||
DynamicDescriptorWrite write;
|
||||
write.desc.Init(pResource, pCounterResource, pDesc);
|
||||
write.dest = GetWrapped(DestDescriptor);
|
||||
if(pResource && pResource->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorWrites.push_back(write);
|
||||
write.dest->GetHeap()->AddRef();
|
||||
if(pResource && pResource->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1126,12 +1120,10 @@ void WrappedID3D12Device::CreateRenderTargetView(ID3D12Resource *pResource,
|
||||
DynamicDescriptorWrite write;
|
||||
write.desc.Init(pResource, pDesc);
|
||||
write.dest = GetWrapped(DestDescriptor);
|
||||
if(pResource && pResource->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorWrites.push_back(write);
|
||||
write.dest->GetHeap()->AddRef();
|
||||
if(pResource && pResource->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
m_DynamicDescriptorRefs.push_back(write.desc);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1169,11 +1161,6 @@ void WrappedID3D12Device::CreateDepthStencilView(ID3D12Resource *pResource,
|
||||
DynamicDescriptorWrite write;
|
||||
write.desc.Init(pResource, pDesc);
|
||||
write.dest = GetWrapped(DestDescriptor);
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorWrites.push_back(write);
|
||||
write.dest->GetHeap()->AddRef();
|
||||
}
|
||||
|
||||
{
|
||||
CACHE_THREAD_SERIALISER();
|
||||
@@ -1208,11 +1195,6 @@ void WrappedID3D12Device::CreateSampler(const D3D12_SAMPLER_DESC *pDesc,
|
||||
DynamicDescriptorWrite write;
|
||||
write.desc.Init(pDesc);
|
||||
write.dest = GetWrapped(DestDescriptor);
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorWrites.push_back(write);
|
||||
write.dest->GetHeap()->AddRef();
|
||||
}
|
||||
|
||||
{
|
||||
CACHE_THREAD_SERIALISER();
|
||||
@@ -2107,8 +2089,8 @@ void WrappedID3D12Device::CopyDescriptors(
|
||||
// assume descriptors are volatile
|
||||
if(capframe)
|
||||
copies.push_back(DynamicDescriptorCopy(&dst[dstIdx], &src[srcIdx], DescriptorHeapsType));
|
||||
else
|
||||
dst[dstIdx].CopyFrom(src[srcIdx]);
|
||||
|
||||
dst[dstIdx].CopyFrom(src[srcIdx]);
|
||||
}
|
||||
|
||||
srcIdx++;
|
||||
@@ -2168,13 +2150,8 @@ void WrappedID3D12Device::CopyDescriptors(
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorCopies.append(copies);
|
||||
for(size_t i = 0; i < copies.size(); i++)
|
||||
{
|
||||
copies[i].src->GetHeap()->AddRef();
|
||||
copies[i].dst->GetHeap()->AddRef();
|
||||
m_DynamicDescriptorRefs.push_back(*copies[i].src);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2242,13 +2219,8 @@ void WrappedID3D12Device::CopyDescriptorsSimple(UINT NumDescriptors,
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_DynDescLock);
|
||||
m_DynamicDescriptorCopies.append(copies);
|
||||
for(size_t i = 0; i < copies.size(); i++)
|
||||
{
|
||||
copies[i].src->GetHeap()->AddRef();
|
||||
copies[i].dst->GetHeap()->AddRef();
|
||||
m_DynamicDescriptorRefs.push_back(*copies[i].src);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2260,11 +2232,9 @@ void WrappedID3D12Device::CopyDescriptorsSimple(UINT NumDescriptors,
|
||||
m_FrameCaptureRecord->AddChunk(scope.Get());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(UINT i = 0; i < NumDescriptors; i++)
|
||||
dst[i].CopyFrom(src[i]);
|
||||
}
|
||||
|
||||
for(UINT i = 0; i < NumDescriptors; i++)
|
||||
dst[i].CopyFrom(src[i]);
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
|
||||
Reference in New Issue
Block a user