From: Chad Versace Date: Mon, 6 Jul 2015 23:24:28 +0000 (-0700) Subject: vk/image: Move validation for vkCreateImageView X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b04db71ff9416fad7d8399b3bad4d754deeacc8;p=mesa.git vk/image: Move validation for vkCreateImageView Move the validation from anv_CreateImageView() and anv_image_view_init() to anv_validate_CreateImageView(). No new validation is added. --- diff --git a/src/vulkan/image.c b/src/vulkan/image.c index 9930d90aa41..00effbbc87b 100644 --- a/src/vulkan/image.c +++ b/src/vulkan/image.c @@ -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)