<div dir="ltr">General comment: Does it make sense to squash this with the previous patch?  I'm fine either way.<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 23, 2016 at 1:16 AM, Topi Pohjolainen <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@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: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>blorp.c         | 15 +++++++++------<br>
 src/mesa/drivers/dri/i965/brw_<wbr>blorp.h         |  3 ++-<br>
 src/mesa/drivers/dri/i965/brw_<wbr>context.c       | 14 +++++++++-----<br>
 src/mesa/drivers/dri/i965/<wbr>intel_blit.c        |  4 ++--<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 27 +++++++++++++++++++++++++--<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h |  1 +<br>
 6 files changed, 48 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
index 9a849f5..99df21e 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
@@ -213,7 +213,10 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
          if (safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E))<br>
             flags |= INTEL_MIPTREE_IGNORE_CCS_E;<br>
<br>
-         intel_miptree_resolve_color(<wbr>brw, mt, flags);<br>
+         for (unsigned i = 0; i < num_layers; i++) {<br>
+            intel_miptree_resolve_color(<wbr>brw, mt,<br>
+                                        *level, start_layer + i, flags);<br>
+         }<br>
<br>
          assert(mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_<wbr>RESOLVED);<br>
          surf->aux_usage = ISL_AUX_USAGE_NONE;<br>
@@ -942,19 +945,19 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,<br>
 }<br>
<br>
 void<br>
-brw_blorp_resolve_color(<wbr>struct brw_context *brw, struct intel_mipmap_tree *mt)<br>
+brw_blorp_resolve_color(<wbr>struct brw_context *brw, struct intel_mipmap_tree *mt,<br>
+                        unsigned level, unsigned layer)<br>
 {<br>
-   DBG("%s to mt %p\n", __FUNCTION__, mt);<br>
+   DBG("%s to mt %p level %u layer %u\n", __FUNCTION__, mt, level, layer);<br>
<br>
    const mesa_format format = _mesa_get_srgb_format_linear(<wbr>mt->format);<br>
<br>
    struct isl_surf isl_tmp[2];<br>
    struct blorp_surf surf;<br>
-   unsigned level = 0;<br>
    blorp_surf_for_miptree(brw, &surf, mt, true,<br>
                           (1 << ISL_AUX_USAGE_CCS_E) |<br>
                           (1 << ISL_AUX_USAGE_CCS_D),<br>
-                          &level, 0 /* start_layer */, 1 /* num_layers */,<br>
+                          &level, layer, 1 /* num_layers */,<br>
                           isl_tmp);<br>
<br>
    enum blorp_fast_clear_op resolve_op;<br>
@@ -971,7 +974,7 @@ brw_blorp_resolve_color(struct brw_context *brw, struct intel_mipmap_tree *mt)<br>
<br>
    struct blorp_batch batch;<br>
    blorp_batch_init(&brw->blorp, &batch, brw, 0);<br>
-   blorp_ccs_resolve(&batch, &surf, 0 /* level */, 0 /* layer */,<br>
+   blorp_ccs_resolve(&batch, &surf, level, layer,<br>
                      brw_blorp_to_isl_format(brw, format, true),<br>
                      resolve_op);<br>
    blorp_batch_finish(&batch);<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h<br>
index abf3956..277b00e 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h<br>
@@ -64,7 +64,8 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,<br>
<br>
 void<br>
 brw_blorp_resolve_color(struct brw_context *brw,<br>
-                        struct intel_mipmap_tree *mt);<br>
+                        struct intel_mipmap_tree *mt,<br>
+                        unsigned level, unsigned layer);<br></blockquote><div><br></div><div>Would it be better to make this start_layer and num_layers and do the looping in blorp?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
 void<br>
 intel_hiz_exec(struct brw_context *brw, struct intel_mipmap_tree *mt,<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_context.c b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
index 3f88f7f..b0e762b 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
@@ -316,8 +316,9 @@ intel_update_state(struct gl_context * ctx, GLuint new_state)<br>
             intel_renderbuffer(fb->_<wbr>ColorDrawBuffers[i]);<br>
<br>
          if (irb &&<br>
-             intel_miptree_resolve_color(<wbr>brw, irb->mt,<br>
-                                         INTEL_MIPTREE_IGNORE_CCS_E))<br>
+             intel_miptree_resolve_color(<br>
+                brw, irb->mt, irb->mt_level, irb->mt_layer,<br>
+                INTEL_MIPTREE_IGNORE_CCS_E))<br></blockquote><div><br></div><div>Do you need to loop here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
             brw_render_cache_set_check_<wbr>flush(brw, irb->mt->bo);<br>
       }<br>
    }<br>
