Stop forcing references for resourced invalidated by freed bound memory

This commit is contained in:
baldurk
2022-08-07 18:56:11 +01:00
parent 0a39b3d6e8
commit a8f0fb1736
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -349,7 +349,7 @@ struct ResourceRecord
Parents.push_back(r);
}
}
bool HasParent(ResourceRecord *r) const { return Parents.indexOf(r) >= 0; }
void MarkParentsDirty(ResourceRecordHandler *mgr)
{
for(auto it = Parents.begin(); it != Parents.end(); ++it)
@@ -747,6 +747,18 @@ void WrappedVulkan::vkFreeMemory(VkDevice device, VkDeviceMemory memory,
if(IsCaptureMode(m_State))
{
VkResourceRecord *memrecord = GetRecord(memory);
// any forced references were already processed at the start of the frame if we're mid capture.
// If we're background capturing though, we need to make sure not to force in buffers
// referencing this now-dead memory, as a new memory allocation could be created and use the
// same BDA address
{
SCOPED_LOCK(m_ForcedReferencesLock);
m_ForcedReferences.removeIf(
[memrecord](const VkResourceRecord *record) { return record->HasParent(memrecord); });
}
// artificially extend the lifespan of buffer device address memory or buffers, to ensure their
// opaque capture address isn't re-used before the capture completes
{