mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-26 01:11:49 +00:00
Don't store cap-referenced desc sets as objects directly
* When we see a descriptor copy during a frame capture we force the source descriptor set to be included since it may never be bound to a command buffer, but it may also be deleted so instead we AddRef the record to keep it alive and store the id & record directly.
This commit is contained in:
@@ -1827,6 +1827,8 @@ void WrappedVulkan::StartFrameCapture(void *dev, void *wnd)
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_CapDescriptorsLock);
|
||||
for(const rdcpair<ResourceId, VkResourceRecord *> &it : m_CapDescriptors)
|
||||
it.second->Delete(GetResourceManager());
|
||||
m_CapDescriptors.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ private:
|
||||
std::set<rdcstr> m_StringDB;
|
||||
|
||||
Threading::CriticalSection m_CapDescriptorsLock;
|
||||
std::set<VkDescriptorSet> m_CapDescriptors;
|
||||
std::set<rdcpair<ResourceId, VkResourceRecord *>> m_CapDescriptors;
|
||||
|
||||
VkResourceRecord *m_FrameCaptureRecord;
|
||||
Chunk *m_HeaderChunk;
|
||||
|
||||
@@ -1071,7 +1071,7 @@ struct CmdBufferRecordingInfo
|
||||
// a list of descriptor sets that are bound at any point in this command buffer
|
||||
// used to look up all the frame refs per-desc set and apply them on queue
|
||||
// submit with latest binding refs.
|
||||
std::set<VkDescriptorSet> boundDescSets;
|
||||
std::set<rdcpair<ResourceId, VkResourceRecord *>> boundDescSets;
|
||||
|
||||
// barriers to apply when the current render pass ends. Calculated at begin time in case the
|
||||
// framebuffer is imageless and we need to use the image views passed in at begin time to
|
||||
|
||||
@@ -3230,7 +3230,9 @@ void WrappedVulkan::vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
||||
|
||||
record->AddChunk(scope.Get(&record->cmdInfo->alloc));
|
||||
record->MarkResourceFrameReferenced(GetResID(layout), eFrameRef_Read);
|
||||
record->cmdInfo->boundDescSets.insert(pDescriptorSets, pDescriptorSets + setCount);
|
||||
for(uint32_t i = 0; i < setCount; i++)
|
||||
record->cmdInfo->boundDescSets.insert(
|
||||
{GetResID(pDescriptorSets[i]), GetRecord(pDescriptorSets[i])});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1222,9 +1222,13 @@ void WrappedVulkan::vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount,
|
||||
GetResourceManager()->MarkResourceFrameReferenced(GetResID(pDescriptorCopies[i].srcSet),
|
||||
eFrameRef_Read);
|
||||
|
||||
ResourceId id = GetResID(pDescriptorCopies[i].srcSet);
|
||||
VkResourceRecord *record = GetRecord(pDescriptorCopies[i].srcSet);
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_CapDescriptorsLock);
|
||||
m_CapDescriptors.insert(pDescriptorCopies[i].srcSet);
|
||||
record->AddRef();
|
||||
m_CapDescriptors.insert({id, record});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,15 +827,18 @@ void WrappedVulkan::CaptureQueueSubmit(VkQueue queue,
|
||||
|
||||
std::unordered_set<ResourceId> refdIDs;
|
||||
|
||||
std::set<VkDescriptorSet> descriptorSets;
|
||||
std::set<rdcpair<ResourceId, VkResourceRecord *>> capDescriptors;
|
||||
std::set<rdcpair<ResourceId, VkResourceRecord *>> descriptorSets;
|
||||
|
||||
// pull in any copy sources, conservatively
|
||||
if(capframe)
|
||||
{
|
||||
SCOPED_LOCK(m_CapDescriptorsLock);
|
||||
descriptorSets.swap(m_CapDescriptors);
|
||||
capDescriptors.swap(m_CapDescriptors);
|
||||
}
|
||||
|
||||
descriptorSets = capDescriptors;
|
||||
|
||||
for(size_t i = 0; i < commandBuffers.size(); i++)
|
||||
{
|
||||
ResourceId cmd = GetResID(commandBuffers[i]);
|
||||
@@ -941,9 +944,9 @@ void WrappedVulkan::CaptureQueueSubmit(VkQueue queue,
|
||||
// for each descriptor set, mark it referenced as well as all resources currently bound to it
|
||||
for(auto it = descriptorSets.begin(); it != descriptorSets.end(); ++it)
|
||||
{
|
||||
rm->MarkResourceFrameReferenced(GetResID(*it), eFrameRef_Read);
|
||||
rm->MarkResourceFrameReferenced(it->first, eFrameRef_Read);
|
||||
|
||||
VkResourceRecord *setrecord = GetRecord(*it);
|
||||
VkResourceRecord *setrecord = it->second;
|
||||
|
||||
DescriptorBindRefs refs;
|
||||
|
||||
@@ -1159,6 +1162,10 @@ void WrappedVulkan::CaptureQueueSubmit(VkQueue queue,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(const rdcpair<ResourceId, VkResourceRecord *> &it : capDescriptors)
|
||||
it.second->Delete(GetResourceManager());
|
||||
capDescriptors.clear();
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
|
||||
Reference in New Issue
Block a user