vk/image: Move validation for vkCreateImageView
authorChad Versace <chad.versace@intel.com>
Mon, 6 Jul 2015 23:24:28 +0000 (16:24 -0700)
committerChad Versace <chad.versace@intel.com>
Tue, 7 Jul 2015 01:27:14 +0000 (18:27 -0700)
Move the validation from anv_CreateImageView() and anv_image_view_init()
to anv_validate_CreateImageView(). No new validation is added.

src/vulkan/image.c

index 9930d90aa41a3a94ed1c8aaa22ab721e5a0788b9..00effbbc87bcdcc082147e6b31d3f6703b97bd18 100644 (file)
@@ -332,11 +332,6 @@ anv_image_view_init(struct anv_surface_view *view,
    const struct anv_format *format_info =
       anv_format_for_vk_format(pCreateInfo->format);
 
-   anv_assert(range->mipLevels > 0);
-   anv_assert(range->arraySize > 0);
-   anv_assert(range->baseMipLevel + range->mipLevels <= image->levels);
-   anv_assert(range->baseArraySlice + range->arraySize <= image->array_size);
-
    if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D)
       anv_finishme("non-2D image views");
 
@@ -434,6 +429,29 @@ anv_image_view_init(struct anv_surface_view *view,
    GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state);
 }
 
+VkResult
+anv_validate_CreateImageView(VkDevice _device,
+                             const VkImageViewCreateInfo *pCreateInfo,
+                             VkImageView *pView)
+{
+   const struct anv_image *image;
+   const VkImageSubresourceRange *range;
+
+   assert(pCreateInfo);
+   assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
+   assert(pView);
+
+   image = (struct anv_image *) pCreateInfo->image;
+   range = &pCreateInfo->subresourceRange;
+
+   assert(range->mipLevels > 0);
+   assert(range->arraySize > 0);
+   assert(range->baseMipLevel + range->mipLevels <= image->levels);
+   assert(range->baseArraySlice + range->arraySize <= image->array_size);
+
+   return anv_CreateImageView(_device, pCreateInfo, pView);
+}
+
 VkResult
 anv_CreateImageView(VkDevice _device,
                     const VkImageViewCreateInfo *pCreateInfo,
@@ -442,8 +460,6 @@ anv_CreateImageView(VkDevice _device,
    struct anv_device *device = (struct anv_device *) _device;
    struct anv_surface_view *view;
 
-   assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
-
    view = anv_device_alloc(device, sizeof(*view), 8,
                            VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
    if (view == NULL)