<div dir="ltr"><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">Until now fast clear has been supported only for non-layered and<br>
non-mipmapped buffers. However, from gen8 onwards there is hardware<br>
support also for layered/mipmapped. Once this is enabled, fast clear<br>
operations target specific layer/level and call for the state to be<br>
tracked in the same granularity. This is the first step providing<br>
the details from callers to the state tracking.<br>
<br>
Patch introduces new interface for reading and writing the state<br>
hiding the upcoming bookkeeping changes in the call sites. There is<br>
bunch of sanity checks added that will be relaxed per hardware<br>
generation later on when the actual functionality is enabled.<br>
<br>
v2: Rebased on top current master setting the state in<br>
    blorp_surf_for_miptree().<br>
<br>
Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>><br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>> (v1)<br>
---<br>
 src/mesa/drivers/dri/i965/<wbr>brw_blorp.c            | 17 ++++++++----<br>
 src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c | 34 ++++++++++++++++--------<br>
 2 files changed, 35 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c b/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
index 749354e..44ae26e 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
@@ -218,7 +218,8 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
                                         *level, start_layer + i, flags);<br>
          }<br>
<br>
-         assert(mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D);<br>
+         assert(!intel_miptree_has_col<wbr>or_unresolved(mt, *level, 1,<br>
+                                                    start_layer, num_layers));<br>
          surf->aux_usage = ISL_AUX_USAGE_NONE;<br>
       }<br>
    }<br>
@@ -813,8 +814,12 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
        !brw_is_color_fast_clear_compa<wbr>tible(brw, irb->mt, &ctx->Color.ClearColor))<br>
       can_fast_clear = false;<br>
<br>
+   const unsigned logical_layer = irb_logical_mt_layer(irb);<br>
    const bool is_lossless_compressed = intel_miptree_is_lossless_comp<wbr>ressed(<br>
                                           brw, irb->mt);<br>
+   const enum intel_fast_clear_state fast_clear_state =<br>
+      intel_miptree_get_fast_clear_s<wbr>tate(irb->mt, irb->mt_level,<br>
+                                         logical_layer);<br>
<br>
    if (can_fast_clear) {<br>
       union gl_color_union override_color =<br>
@@ -846,7 +851,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
        * it is available without consulting the surface state.<br>
        */<br>
       if ((!color_updated || !is_lossless_compressed) &&<br>
-          irb->mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_CLEAR)<br>
+          fast_clear_state == INTEL_FAST_CLEAR_STATE_CLEAR)<br>
          return true;<br>
<br>
       /* If the MCS buffer hasn't been allocated yet, we need to allocate<br>
@@ -864,7 +869,6 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
       }<br>
    }<br>
<br>
-   const unsigned logical_layer = irb_logical_mt_layer(irb);<br>
    const unsigned num_layers = fb->MaxNumLayers ? irb->layer_count : 1;<br>
<br>
    /* We can't setup the blorp_surf until we've allocated the MCS above */<br>
@@ -893,7 +897,9 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
        * INTEL_FAST_CLEAR_STATE_CLEAR so that we won't waste time doing<br>
        * redundant clears.<br>
        */<br>
-      irb->mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_CLEAR;<br>
+      intel_miptree_set_fast_clear_s<wbr>tate(irb->mt, irb->mt_level,<br>
+                                         logical_layer, num_layers,<br>
+                                         INTEL_FAST_CLEAR_STATE_CLEAR)<wbr>;<br>
    } else {<br>
       DBG("%s (slow) to mt %p level %d layer %d+%d\n", __FUNCTION__,<br>
           irb->mt, irb->mt_level, irb->mt_layer, num_layers);<br>
@@ -980,7 +986,8 @@ brw_blorp_resolve_color(struct brw_context *brw, struct intel_mipmap_tree *mt,<br>
                      resolve_op);<br>
    blorp_batch_finish(&batch);<br>
<br>
-   mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D;<br>
+   intel_miptree_set_fast_clear_<wbr>state(mt, level, layer, 1,<br>
+                                      INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D);<br>
 }<br>
<br>
 static void<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