@@ -1349,10 +1350,13 @@ intel_resolve_for_dri2_flush(<wbr>struct brw_context *brw,<br>
       rb = intel_get_renderbuffer(fb, buffers[i]);<br>
       if (rb == NULL || rb->mt == NULL)<br>
          continue;<br>
-      if (rb->mt->num_samples <= 1)<br>
-         intel_miptree_resolve_color(<wbr>brw, rb->mt, 0);<br>
-      else<br>
+      if (rb->mt->num_samples <= 1) {<br>
+         assert(rb->mt_layer == 0 && rb->mt_level == 0 &&<br>
+                rb->layer_count == 1);<br>
+         intel_miptree_resolve_color(<wbr>brw, rb->mt, 0, 0, 0);<br>
+      } else {<br>
          intel_renderbuffer_downsample(<wbr>brw, rb);<br>
+      }<br>
    }<br>
 }<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
index 7e97fbc..a4e1216 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
@@ -294,8 +294,8 @@ intel_miptree_blit(struct brw_context *brw,<br>
     */<br>
    intel_miptree_slice_resolve_<wbr>depth(brw, src_mt, src_level, src_slice);<br>
    intel_miptree_slice_resolve_<wbr>depth(brw, dst_mt, dst_level, dst_slice);<br>
-   intel_miptree_resolve_color(<wbr>brw, src_mt, 0);<br>
-   intel_miptree_resolve_color(<wbr>brw, dst_mt, 0);<br>
+   intel_miptree_resolve_color(<wbr>brw, src_mt, src_level, src_slice, 0);<br>
+   intel_miptree_resolve_color(<wbr>brw, dst_mt, dst_level, dst_slice, 0);<br>
<br>
    if (src_flip)<br>
       src_y = minify(src_mt->physical_<wbr>height0, src_level - src_mt->first_level) - src_y - height;<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
index 328c770..8482afe 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
@@ -2203,12 +2203,35 @@ intel_miptree_all_slices_<wbr>resolve_depth(struct brw_context *brw,<br>
                                           BLORP_HIZ_OP_DEPTH_RESOLVE);<br>
 }<br>
<br>
+static void<br>
+intel_miptree_check_color_<wbr>resolve(const struct intel_mipmap_tree *mt,<br>
+                                  unsigned level, unsigned layer)<br>
+{<br>
+   if (!mt->mcs_buf)<br>
+      return;<br>
+<br>
+   /* Fast color clear is not supported for mipmapped surfaces. */<br>
+   assert(level == 0 && mt->first_level == 0 && mt->last_level == 0);<br>
+<br>
+   /* Compression of arrayed msaa surfaces is supported. */<br>
+   if (mt->num_samples > 1)<br>
+      return;<br>
+<br>
+   /* Fast color clear is not supported for non-msaa arrays. */<br>
+   assert(layer == 0 && mt->logical_depth0 == 1);<br></blockquote><div><br></div><div>Is this a hardware limitation or a software limitation?  If it's a hardware limitation, I'd like a PRM citation or something to explain why.  This seems to me like something that should totally be possible.  If there are any layered rendering tests in the Vulkan CTS (I think there are but I'm not sure), then it's definitely possible.  I just kicked off a Jenkins run to find out.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+   (void)level;<br>
+   (void)layer;<br>
+}<br>
<br>
 bool<br>
 intel_miptree_resolve_color(<wbr>struct brw_context *brw,<br>
                             struct intel_mipmap_tree *mt,<br>
+                            unsigned level, unsigned layer,<br>
                             int flags)<br>
 {<br>
+   intel_miptree_check_color_<wbr>resolve(mt, level, layer);<br>
+<br>
    /* From gen9 onwards there is new compression scheme for single sampled<br>
     * surfaces called "lossless compressed". These don't need to be always<br>
     * resolved.<br>
@@ -2227,7 +2250,7 @@ intel_miptree_resolve_color(<wbr>struct brw_context *brw,<br>
       /* Fast color clear resolves only make sense for non-MSAA buffers. */<br>
       if (mt->msaa_layout == INTEL_MSAA_LAYOUT_NONE ||<br>
           intel_miptree_is_lossless_<wbr>compressed(brw, mt)) {<br>
-         brw_blorp_resolve_color(brw, mt);<br>
+         brw_blorp_resolve_color(brw, mt, level, layer);<br>
          return true;<br>
       } else {<br>
          return false;<br>
@@ -2242,7 +2265,7 @@ intel_miptree_all_slices_<wbr>resolve_color(struct brw_context *brw,<br>
                                        struct intel_mipmap_tree *mt,<br>
                                        int flags)<br>
 {<br>
-   intel_miptree_resolve_color(<wbr>brw, mt, flags);<br>
+   intel_miptree_resolve_color(<wbr>brw, mt, 0, 0, flags);<br>
 }<br>
<br>
 /**<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
index 80cc876..95d9dad 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
@@ -991,6 +991,7 @@ intel_miptree_used_for_<wbr>rendering(const struct brw_context *brw,<br>
 bool<br>
 intel_miptree_resolve_color(<wbr>struct brw_context *brw,<br>
                             struct intel_mipmap_tree *mt,<br>
+                            unsigned level, unsigned layer,<br>
                             int flags);<br>
<br>
 void<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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>