From 4b561b81bbe94a78fbc7b1b696d4e54b0ca78382 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 7 Apr 2025 16:53:00 +0100 Subject: [PATCH] Don't force BDA on memory allocs that will be used with dedicated images --- .../vulkan/wrappers/vk_resource_funcs.cpp | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index 807599076..9f2b82c4b 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -514,19 +514,29 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate // will be bound against since there's no requirement for the buffer to be marked as BDA. This // means that when RT is enabled ALL MEMORY IN THE ENTIRE PROGRAM must be marked as BDA just in // case. + // + // we don't force this on for memory allocations that are going to be used for dedicated images + bool forceBDA = false; if(IsCaptureMode(m_State) && AccelerationStructures()) { - // force BDA flag when creating, by adding the struct if needed - if(memFlags) + VkMemoryDedicatedAllocateInfo *dedicated = (VkMemoryDedicatedAllocateInfo *)FindNextStruct( + pAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO); + if(dedicated == NULL || dedicated->image == VK_NULL_HANDLE) { - memFlags->flags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT; - } - else - { - rtForcedFlags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT | - VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT; - rtForcedFlags.pNext = unwrapped.pNext; - unwrapped.pNext = &rtForcedFlags; + // force BDA flag when creating, by adding the struct if needed + forceBDA = true; + + if(memFlags) + { + memFlags->flags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT; + } + else + { + rtForcedFlags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT | + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT; + rtForcedFlags.pNext = unwrapped.pNext; + unwrapped.pNext = &rtForcedFlags; + } } } @@ -690,7 +700,7 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate &serialisedInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO); // see above for this gross workaround we have to do - if(AccelerationStructures()) + if(forceBDA) { if(memFlags) {