anv/image: Add a ussage_mask field to image_view_init
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 25 Feb 2016 03:49:12 +0000 (19:49 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 27 Feb 2016 18:26:14 +0000 (10:26 -0800)
This allows us to avoid doing some unneeded work on the meta paths where we
know that the image view will be used for exactly one thing.  The meta
paths also sometimes do things that aren't quite valid like setting the
array slice on a 3-D texture and we want to limit the number of paths that
need to be able to sensibly handle the lies.

src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_meta_blit.c
src/intel/vulkan/anv_meta_clear.c
src/intel/vulkan/anv_meta_resolve.c
src/intel/vulkan/anv_private.h

index 145db6de0390416574ff8370f436afbf4d92a59d..4caab5804ae3eec19d46711880e33d11fcb5694d 100644 (file)
@@ -478,7 +478,8 @@ anv_image_view_init(struct anv_image_view *iview,
                     struct anv_device *device,
                     const VkImageViewCreateInfo* pCreateInfo,
                     struct anv_cmd_buffer *cmd_buffer,
-                    uint32_t offset)
+                    uint32_t offset,
+                    VkImageUsageFlags usage_mask)
 {
    ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
    const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
@@ -577,7 +578,7 @@ anv_image_view_init(struct anv_image_view *iview,
       cube_usage = 0;
    }
 
-   if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
+   if (image->usage & usage_mask & VK_IMAGE_USAGE_SAMPLED_BIT) {
       iview->sampler_surface_state = alloc_surface_state(device, cmd_buffer);
 
       isl_view.usage = cube_usage | ISL_SURF_USAGE_TEXTURE_BIT;
@@ -594,7 +595,7 @@ anv_image_view_init(struct anv_image_view *iview,
       iview->sampler_surface_state.alloc_size = 0;
    }
 
-   if (image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
+   if (image->usage & usage_mask & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
       iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer);
 
       isl_view.usage = cube_usage | ISL_SURF_USAGE_RENDER_TARGET_BIT;
@@ -611,7 +612,7 @@ anv_image_view_init(struct anv_image_view *iview,
       iview->color_rt_surface_state.alloc_size = 0;
    }
 
-   if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
+   if (image->usage & usage_mask & VK_IMAGE_USAGE_STORAGE_BIT) {
       iview->storage_surface_state = alloc_surface_state(device, cmd_buffer);
 
       if (has_matching_storage_typed_format(device, format)) {
@@ -650,7 +651,7 @@ anv_CreateImageView(VkDevice _device,
    if (view == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   anv_image_view_init(view, device, pCreateInfo, NULL, 0);
+   anv_image_view_init(view, device, pCreateInfo, NULL, 0, ~0);
 
    *pView = anv_image_view_to_handle(view);
 
index 8ef943aa5122561e42ec518ed027f828e6779cff..2ec428b5f4a0a91debe52e94837be27abff6a2f4 100644 (file)
@@ -451,7 +451,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
             .layerCount = 1
          },
       },
-      cmd_buffer, 0);
+      cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
    struct anv_image_view dest_iview;
    anv_image_view_init(&dest_iview, cmd_buffer->device,
@@ -468,7 +468,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
             .layerCount = 1,
          },
       },
-      cmd_buffer, 0);
+      cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
    meta_emit_blit(cmd_buffer,
                   anv_image_from_handle(src_image),
@@ -711,7 +711,7 @@ void anv_CmdCopyImage(
                .layerCount = pRegions[r].dstSubresource.layerCount,
             },
          },
-         cmd_buffer, 0);
+         cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
       const uint32_t dest_base_array_slice =
          anv_meta_get_iview_layer(dest_image, &pRegions[r].dstSubresource,
@@ -758,7 +758,7 @@ void anv_CmdCopyImage(
                   .layerCount = 1
                },
             },
-            cmd_buffer, img_o);
+            cmd_buffer, img_o, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
          const VkExtent3D img_extent_el = meta_region_extent_el(dest_image->vk_format,
                                                                 &pRegions[r].extent);
@@ -826,7 +826,7 @@ void anv_CmdBlitImage(
                .layerCount = 1
             },
          },
-         cmd_buffer, 0);
+         cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
       const VkOffset3D dest_offset = {
          .x = pRegions[r].dstOffsets[0].x,
@@ -876,7 +876,7 @@ void anv_CmdBlitImage(
                .layerCount = 1
             },
          },
-         cmd_buffer, 0);
+         cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
       meta_emit_blit(cmd_buffer,
                      src_image, &src_iview,
@@ -991,7 +991,7 @@ void anv_CmdCopyBufferToImage(
                   .layerCount = 1,
                },
             },
-            cmd_buffer, 0);
+            cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
          uint32_t img_x = 0;
          uint32_t img_y = 0;
@@ -1025,7 +1025,7 @@ void anv_CmdCopyBufferToImage(
                   .layerCount = 1
                },
             },
-            cmd_buffer, img_o);
+            cmd_buffer, img_o, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
          const VkExtent3D img_extent_el = meta_region_extent_el(dest_image->vk_format,
                                                       &pRegions[r].imageExtent);
@@ -1104,7 +1104,7 @@ void anv_CmdCopyImageToBuffer(
                .layerCount = pRegions[r].imageSubresource.layerCount,
             },
          },
-         cmd_buffer, 0);
+         cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
       struct anv_image *dest_image =
          make_image_for_buffer(vk_device, destBuffer, src_image->vk_format,
@@ -1140,7 +1140,7 @@ void anv_CmdCopyImageToBuffer(
                   .layerCount = 1
                },
             },
-            cmd_buffer, 0);
+            cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
          meta_emit_blit(cmd_buffer,
                         anv_image_from_handle(srcImage),
index 739ae09582c41ea13a4fb8c1eaf19db11c0e6972..227f8f35115c46433e50e434deb1fafaffb675fd 100644 (file)
@@ -811,7 +811,7 @@ anv_cmd_clear_image(struct anv_cmd_buffer *cmd_buffer,
                      .layerCount = 1
                   },
                },
-               cmd_buffer, 0);
+               cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
             VkFramebuffer fb;
             anv_CreateFramebuffer(device_h,
index 8eb2548b5aecc8720dd7bd339dd7f64edb915700..19fb3ad30038d73ff6f975cd16605e8af997ced2 100644 (file)
@@ -737,7 +737,7 @@ void anv_CmdResolveImage(
                   .layerCount = 1,
                },
             },
-            cmd_buffer, 0);
+            cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
          struct anv_image_view dest_iview;
          anv_image_view_init(&dest_iview, cmd_buffer->device,
@@ -754,7 +754,7 @@ void anv_CmdResolveImage(
                   .layerCount = 1,
                },
             },
-            cmd_buffer, 0);
+            cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
          VkFramebuffer fb_h;
          anv_CreateFramebuffer(device_h,
index e50a6dbdbfeda76ab125ee6e1787a9f01ac13e90..05cb77c5509d1c1c3774fdbe41255b7817bc1320 100644 (file)
@@ -1680,7 +1680,8 @@ void anv_image_view_init(struct anv_image_view *view,
                          struct anv_device *device,
                          const VkImageViewCreateInfo* pCreateInfo,
                          struct anv_cmd_buffer *cmd_buffer,
-                         uint32_t offset);
+                         uint32_t offset,
+                         VkImageUsageFlags usage_mask);
 
 void
 anv_fill_image_surface_state(struct anv_device *device, struct anv_state state,