From c31c04712d7eac5abb0ed91b3f8e30769d8fb0ae Mon Sep 17 00:00:00 2001 From: Pavel Asyutchenko Date: Sat, 31 Jul 2021 17:09:14 +0300 Subject: [PATCH] Fix broken capture when app uses dedicated allocation weirdly Both handles in VkMemoryDedicatedAllocateInfo can be VK_NULL_HANDLE, specification allows this. Should be safe to ignore struct in this case. --- .../vulkan/wrappers/vk_resource_funcs.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index cbcb9651e..cc2f0b30b 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -315,9 +315,18 @@ bool WrappedVulkan::Serialise_vkAllocateMemory(SerialiserType &ser, VkDevice dev VkMemoryDedicatedAllocateInfo *dedicated = (VkMemoryDedicatedAllocateInfo *)FindNextStruct( &AllocateInfo, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO); + if(dedicated && dedicated->buffer == VK_NULL_HANDLE && dedicated->image == VK_NULL_HANDLE) + { + dedicated = NULL; + } + VkDedicatedAllocationMemoryAllocateInfoNV *dedicatedNV = (VkDedicatedAllocationMemoryAllocateInfoNV *)FindNextStruct( &AllocateInfo, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV); + if(dedicatedNV && dedicatedNV->buffer == VK_NULL_HANDLE && dedicatedNV->image == VK_NULL_HANDLE) + { + dedicatedNV = NULL; + } if(dedicated) { @@ -480,9 +489,18 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate VkMemoryDedicatedAllocateInfo *dedicated = (VkMemoryDedicatedAllocateInfo *)FindNextStruct( pAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO); + if(dedicated && dedicated->buffer == VK_NULL_HANDLE && dedicated->image == VK_NULL_HANDLE) + { + dedicated = NULL; + } + VkDedicatedAllocationMemoryAllocateInfoNV *dedicatedNV = (VkDedicatedAllocationMemoryAllocateInfoNV *)FindNextStruct( pAllocateInfo, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV); + if(dedicatedNV && dedicatedNV->buffer == VK_NULL_HANDLE && dedicatedNV->image == VK_NULL_HANDLE) + { + dedicatedNV = NULL; + } // create a buffer with the whole memory range bound, for copying to and from // conveniently (for initial state data)