Mesa (master): anv/image: Simplify setup of HiZ sampler surface state

Nanley Chery nchery at kemper.freedesktop.org
Thu Mar 2 21:18:27 UTC 2017


Module: Mesa
Branch: master
Commit: f3621f4e71a68aae76093ee2232d4027057c2e19
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3621f4e71a68aae76093ee2232d4027057c2e19

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Thu Feb 23 10:02:17 2017 -0800

anv/image: Simplify setup of HiZ sampler surface state

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/intel/vulkan/anv_image.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 0c41ed3..16a6083 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -682,24 +682,6 @@ anv_CreateImageView(VkDevice _device,
       iview->isl.usage = 0;
    }
 
-   /* If the HiZ buffer can be sampled from, set the constant clear color.
-    * If it cannot, disable the isl aux usage flag.
-    */
-   float red_clear_color = 0.0f;
-   enum isl_aux_usage surf_usage = image->aux_usage;
-   if (image->aux_usage == ISL_AUX_USAGE_HIZ) {
-      if (anv_can_sample_with_hiz(&device->info, iview->aspect_mask,
-                                  image->samples)) {
-         /* When a HiZ buffer is sampled on gen9+, ensure that
-          * the constant fast clear value is set in the surface state.
-          */
-         if (device->info.gen >= 9)
-            red_clear_color = ANV_HZ_FC_VAL;
-      } else {
-         surf_usage = ISL_AUX_USAGE_NONE;
-      }
-   }
-
    /* Input attachment surfaces for color are allocated and filled
     * out at BeginRenderPass time because they need compression information.
     * Compression is not yet enabled for depth textures and stencil doesn't
@@ -711,6 +693,18 @@ anv_CreateImageView(VkDevice _device,
         !(iview->aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT))) {
       iview->sampler_surface_state = alloc_surface_state(device);
 
+      /* Select the optimal aux_usage for sampling. */
+      const enum isl_aux_usage surf_usage =
+         anv_layout_to_aux_usage(&device->info, image, iview->aspect_mask,
+                                 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+
+      /* If this is a HiZ buffer we can sample from with a programmable clear
+       * value (SKL+), define the clear value to the optimal constant.
+       */
+      const float red_clear_color = surf_usage == ISL_AUX_USAGE_HIZ &&
+                                    device->info.gen >= 9 ?
+                                    ANV_HZ_FC_VAL : 0.0f;
+
       struct isl_view view = iview->isl;
       view.usage |= ISL_SURF_USAGE_TEXTURE_BIT;
       isl_surf_fill_state(&device->isl_dev,




More information about the mesa-commit mailing list