anv: Sanitize Image extents and offsets

Prepare Image extents and offsets for internal consumption by assigning
the default values implicitly defned by the spec. Fixes textures on
several Vulkan demos in which the VkImageCopy depth is set to zero when
copying a 2D image.

v2 (Jason Ekstrand):
   Replace "prep" with "sanitize"
   Make function static inline
   Pass structs instead of pointers

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 143a084..b47425b 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -124,30 +124,16 @@
 
    struct anv_surface *anv_surf = get_surface(image, aspect);
 
-   VkExtent3D extent;
-   switch (vk_info->imageType) {
-   case VK_IMAGE_TYPE_1D:
-      extent = (VkExtent3D) { vk_info->extent.width, 1, 1 };
-      break;
-   case VK_IMAGE_TYPE_2D:
-      extent = (VkExtent3D) { vk_info->extent.width, vk_info->extent.height, 1 };
-      break;
-   case VK_IMAGE_TYPE_3D:
-      extent = vk_info->extent;
-      break;
-   default:
-      unreachable("invalid image type");
-   }
-
-   image->extent = extent;
+   image->extent = anv_sanitize_image_extent(vk_info->imageType,
+                                             vk_info->extent);
 
    ok = isl_surf_init(&dev->isl_dev, &anv_surf->isl,
       .dim = vk_to_isl_surf_dim[vk_info->imageType],
       .format = anv_get_isl_format(vk_info->format, aspect,
                                    vk_info->tiling, NULL),
-      .width = extent.width,
-      .height = extent.height,
-      .depth = extent.depth,
+      .width = image->extent.width,
+      .height = image->extent.height,
+      .depth = image->extent.depth,
       .levels = vk_info->mipLevels,
       .array_len = vk_info->arrayLayers,
       .samples = vk_info->samples,