<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Thanks for noticing this. I actually had a patch to handle this that must have gotten lost in my rebasing efforts. I'll send it in the v2.
<br>
<br>
My email isn't working properly, so sorry for any formatting errors.<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF79341" style="direction: ltr;"><font size="2" face="Tahoma" color="#000000"><b>From:</b> Jason Ekstrand [jason@jlekstrand.net]<br>
<b>Sent:</b> Thursday, January 12, 2017 10:38 AM<br>
<b>To:</b> Nanley Chery<br>
<b>Cc:</b> mesa-dev@lists.freedesktop.org; Chery, Nanley G<br>
<b>Subject:</b> Re: [Mesa-dev] [PATCH 21/22] anv: Enable sampling from HiZ<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Jan 11, 2017 at 5:55 PM, Nanley Chery <span dir="ltr">
<<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com" target="_blank">nanley.g.chery@intel.com</a>><br>
---<br>
 src/intel/vulkan/TODO        |  1 -<br>
 src/intel/vulkan/anv_image.c | 19 ++++++++++++++++---<br>
 2 files changed, 16 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/TODO b/src/intel/vulkan/TODO<br>
index 37fd16b437..38acc0dd5b 100644<br>
--- a/src/intel/vulkan/TODO<br>
+++ b/src/intel/vulkan/TODO<br>
@@ -8,7 +8,6 @@ Missing Features:<br>
  - Sparse memory<br>
<br>
 Performance:<br>
- - Sampling from HiZ (Nanley)<br>
  - Multi-{sampled/gen8,LOD} HiZ<br>
  - Compressed multisample support<br>
  - Pushing pieces of UBOs?<br>
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c<br>
index 7d5beeabbe..ee563685bb 100644<br>
--- a/src/intel/vulkan/anv_image.c<br>
+++ b/src/intel/vulkan/anv_image.c<br>
@@ -538,10 +538,22 @@ anv_CreateImageView(VkDevice _device,<br>
       iview->isl.usage = 0;<br>
    }<br>
<br>
-   /* Sampling from HiZ is not yet enabled */<br>
+   /* If the HiZ buffer can be sampled from, set the constant clear color.<br>
+    * If it cannot, disable the isl aux usage flag.<br>
+    */<br>
+   float red_clear_color = 0.0f;<br>
    enum isl_aux_usage surf_usage = image->aux_usage;<br>
-   if (surf_usage == ISL_AUX_USAGE_HIZ)<br>
-      surf_usage = ISL_AUX_USAGE_NONE;<br>
+   if (image->aux_usage == ISL_AUX_USAGE_HIZ) {<br>
+      if (anv_can_sample_with_hiz(<wbr>device->info.gen, image->samples)) {<br>
+         /* When a HiZ buffer is sampled on gen9+, ensure that<br>
+          * the constant fast clear value is set in the surface state.<br>
+          */<br>
+         if (device->info.gen >= 9)<br>
+            red_clear_color = ANV_HZ_FC_VAL;<br>
+      } else {<br>
+         surf_usage = ISL_AUX_USAGE_NONE;<br>
+      }<br>
+   }<br>
</blockquote>
<div><br>
</div>
<div>I realized this morning that this doesn't actually do everything we need.  If we're going to use a layout-based approach to HiZ, we need two surface states, one with HiZ and one without and we need to select which one to put in the binding table based
 on layout.  Otherwise, if they sample from an image in LAYOUT_GENERAL and the HiZ data doesn't match the depth data, we'll get the wrong values.  I don't think this will be all that hard to solve, but we should solve it.<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<br>
    /* Input attachment surfaces for color are allocated and filled<br>
     * out at BeginRenderPass time because they need compression information.<br>
@@ -560,6 +572,7 @@ anv_CreateImageView(VkDevice _device,<br>
                           iview->sampler_surface_state.<wbr>map,<br>
                           .surf = &surface->isl,<br>
                           .view = &view,<br>
+                          .clear_color.f32 = { red_clear_color,},<br>
                           .aux_surf = &image->aux_surface.isl,<br>
                           .aux_usage = surf_usage,<br>
                           .mocs = device->default_mocs);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>