anv/image: Do more work in anv_image_view_init
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 1 Jan 2016 21:47:18 +0000 (13:47 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 5 Jan 2016 00:08:05 +0000 (16:08 -0800)
There was a bunch of common code in gen7/8_image_view_init that we really
should be sharing.

src/vulkan/anv_image.c
src/vulkan/anv_private.h
src/vulkan/gen7_state.c
src/vulkan/gen8_state.c

index 5a9f826ec435b777a93442df5c48e16c17291ddd..5bee5a236e8cbb5d8ae22568088637e8fddbd37b 100644 (file)
@@ -432,6 +432,22 @@ anv_image_view_init(struct anv_image_view *iview,
       break;
    }
 
+   struct anv_surface *surface =
+      anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
+
+   iview->image = image;
+   iview->bo = image->bo;
+   iview->offset = image->offset + surface->offset;
+
+   iview->aspect_mask = pCreateInfo->subresourceRange.aspectMask;
+   iview->format = anv_format_for_vk_format(pCreateInfo->format);
+
+   iview->extent = (VkExtent3D) {
+      .width = anv_minify(image->extent.width, range->baseMipLevel),
+      .height = anv_minify(image->extent.height, range->baseMipLevel),
+      .depth = anv_minify(image->extent.depth, range->baseMipLevel),
+   };
+
    switch (device->info.gen) {
    case 7:
       if (device->info.is_haswell)
index d915f6943477a085d72d27b82d33568ec3000a5d..76c47de594a109854c93bf17c8e1652e00624d88 100644 (file)
@@ -1492,6 +1492,8 @@ struct anv_image_view {
    const struct anv_format *format; /**< VkImageViewCreateInfo::format */
    struct anv_bo *bo;
    uint32_t offset; /**< Offset into bo. */
+
+   VkImageAspectFlags aspect_mask;
    VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
 
    /** RENDER_SURFACE_STATE when using image as a color render target. */
index c5c4cdaaf85fd7d02cd01858f4244eaaf43d69ab..fe2967c7ef4ca244178553f39fdb23724801808e 100644 (file)
@@ -198,23 +198,9 @@ genX(image_view_init)(struct anv_image_view *iview,
    struct anv_surface *surface =
       anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
 
-   const struct anv_format *format =
-      anv_format_for_vk_format(pCreateInfo->format);
-
    if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D)
       anv_finishme("non-2D image views");
 
-   iview->image = image;
-   iview->bo = image->bo;
-   iview->offset = image->offset + surface->offset;
-   iview->format = anv_format_for_vk_format(pCreateInfo->format);
-
-   iview->extent = (VkExtent3D) {
-      .width = anv_minify(image->extent.width, range->baseMipLevel),
-      .height = anv_minify(image->extent.height, range->baseMipLevel),
-      .depth = anv_minify(image->extent.depth, range->baseMipLevel),
-   };
-
    uint32_t depth = 1;
    if (range->layerCount > 1) {
       depth = range->layerCount;
@@ -228,7 +214,7 @@ genX(image_view_init)(struct anv_image_view *iview,
    struct GENX(RENDER_SURFACE_STATE) surface_state = {
       .SurfaceType = anv_surftype(image, pCreateInfo->viewType, false),
       .SurfaceArray = image->array_size > 1,
-      .SurfaceFormat = format->surface_format,
+      .SurfaceFormat = iview->format->surface_format,
       .SurfaceVerticalAlignment = anv_valign[image_align_sa.height],
       .SurfaceHorizontalAlignment = anv_halign[image_align_sa.width],
 
@@ -325,7 +311,7 @@ genX(image_view_init)(struct anv_image_view *iview,
 
       surface_state.SurfaceFormat =
          isl_lower_storage_image_format(&device->isl_dev,
-                                        format->surface_format);
+                                        iview->format->surface_format);
 
       surface_state.SurfaceMinLOD = range->baseMipLevel;
       surface_state.MIPCountLOD = MAX2(range->levelCount, 1) - 1;
index c7cc585c5e1a860513a8b7a02e32268c1d9de1ef..5562a252a21999a2c5945ec13857a24181fcae7a 100644 (file)
@@ -140,20 +140,6 @@ genX(image_view_init)(struct anv_image_view *iview,
    uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */
    uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */
 
-   const struct anv_format *format_info =
-      anv_format_for_vk_format(pCreateInfo->format);
-
-   iview->image = image;
-   iview->bo = image->bo;
-   iview->offset = image->offset + surface->offset;
-   iview->format = format_info;
-
-   iview->extent = (VkExtent3D) {
-      .width = anv_minify(image->extent.width, range->baseMipLevel),
-      .height = anv_minify(image->extent.height, range->baseMipLevel),
-      .depth = anv_minify(image->extent.depth, range->baseMipLevel),
-   };
-
    switch (image->type) {
    case VK_IMAGE_TYPE_1D:
    case VK_IMAGE_TYPE_2D:
@@ -208,7 +194,7 @@ genX(image_view_init)(struct anv_image_view *iview,
    struct GENX(RENDER_SURFACE_STATE) surface_state = {
       .SurfaceType = anv_surftype(image, pCreateInfo->viewType, false),
       .SurfaceArray = image->array_size > 1,
-      .SurfaceFormat = format_info->surface_format,
+      .SurfaceFormat = iview->format->surface_format,
       .SurfaceVerticalAlignment = valign,
       .SurfaceHorizontalAlignment = halign,
       .TileMode = isl_to_gen_tiling[surface->isl.tiling],
@@ -300,7 +286,7 @@ genX(image_view_init)(struct anv_image_view *iview,
 
       surface_state.SurfaceFormat =
          isl_lower_storage_image_format(&device->isl_dev,
-                                        format_info->surface_format);
+                                        iview->format->surface_format);
 
       surface_state.SurfaceMinLOD = range->baseMipLevel;
       surface_state.MIPCountLOD = MAX2(range->levelCount, 1) - 1;