index ec434c7..7fc0d0c 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
@@ -441,20 +441,24 @@ brw_find_matching_rb(const struct gl_framebuffer *fb,<br>
<br>
 static inline bool<br>
 brw_texture_view_sane(const struct brw_context *brw,<br>
-                      const struct intel_mipmap_tree *mt, unsigned format)<br>
+                      const struct intel_mipmap_tree *mt,<br>
+                      const struct isl_view *view)<br>
 {<br>
    /* There are special cases only for lossless compression. */<br>
    if (!intel_miptree_is_lossless_co<wbr>mpressed(brw, mt))<br>
       return true;<br>
<br>
    if (isl_format_supports_lossless_<wbr>compression(&brw->screen->devi<wbr>nfo,<br>
-                                                format))<br>
+                                                view->format))<br>
       return true;<br>
<br>
    /* Logic elsewhere needs to take care to resolve the color buffer prior<br>
     * to sampling it as non-compressed.<br>
     */<br>
-   if (mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D)<br>
+   const enum intel_fast_clear_state fast_clear_state =<br>
+      intel_miptree_get_fast_clear_s<wbr>tate(mt, view->base_level,<br>
+                                         view->base_array_layer);<br></blockquote><div><br></div><div>Do you want has_color_unresolved here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+   if (fast_clear_state != INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D)<br>
       return false;<br>
<br>
    const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;<br>
@@ -473,15 +477,20 @@ brw_texture_view_sane(const struct brw_context *brw,<br>
<br>
 static bool<br>
 brw_disable_aux_surface(const struct brw_context *brw,<br>
-                        const struct intel_mipmap_tree *mt)<br>
+                        const struct intel_mipmap_tree *mt,<br>
+                        const struct isl_view *view)<br>
 {<br>
    /* Nothing to disable. */<br>
    if (!mt->mcs_buf)<br>
       return false;<br>
<br>
+   const bool is_unresolved = intel_miptree_has_color_unreso<wbr>lved(<br>
+                                 mt, view->base_level, view->levels,<br>
+                                 view->base_array_layer, view->array_len);<br>
+<br>
    /* There are special cases only for lossless compression. */<br>
    if (!intel_miptree_is_lossless_co<wbr>mpressed(brw, mt))<br>
-      return mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D;<br>
+      return !is_unresolved;<br>
<br>
    const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;<br>
    const unsigned rb_index = brw_find_matching_rb(fb, mt);<br>
@@ -499,13 +508,13 @@ brw_disable_aux_surface(const struct brw_context *brw,<br>
     */<br>
    if (rb_index < fb->_NumColorDrawBuffers) {<br>
       if (brw->draw_aux_buffer_disabled<wbr>[rb_index]) {<br>
-         assert(mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D);<br>
+         assert(!is_unresolved);<br>
       }<br>
<br>
       return brw->draw_aux_buffer_disabled[<wbr>rb_index];<br>
    }<br>
<br>
-   return mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D;<br>
+   return !is_unresolved;<br>
 }<br>
<br>
 void<br>
@@ -625,10 +634,10 @@ brw_update_texture_surface(str<wbr>uct gl_context *ctx,<br>
           obj->Target == GL_TEXTURE_CUBE_MAP_ARRAY)<br>
          view.usage |= ISL_SURF_USAGE_CUBE_BIT;<br>
<br>
-      assert(brw_texture_view_sane(b<wbr>rw, mt, format));<br>
+      assert(brw_texture_view_sane(b<wbr>rw, mt, &view));<br>
<br>
-      const int flags =<br>
-         brw_disable_aux_surface(brw, mt) ? INTEL_AUX_BUFFER_DISABLED : 0;<br>
+      const int flags = brw_disable_aux_surface(brw, mt, &view) ?<br>
+                           INTEL_AUX_BUFFER_DISABLED : 0;<br>
       brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
                              tex_mocs[brw->gen],<br>
                              surf_offset, surf_index,<br>
@@ -1749,8 +1758,11 @@ update_image_surface(struct brw_context *brw,<br>
             };<br>
<br>
             const int surf_index = surf_offset - &brw->wm.base.surf_offset[0];<br>
+            const enum intel_fast_clear_state fast_clear_state =<br>
+               intel_miptree_get_fast_clear_<wbr>state(mt, view.base_level,<br>
+                                                  view.base_array_layer);<br>
             const int flags =<br>
-               mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D ?<br>
+               fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVE<wbr>D ?<br></blockquote><div><br></div><div>Do you want to use has_color_unresolved here?  I think you do.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                INTEL_AUX_BUFFER_DISABLED : 0;<br>
             brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
                                    tex_mocs[brw->gen],<br>
<span class="m_-3265310095105692971HOEnZb"><font color="#888888">--<br>
2.5.5<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>