Skip to content

Commit e61aca2

Browse files
committed
Try to re-use BDA capture/replay structs
1 parent f30f49f commit e61aca2

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp

+42-15
Original file line numberDiff line numberDiff line change
@@ -713,16 +713,29 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
713713
Unwrap(*pMemory),
714714
};
715715

716-
memoryDeviceAddress.opaqueCaptureAddress =
716+
VkMemoryOpaqueCaptureAddressAllocateInfo *addr =
717+
(VkMemoryOpaqueCaptureAddressAllocateInfo *)FindNextStruct(
718+
&serialisedInfo, VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO);
719+
720+
uint64_t opaque =
717721
ObjDisp(device)->GetDeviceMemoryOpaqueCaptureAddress(Unwrap(device), &getInfo);
718722

719-
// we explicitly DON'T assert on this, because some drivers will only need the device
720-
// address specified at allocate time.
721-
// RDCASSERT(memoryDeviceAddress.opaqueCaptureAddress);
723+
if(addr)
724+
{
725+
RDCASSERT(addr->opaqueCaptureAddress == opaque, addr->opaqueCaptureAddress, opaque);
726+
}
727+
else
728+
{
729+
memoryDeviceAddress.opaqueCaptureAddress = opaque;
722730

723-
// push this struct onto the start of the chain
724-
memoryDeviceAddress.pNext = serialisedInfo.pNext;
725-
serialisedInfo.pNext = &memoryDeviceAddress;
731+
// we explicitly DON'T assert on this, because some drivers will only need the device
732+
// address specified at allocate time.
733+
// RDCASSERT(memoryDeviceAddress.opaqueCaptureAddress);
734+
735+
// push this struct onto the start of the chain
736+
memoryDeviceAddress.pNext = serialisedInfo.pNext;
737+
serialisedInfo.pNext = &memoryDeviceAddress;
738+
}
726739

727740
memFlags->flags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT;
728741

@@ -1877,16 +1890,30 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo
18771890

18781891
if(GetExtensions(GetRecord(device)).ext_KHR_buffer_device_address)
18791892
{
1880-
bufferDeviceAddressCoreOrKHR.opaqueCaptureAddress =
1881-
ObjDisp(device)->GetBufferOpaqueCaptureAddress(Unwrap(device), &getInfo);
1893+
VkBufferOpaqueCaptureAddressCreateInfo *addr =
1894+
(VkBufferOpaqueCaptureAddressCreateInfo *)FindNextStruct(
1895+
&serialisedCreateInfo, VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO);
18821896

1883-
// we explicitly DON'T assert on this, because some drivers will only need the device
1884-
// address specified at allocate time.
1885-
// RDCASSERT(bufferDeviceAddressKHR.opaqueCaptureAddress);
1897+
uint64_t opaque = ObjDisp(device)->GetBufferOpaqueCaptureAddress(Unwrap(device), &getInfo);
18861898

1887-
// push this struct onto the start of the chain
1888-
bufferDeviceAddressCoreOrKHR.pNext = serialisedCreateInfo.pNext;
1889-
serialisedCreateInfo.pNext = &bufferDeviceAddressCoreOrKHR;
1899+
if(addr)
1900+
{
1901+
RDCASSERT(opaque == addr->opaqueCaptureAddress, opaque, addr->opaqueCaptureAddress);
1902+
}
1903+
else
1904+
{
1905+
addr = &bufferDeviceAddressCoreOrKHR;
1906+
1907+
bufferDeviceAddressCoreOrKHR.opaqueCaptureAddress = opaque;
1908+
1909+
// we explicitly DON'T assert on this, because some drivers will only need the device
1910+
// address specified at allocate time.
1911+
// RDCASSERT(bufferDeviceAddressKHR.opaqueCaptureAddress);
1912+
1913+
// push this struct onto the start of the chain
1914+
bufferDeviceAddressCoreOrKHR.pNext = serialisedCreateInfo.pNext;
1915+
serialisedCreateInfo.pNext = &bufferDeviceAddressCoreOrKHR;
1916+
}
18901917
}
18911918
else if(GetExtensions(GetRecord(device)).ext_EXT_buffer_device_address)
18921919
{

0 commit comments

Comments
 (0)