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."
This commit is contained in:
Brian Osman
2022-11-03 10:17:21 -04:00
committed by Baldur Karlsson
parent 95ade35dab
commit 7a3ea53b3d
@@ -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<VkQueueFamilyProperties> &queueProps,