Skip to content

Commit 4b561b8

Browse files
committed
Don't force BDA on memory allocs that will be used with dedicated images
1 parent af0a32d commit 4b561b8

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,29 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
514514
// will be bound against since there's no requirement for the buffer to be marked as BDA. This
515515
// means that when RT is enabled ALL MEMORY IN THE ENTIRE PROGRAM must be marked as BDA just in
516516
// case.
517+
//
518+
// we don't force this on for memory allocations that are going to be used for dedicated images
519+
bool forceBDA = false;
517520
if(IsCaptureMode(m_State) && AccelerationStructures())
518521
{
519-
// force BDA flag when creating, by adding the struct if needed
520-
if(memFlags)
521-
{
522-
memFlags->flags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT;
523-
}
524-
else
522+
VkMemoryDedicatedAllocateInfo *dedicated = (VkMemoryDedicatedAllocateInfo *)FindNextStruct(
523+
pAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO);
524+
if(dedicated == NULL || dedicated->image == VK_NULL_HANDLE)
525525
{
526-
rtForcedFlags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT |
527-
VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT;
528-
rtForcedFlags.pNext = unwrapped.pNext;
529-
unwrapped.pNext = &rtForcedFlags;
526+
// force BDA flag when creating, by adding the struct if needed
527+
forceBDA = true;
528+
529+
if(memFlags)
530+
{
531+
memFlags->flags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT;
532+
}
533+
else
534+
{
535+
rtForcedFlags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT |
536+
VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT;
537+
rtForcedFlags.pNext = unwrapped.pNext;
538+
unwrapped.pNext = &rtForcedFlags;
539+
}
530540
}
531541
}
532542

@@ -690,7 +700,7 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
690700
&serialisedInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO);
691701

692702
// see above for this gross workaround we have to do
693-
if(AccelerationStructures())
703+
if(forceBDA)
694704
{
695705
if(memFlags)
696706
{

0 commit comments

Comments
 (0)