OSDN Git Service

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 5a9f826..5bee5a2 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 d915f69..76c47de 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 c5c4cda..fe2967c 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 c7cc585..5562a25 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;