vk/image: Simplify stencil case for anv_image_create()
authorChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 20:50:43 +0000 (13:50 -0700)
committerChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 21:08:55 +0000 (14:08 -0700)
Stop creating a temporary VkImageCreateInfo with overriden
format=VK_FORMAT_S8_UINT. Instead, just pass the format override
directly to anv_image_make_surface().

src/vulkan/anv_image.c

index 4c5032cea53a52ae49cdc53be21204569b5e6f6f..3b706c6844336d47b50aac77e30d5311e177614d 100644 (file)
@@ -123,8 +123,14 @@ anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info)
    }
 }
 
+
+/**
+ * The \a format argument is required and overrides any format in
+ * struct anv_image_create_info.
+ */
 static VkResult
 anv_image_make_surface(const struct anv_image_create_info *create_info,
+                       const struct anv_format *format,
                        uint64_t *inout_image_size,
                        uint32_t *inout_image_alignment,
                        struct anv_surface *out_surface)
@@ -142,9 +148,6 @@ anv_image_make_surface(const struct anv_image_create_info *create_info,
    const struct anv_tile_info *tile_info =
        &anv_tile_info_table[tile_mode];
 
-   const struct anv_format *format_info =
-      anv_format_for_vk_format(create_info->vk_info->format);
-
    const uint32_t i = 4; /* FINISHME: Stop hardcoding subimage alignment */
    const uint32_t j = 4; /* FINISHME: Stop hardcoding subimage alignment */
    const uint32_t w0 = align_u32(extent->width, i);
@@ -181,7 +184,7 @@ anv_image_make_surface(const struct anv_image_create_info *create_info,
     */
    assert(anv_is_aligned(qpitch, j));
 
-   uint32_t stride = align_u32(mt_width * format_info->cpp, tile_info->width);
+   uint32_t stride = align_u32(mt_width * format->cpp, tile_info->width);
    if (create_info->stride > 0)
       stride = create_info->stride;
 
@@ -257,7 +260,8 @@ anv_image_create(VkDevice _device,
 
    if (likely(!image->format->has_stencil || image->format->depth_format)) {
       /* The image's primary surface is a color or depth surface. */
-      r = anv_image_make_surface(create_info, &image->size, &image->alignment,
+      r = anv_image_make_surface(create_info, image->format,
+                                 &image->size, &image->alignment,
                                  &image->primary_surface);
       if (r != VK_SUCCESS)
          goto fail;
@@ -269,15 +273,9 @@ anv_image_create(VkDevice _device,
        * stencil reside in the same image.  To satisfy Vulkan and the GPU, we
        * place the depth and stencil buffers in the same bo.
        */
-      VkImageCreateInfo stencil_info = *pCreateInfo;
-      stencil_info.format = VK_FORMAT_S8_UINT;
-
-      r = anv_image_make_surface(
-            &(struct anv_image_create_info) {
-               .vk_info = &stencil_info,
-            },
-            &image->size, &image->alignment, &image->stencil_surface);
-
+      r = anv_image_make_surface(create_info, anv_format_s8_uint,
+                                 &image->size, &image->alignment,
+                                 &image->stencil_surface);
       if (r != VK_SUCCESS)
          goto fail;
    }