wsi: fix VK_INCOMPLETE for vkGetSwapchainImagesKHR
authorDave Airlie <airlied@redhat.com>
Tue, 15 Nov 2016 21:18:50 +0000 (21:18 +0000)
committerDave Airlie <airlied@redhat.com>
Tue, 15 Nov 2016 23:17:34 +0000 (09:17 +1000)
This fixes the x11 and wayland backends to not assert:
dEQP-VK.wsi.xcb.swapchain.get_images.incomplete

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/vulkan/wsi/wsi_common_wayland.c
src/vulkan/wsi/wsi_common_x11.c

index 76917442fb1b9ed6cd548ba38172dc1f5ffb20d0..f6c218bde3ff5f59696eeed57ebbb5ecce86d537 100644 (file)
@@ -498,19 +498,25 @@ wsi_wl_swapchain_get_images(struct wsi_swapchain *wsi_chain,
                             uint32_t *pCount, VkImage *pSwapchainImages)
 {
    struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
+   uint32_t ret_count;
+   VkResult result;
 
    if (pSwapchainImages == NULL) {
       *pCount = chain->image_count;
       return VK_SUCCESS;
    }
 
-   assert(chain->image_count <= *pCount);
-   for (uint32_t i = 0; i < chain->image_count; i++)
-      pSwapchainImages[i] = chain->images[i].image;
+   result = VK_SUCCESS;
+   ret_count = chain->image_count;
+   if (chain->image_count > *pCount) {
+     ret_count = *pCount;
+     result = VK_INCOMPLETE;
+   }
 
-   *pCount = chain->image_count;
+   for (uint32_t i = 0; i < ret_count; i++)
+      pSwapchainImages[i] = chain->images[i].image;
 
-   return VK_SUCCESS;
+   return result;
 }
 
 static VkResult
index 137bc7f06f2587eeb9f3d63f8cf638018543eb96..8e0043fdc7f297abd0ca43cc370ccb953201d8ed 100644 (file)
@@ -509,19 +509,25 @@ x11_get_images(struct wsi_swapchain *anv_chain,
                uint32_t* pCount, VkImage *pSwapchainImages)
 {
    struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
+   uint32_t ret_count;
+   VkResult result;
 
    if (pSwapchainImages == NULL) {
       *pCount = chain->image_count;
       return VK_SUCCESS;
    }
 
-   assert(chain->image_count <= *pCount);
-   for (uint32_t i = 0; i < chain->image_count; i++)
-      pSwapchainImages[i] = chain->images[i].image;
+   result = VK_SUCCESS;
+   ret_count = chain->image_count;
+   if (chain->image_count > *pCount) {
+     ret_count = *pCount;
+     result = VK_INCOMPLETE;
+   }
 
-   *pCount = chain->image_count;
+   for (uint32_t i = 0; i < ret_count; i++)
+      pSwapchainImages[i] = chain->images[i].image;
 
-   return VK_SUCCESS;
+   return result;
 }
 
 static VkResult