From 3d5aabdd80ecea6d314c0ebee9f4d3baa2c9a992 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 8 Sep 2020 12:41:10 +0100 Subject: [PATCH] Make sure to enable bufferDeviceAddressCaptureReplay on replay * We used to get this 'for free' by serialising our patched device next chains, but we no longer do that so we need to enable this bit on replay as well. --- .../vulkan/wrappers/vk_device_funcs.cpp | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 2a6ad0c44..f6e67462b 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -2922,14 +2922,25 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi } else { - // don't add a new VkPhysicalDeviceVulkan12Features to the pNext chain because if we do we - // have to remove any components etc. Instead just add the individual - // VkPhysicalDeviceBufferDeviceAddressFeaturesKHR - bufAddrKHRFeatures.bufferDeviceAddress = VK_TRUE; - bufAddrKHRFeatures.bufferDeviceAddressMultiDevice = VK_FALSE; + VkPhysicalDeviceBufferDeviceAddressFeaturesKHR *existingKHR = + (VkPhysicalDeviceBufferDeviceAddressFeaturesKHR *)FindNextStruct( + &createInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR); + VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *existingEXT = + (VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *)FindNextStruct( + &createInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT); - bufAddrKHRFeatures.pNext = (void *)createInfo.pNext; - createInfo.pNext = &bufAddrKHRFeatures; + if(!existingKHR && !existingEXT) + { + // don't add a new VkPhysicalDeviceVulkan12Features to the pNext chain because if we do + // we + // have to remove any components etc. Instead just add the individual + // VkPhysicalDeviceBufferDeviceAddressFeaturesKHR + bufAddrKHRFeatures.bufferDeviceAddress = VK_TRUE; + bufAddrKHRFeatures.bufferDeviceAddressMultiDevice = VK_FALSE; + + bufAddrKHRFeatures.pNext = (void *)createInfo.pNext; + createInfo.pNext = &bufAddrKHRFeatures; + } } } } @@ -3008,6 +3019,30 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi } } + { + VkPhysicalDeviceVulkan12Features *enabledFeaturesVK12 = + (VkPhysicalDeviceVulkan12Features *)FindNextStruct( + &createInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES); + VkPhysicalDeviceBufferDeviceAddressFeatures *bufferAddressFeaturesCoreKHR = + (VkPhysicalDeviceBufferDeviceAddressFeatures *)FindNextStruct( + &createInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES); + VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *bufferAddressFeaturesEXT = + (VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *)FindNextStruct( + &createInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT); + + // turn on bufferDeviceAddressCaptureReplay if available, so that a capture that uses it is + // safe + // to replay. Enabling this without using it is fine. + if(enabledFeaturesVK12 && enabledFeaturesVK12->bufferDeviceAddress) + enabledFeaturesVK12->bufferDeviceAddressCaptureReplay = VK_TRUE; + + if(bufferAddressFeaturesCoreKHR) + bufferAddressFeaturesCoreKHR->bufferDeviceAddressCaptureReplay = VK_TRUE; + + if(bufferAddressFeaturesEXT) + bufferAddressFeaturesEXT->bufferDeviceAddressCaptureReplay = VK_TRUE; + } + rdcarray layerArray(Layers.size()); for(size_t i = 0; i < Layers.size(); i++) layerArray[i] = Layers[i].c_str();