anv: Take a single aspect in anv_layout_to_aux_usage
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 5 Oct 2017 19:20:40 +0000 (12:20 -0700)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 6 Oct 2017 15:32:19 +0000 (16:32 +0100)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c

index 6ee2d2ef7cb5bd468f90e833cae4e455b09c2645..a56f732e276e88f08ec4fbfd5a153c94e495318e 100644 (file)
@@ -608,7 +608,7 @@ void anv_GetImageSubresourceLayout(
 enum isl_aux_usage
 anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
                         const struct anv_image * const image,
-                        const VkImageAspectFlags aspects,
+                        const VkImageAspectFlagBits aspect,
                         const VkImageLayout layout)
 {
    /* Validate the inputs. */
@@ -619,8 +619,8 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
    /* The layout of a NULL image is not properly defined. */
    assert(image != NULL);
 
-   /* The aspects must be a subset of the image aspects. */
-   assert(aspects & image->aspects && aspects <= image->aspects);
+   /* The aspect must be exactly one of the image aspects. */
+   assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));
 
    /* Determine the optimal buffer. */
 
@@ -633,15 +633,11 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
    /* All images that use an auxiliary surface are required to be tiled. */
    assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
 
-   /* On BDW+, when clearing the stencil aspect of a depth stencil image,
-    * the HiZ buffer allows us to record the clear with a relatively small
-    * number of packets. Prior to BDW, the HiZ buffer provides no known benefit
-    * to the stencil aspect.
-    */
-   if (devinfo->gen < 8 && aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
+   /* Stencil has no aux */
+   if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT)
       return ISL_AUX_USAGE_NONE;
 
-   const bool color_aspect = aspects == VK_IMAGE_ASPECT_COLOR_BIT;
+   const bool color_aspect = aspect == VK_IMAGE_ASPECT_COLOR_BIT;
 
    /* The following switch currently only handles depth stencil aspects.
     * TODO: Handle the color aspect.
@@ -685,7 +681,8 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
       /* Fall-through */
    case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
    case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR:
-      if (anv_can_sample_with_hiz(devinfo, aspects, image->samples))
+      assert(aspect == VK_IMAGE_ASPECT_DEPTH_BIT);
+      if (anv_can_sample_with_hiz(devinfo, aspect, image->samples))
          return ISL_AUX_USAGE_HIZ;
       else
          return ISL_AUX_USAGE_NONE;
@@ -718,7 +715,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
 
    case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
    case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR:
-      assert(!color_aspect);
+      assert(aspect == VK_IMAGE_ASPECT_DEPTH_BIT);
       return ISL_AUX_USAGE_HIZ;
 
    case VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR:
index a465aab272618bb65dd62c37cf085ff702bd7320..77106ca68a10cdde90c9d703b4c1b1657f069c77 100644 (file)
@@ -2417,7 +2417,7 @@ anv_image_copy_to_shadow(struct anv_cmd_buffer *cmd_buffer,
 enum isl_aux_usage
 anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
                         const struct anv_image *image,
-                        const VkImageAspectFlags aspects,
+                        const VkImageAspectFlagBits aspect,
                         const VkImageLayout layout);
 
 /* This is defined as a macro so that it works for both
index 779a74d7ccabe9aa69d6de37678fd7f838a993af..dcebf1d3c428945cc4fa8315f49bdecaa533171d 100644 (file)
@@ -374,11 +374,11 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
       return;
 
    const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==
-      anv_layout_to_aux_usage(&cmd_buffer->device->info, image, image->aspects,
-                              initial_layout);
+      anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
+                              VK_IMAGE_ASPECT_DEPTH_BIT, initial_layout);
    const bool enable_hiz = ISL_AUX_USAGE_HIZ ==
-      anv_layout_to_aux_usage(&cmd_buffer->device->info, image, image->aspects,
-                              final_layout);
+      anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
+                              VK_IMAGE_ASPECT_DEPTH_BIT, final_layout);
 
    enum blorp_hiz_op hiz_op;
    if (hiz_enabled && !enable_hiz) {
@@ -2892,7 +2892,7 @@ cmd_buffer_subpass_transition_layouts(struct anv_cmd_buffer * const cmd_buffer,
                                  att_state->current_layout, target_layout);
          att_state->aux_usage =
             anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
-                                    image->aspects, target_layout);
+                                    VK_IMAGE_ASPECT_DEPTH_BIT, target_layout);
       } else if (image->aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
          transition_color_buffer(cmd_buffer, image,
                                  iview->isl.base_level, 1,