From b3c037f329beb5d7a63a7e755ca3b15acdfce972 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 4 Sep 2015 19:05:51 -0700 Subject: [PATCH] vk: Fix size return value handling in a couple plces --- src/vulkan/anv_device.c | 4 ++-- src/vulkan/anv_wsi_wayland.c | 8 +++++++- src/vulkan/anv_wsi_x11.c | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index c1758de537c..cf93cd1a6eb 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -653,7 +653,7 @@ VkResult anv_GetGlobalExtensionProperties( return VK_SUCCESS; } - assert(*pCount <= ARRAY_SIZE(global_extensions)); + assert(*pCount >= ARRAY_SIZE(global_extensions)); *pCount = ARRAY_SIZE(global_extensions); memcpy(pProperties, global_extensions, sizeof(global_extensions)); @@ -679,7 +679,7 @@ VkResult anv_GetPhysicalDeviceExtensionProperties( return VK_SUCCESS; } - assert(*pCount < ARRAY_SIZE(device_extensions)); + assert(*pCount >= ARRAY_SIZE(device_extensions)); *pCount = ARRAY_SIZE(device_extensions); memcpy(pProperties, device_extensions, sizeof(device_extensions)); diff --git a/src/vulkan/anv_wsi_wayland.c b/src/vulkan/anv_wsi_wayland.c index e23f5933fe4..11f2dae9759 100644 --- a/src/vulkan/anv_wsi_wayland.c +++ b/src/vulkan/anv_wsi_wayland.c @@ -327,9 +327,15 @@ wsi_wl_get_surface_info(struct anv_wsi_implementation *impl, switch (infoType) { case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: { - assert(*pDataSize >= sizeof(VkSurfacePropertiesWSI)); VkSurfacePropertiesWSI *props = pData; + if (pData == NULL) { + *pDataSize = sizeof(*props); + return VK_SUCCESS; + } + + assert(*pDataSize >= sizeof(*props)); + props->minImageCount = MIN_NUM_IMAGES; props->maxImageCount = 4; props->currentExtent = (VkExtent2D) { -1, -1 }; diff --git a/src/vulkan/anv_wsi_x11.c b/src/vulkan/anv_wsi_x11.c index 212c01be0b9..b412a2bab32 100644 --- a/src/vulkan/anv_wsi_x11.c +++ b/src/vulkan/anv_wsi_x11.c @@ -59,9 +59,15 @@ x11_get_surface_info(struct anv_wsi_implementation *impl, switch (infoType) { case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: { - assert(*pDataSize >= sizeof(VkSurfacePropertiesWSI)); VkSurfacePropertiesWSI *props = pData; + if (pData == NULL) { + *pDataSize = sizeof(*props); + return VK_SUCCESS; + } + + assert(*pDataSize >= sizeof(*props)); + props->minImageCount = 2; props->maxImageCount = 4; props->currentExtent = (VkExtent2D) { -1, -1 }; -- 2.30.2