anv: Enable sampling from HiZ
authorNanley Chery <nanley.g.chery@intel.com>
Wed, 11 Jan 2017 16:12:48 +0000 (08:12 -0800)
committerNanley Chery <nanley.g.chery@intel.com>
Fri, 13 Jan 2017 04:52:21 +0000 (20:52 -0800)
v2: Restrict ISL_AUX_USAGE_HIZ to depth aspects

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

index 37fd16b4372b972097a7800ce51bc8d983e02726..38acc0dd5b6cac76f012906cd4971b66ff04aea3 100644 (file)
@@ -8,7 +8,6 @@ Missing Features:
  - Sparse memory
 
 Performance:
- - Sampling from HiZ (Nanley)
  - Multi-{sampled/gen8,LOD} HiZ
  - Compressed multisample support
  - Pushing pieces of UBOs?
index e21374b1abcb480098f01be5bab5b0b2c343b420..9e5cebe1889d571d8d290c280caf06fba9ec95f7 100644 (file)
@@ -538,10 +538,23 @@ anv_CreateImageView(VkDevice _device,
       iview->isl.usage = 0;
    }
 
-   /* Sampling from HiZ is not yet enabled */
+   /* 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 (surf_usage == ISL_AUX_USAGE_HIZ)
-      surf_usage = ISL_AUX_USAGE_NONE;
+   if (image->aux_usage == ISL_AUX_USAGE_HIZ) {
+      if (iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT &&
+          anv_can_sample_with_hiz(device->info.gen, 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.
@@ -560,6 +573,7 @@ anv_CreateImageView(VkDevice _device,
                           iview->sampler_surface_state.map,
                           .surf = &surface->isl,
                           .view = &view,
+                          .clear_color.f32 = { red_clear_color,},
                           .aux_surf = &image->aux_surface.isl,
                           .aux_usage = surf_usage,
                           .mocs = device->default_mocs);