From 7a3ea53b3de05949569b3af35179acf2b5b5928b Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Thu, 3 Nov 2022 10:17:21 -0400 Subject: [PATCH] vkEnumeratePhysicalDevices: Handle count being too small Per the Vulkan Spec: "If pPhysicalDeviceCount is less than the number of physical devices available, at most pPhysicalDeviceCount structures will be written, and VK_INCOMPLETE will be returned instead of VK_SUCCESS, to indicate that not all the available physical devices were returned." --- .../driver/vulkan/wrappers/vk_device_funcs.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 5089e86e1..eb700a43a 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -1502,14 +1502,22 @@ VkResult WrappedVulkan::vkEnumeratePhysicalDevices(VkInstance instance, } } - if(pPhysicalDeviceCount) - *pPhysicalDeviceCount = count; + VkResult result = VK_SUCCESS; + if(pPhysicalDevices) + { + if(count > *pPhysicalDeviceCount) + { + count = *pPhysicalDeviceCount; + result = VK_INCOMPLETE; + } memcpy(pPhysicalDevices, devices, count * sizeof(VkPhysicalDevice)); + } + *pPhysicalDeviceCount = count; SAFE_DELETE_ARRAY(devices); - return VK_SUCCESS; + return result; } bool WrappedVulkan::SelectGraphicsComputeQueue(const rdcarray &queueProps,