Skip to content

Commit c71f3d5

Browse files
tuxerrbaldurk
authored andcommitted
fix destroyed BDA buffers staying tracked
1 parent ef0d673 commit c71f3d5

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

renderdoc/driver/vulkan/vk_core.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,6 @@ class WrappedVulkan : public IFrameCapturer
10381038
{
10391039
rdcarray<VkDeviceMemory> DeadMemories;
10401040
rdcarray<VkBuffer> DeadBuffers;
1041-
rdcarray<ResourceId> IDs;
10421041

10431042
// with descriptor buffers, we also need to hold onto images and image views
10441043
rdcarray<VkImage> DeadImages;

renderdoc/driver/vulkan/vk_memory.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ RDOC_CONFIG(bool, Vulkan_Debug_MemoryAllocationLogging, false,
3030

3131
GPUAddressRange WrappedVulkan::CreateAddressRange(VkDevice device, VkBuffer buffer)
3232
{
33-
bool isBDA = false;
34-
{
35-
SCOPED_LOCK(m_DeviceAddressResourcesLock);
36-
isBDA = m_DeviceAddressResources.IDs.contains(GetResID(buffer));
37-
}
38-
39-
if(!isBDA)
33+
VkResourceRecord *record = GetRecord(buffer);
34+
if(!record->hasBDA)
4035
return {};
4136

42-
VkResourceRecord *record = GetRecord(buffer);
4337
VkResourceRecord *memrecord = GetResourceManager()->GetResourceRecord(record->baseResourceMem);
4438

4539
const bool isSparse = record->resInfo && record->resInfo->IsSparse();

renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,12 @@ void WrappedVulkan::vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAl
307307
// opaque capture address isn't re-used before the capture completes
308308
{
309309
SCOPED_READLOCK(m_CapTransitionLock);
310-
SCOPED_LOCK(m_DeviceAddressResourcesLock);
311-
if(IsActiveCapturing(m_State) && m_DeviceAddressResources.IDs.contains(GetResID(buffer)))
310+
if(IsActiveCapturing(m_State) && GetRecord(buffer)->hasBDA)
312311
{
312+
SCOPED_LOCK(m_DeviceAddressResourcesLock);
313313
m_DeviceAddressResources.DeadBuffers.push_back(buffer);
314314
return;
315315
}
316-
m_DeviceAddressResources.IDs.removeOne(GetResID(buffer));
317316
}
318317

319318
if(IsCaptureMode(m_State))

renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -842,10 +842,7 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
842842

843843
memFlags->flags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT;
844844

845-
{
846-
SCOPED_LOCK(m_DeviceAddressResourcesLock);
847-
m_DeviceAddressResources.IDs.push_back(record->GetResourceID());
848-
}
845+
record->hasBDA = true;
849846
}
850847

851848
{
@@ -950,13 +947,12 @@ void WrappedVulkan::vkFreeMemory(VkDevice device, VkDeviceMemory memory, const V
950947
// opaque capture address isn't re-used before the capture completes
951948
{
952949
SCOPED_READLOCK(m_CapTransitionLock);
953-
SCOPED_LOCK(m_DeviceAddressResourcesLock);
954-
if(IsActiveCapturing(m_State) && m_DeviceAddressResources.IDs.contains(GetResID(memory)))
950+
if(IsActiveCapturing(m_State) && wrapped->record->hasBDA)
955951
{
952+
SCOPED_LOCK(m_DeviceAddressResourcesLock);
956953
m_DeviceAddressResources.DeadMemories.push_back(memory);
957954
return;
958955
}
959-
m_DeviceAddressResources.IDs.removeOne(GetResID(memory));
960956
}
961957

962958
MemMapState *memMapState = wrapped->record->memMapState;
@@ -2066,11 +2062,6 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic
20662062
}
20672063
}
20682064

2069-
if(patchedusage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT)
2070-
{
2071-
m_DeviceAddressResources.IDs.push_back(GetResID(buf));
2072-
}
2073-
20742065
if(patchedusage & VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT)
20752066
m_ResourceDescBuffers.push_back(GetResID(buf));
20762067

@@ -2231,10 +2222,7 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo
22312222
// address
22322223
AddForcedReference(record);
22332224

2234-
{
2235-
SCOPED_LOCK(m_DeviceAddressResourcesLock);
2236-
m_DeviceAddressResources.IDs.push_back(record->GetResourceID());
2237-
}
2225+
record->hasBDA = true;
22382226

22392227
if(DescriptorBuffers())
22402228
{

0 commit comments

Comments
 (0)