anv: Disable HiZ for input attachments
authorNanley Chery <nanley.g.chery@intel.com>
Wed, 11 Jan 2017 23:12:35 +0000 (15:12 -0800)
committerNanley Chery <nanley.g.chery@intel.com>
Fri, 13 Jan 2017 04:52:20 +0000 (20:52 -0800)
v2 (Jason Ekstrand):
- Add spec citation
- Drop conditional

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_image.c
src/intel/vulkan/genX_cmd_buffer.c

index d8216291914b361c0b57b3194ca8e1adcdf38459..e21374b1abcb480098f01be5bab5b0b2c343b420 100644 (file)
@@ -182,6 +182,20 @@ make_surface(const struct anv_device *dev,
        */
       if (!(image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
          /* It will never be used as an attachment, HiZ is pointless. */
+      } else if (image->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) {
+         /* From the 1.0.37 spec:
+          *
+          *    "An attachment used as an input attachment and depth/stencil
+          *    attachment must be in either VK_IMAGE_LAYOUT_GENERAL or
+          *    VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL."
+          *
+          * It will never have a layout of
+          * VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, so HiZ is
+          * currently pointless. If transfer operations learn to use the HiZ
+          * buffer, we can enable HiZ for VK_IMAGE_LAYOUT_GENERAL and support
+          * input attachments.
+          */
+         anv_finishme("Implement HiZ for input attachments");
       } else if (!env_var_as_boolean("INTEL_VK_HIZ", dev->info.gen >= 8)) {
          anv_finishme("Implement gen7 HiZ");
       } else if (vk_info->mipLevels > 1) {
@@ -529,14 +543,15 @@ anv_CreateImageView(VkDevice _device,
    if (surf_usage == ISL_AUX_USAGE_HIZ)
       surf_usage = ISL_AUX_USAGE_NONE;
 
-   /* Input attachment surfaces for color or depth are allocated and filled
+   /* Input attachment surfaces for color are allocated and filled
     * out at BeginRenderPass time because they need compression information.
-    * Stencil image do not support compression so we just use the texture
-    * surface from the image view.
+    * Compression is not yet enabled for depth textures and stencil doesn't
+    * allow compression so we can just use the texture surface state from the
+    * view.
     */
    if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT ||
        (image->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
-        (iview->aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT))) {
+        !(iview->aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT))) {
       iview->sampler_surface_state = alloc_surface_state(device);
 
       struct isl_view view = iview->isl;
index baa932e51719fcec89418d9fddd850bf8b4bfa58..05f29ee57cce3df7f9983b99936189a97fc201f0 100644 (file)
@@ -303,11 +303,11 @@ need_input_attachment_state(const struct anv_render_pass_attachment *att)
    if (!(att->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))
       return false;
 
-   /* We only allocate input attachment states for color and depth surfaces.
-    * Stencil doesn't allow compression so we can just use the texture surface
-    * state from the view
+   /* We only allocate input attachment states for color surfaces. Compression
+    * is not yet enabled for depth textures and stencil doesn't allow
+    * compression so we can just use the texture surface state from the view.
     */
-   return vk_format_is_color(att->format) || vk_format_has_depth(att->format);
+   return vk_format_is_color(att->format);
 }
 
 static enum isl_aux_usage
@@ -515,18 +515,11 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
          }
 
          if (need_input_attachment_state(&pass->attachments[i])) {
-            const struct isl_surf *surf;
-            if (att_aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
-               surf = &iview->image->color_surface.isl;
-            } else {
-               surf = &iview->image->depth_surface.isl;
-            }
-
             struct isl_view view = iview->isl;
             view.usage |= ISL_SURF_USAGE_TEXTURE_BIT;
             isl_surf_fill_state(isl_dev,
                                 state->attachments[i].input_att_state.map,
-                                .surf = surf,
+                                .surf = &iview->image->color_surface.isl,
                                 .view = &view,
                                 .aux_surf = &iview->image->aux_surface.isl,
                                 .aux_usage = state->attachments[i].input_aux_usage,