<div dir="ltr"><div>Why is this useful in light of patch 4?  I don't mean to be overly critical but the main purpose of this helper seems to be to deal with the fact that we have two different fields.  If it's just one field, why the helper?<br><br></div>--Jason<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 11, 2018 at 1:42 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">Make the next patch easier to read by eliminating most of the would-be<br>
duplicate field accesses now.<br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>blorp.c            |  8 ++------<br>
 src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c | 16 +---------------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c    | 24 ++++--------------------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h    | 17 +++++++++++++++++<br>
 4 files changed, 24 insertions(+), 41 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 5dcd95e9f44..962a316c5cf 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
@@ -154,12 +154,6 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
       .aux_usage = aux_usage,<br>
    };<br>
<br>
-   struct intel_miptree_aux_buffer *aux_buf = NULL;<br>
-   if (mt->mcs_buf)<br>
-      aux_buf = mt->mcs_buf;<br>
-   else if (mt->hiz_buf)<br>
-      aux_buf = mt->hiz_buf;<br>
-<br>
    if (mt->format == MESA_FORMAT_S_UINT8 && is_render_target &&<br>
        devinfo->gen <= 7)<br>
       mt->r8stencil_needs_update = true;<br>
@@ -174,6 +168,8 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
        */<br>
       surf->clear_color = mt->fast_clear_color;<br>
<br>
+      struct intel_miptree_aux_buffer *aux_buf =<br>
+         intel_miptree_get_aux_buffer(<wbr>mt);<br>
       surf->aux_surf = &aux_buf->surf;<br>
       surf->aux_addr = (struct blorp_address) {<br>
          .reloc_flags = is_render_target ? EXEC_OBJECT_WRITE : 0,<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
index 3fb101bf68b..06f739faf61 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
@@ -155,21 +155,7 @@ brw_emit_surface_state(struct brw_context *brw,<br>
    struct brw_bo *aux_bo = NULL;<br>
    struct isl_surf *aux_surf = NULL;<br>
    uint64_t aux_offset = 0;<br>
-   struct intel_miptree_aux_buffer *aux_buf = NULL;<br>
-   switch (aux_usage) {<br>
-   case ISL_AUX_USAGE_MCS:<br>
-   case ISL_AUX_USAGE_CCS_D:<br>
-   case ISL_AUX_USAGE_CCS_E:<br>
-      aux_buf = mt->mcs_buf;<br>
-      break;<br>
-<br>
-   case ISL_AUX_USAGE_HIZ:<br>
-      aux_buf = mt->hiz_buf;<br>
-      break;<br>
-<br>
-   case ISL_AUX_USAGE_NONE:<br>
-      break;<br>
-   }<br>
+   struct intel_miptree_aux_buffer *aux_buf = intel_miptree_get_aux_buffer(<wbr>mt);<br>
<br>
    if (aux_usage != ISL_AUX_USAGE_NONE) {<br>
       aux_surf = &aux_buf->surf;<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 d95128de119..ba5b02bc0aa 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>
@@ -1249,8 +1249,7 @@ intel_miptree_release(struct intel_mipmap_tree **mt)<br>
       brw_bo_unreference((*mt)->bo);<br>
       intel_miptree_release(&(*mt)-><wbr>stencil_mt);<br>
       intel_miptree_release(&(*mt)-><wbr>r8stencil_mt);<br>
-      intel_miptree_aux_buffer_free(<wbr>(*mt)->hiz_buf);<br>
-      intel_miptree_aux_buffer_free(<wbr>(*mt)->mcs_buf);<br>
+      intel_miptree_aux_buffer_free(<wbr>intel_miptree_get_aux_buffer(*<wbr>mt));<br>
       free_aux_state_map((*mt)->aux_<wbr>state);<br>
<br>
       intel_miptree_release(&(*mt)-><wbr>plane[0]);<br>
@@ -2876,31 +2875,16 @@ intel_miptree_make_shareable(<wbr>struct brw_context *brw,<br>
                                 0, INTEL_REMAINING_LAYERS,<br>
                                 ISL_AUX_USAGE_NONE, false);<br>
<br>
-   if (mt->mcs_buf) {<br>
-      intel_miptree_aux_buffer_free(<wbr>mt->mcs_buf);<br>
+   struct intel_miptree_aux_buffer *aux_buf = intel_miptree_get_aux_buffer(<wbr>mt);<br>
+   if (aux_buf) {<br>
+      intel_miptree_aux_buffer_free(<wbr>aux_buf);<br>
       mt->mcs_buf = NULL;<br>
-<br>
-      /* Any pending MCS/CCS operations are no longer needed. Trying to<br>
-       * execute any will likely crash due to the missing aux buffer. So let's<br>
-       * delete all pending ops.<br>
-       */<br>
-      free(mt->aux_state);<br>
-      mt->aux_state = NULL;<br>
-      brw->ctx.NewDriverState |= BRW_NEW_AUX_STATE;<br>
-   }<br>
-<br>
-   if (mt->hiz_buf) {<br>
-      intel_miptree_aux_buffer_free(<wbr>mt->hiz_buf);<br>
       mt->hiz_buf = NULL;<br>
<br>
       for (uint32_t l = mt->first_level; l <= mt->last_level; ++l) {<br>
          mt->level[l].has_hiz = false;<br>
       }<br>
<br>
-      /* Any pending HiZ operations are no longer needed. Trying to execute<br>
-       * any will likely crash due to the missing aux buffer. So let's delete<br>
-       * all pending ops.<br>
-       */<br>
       free(mt->aux_state);<br>
       mt->aux_state = NULL;<br>
       brw->ctx.NewDriverState |= BRW_NEW_AUX_STATE;<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 2f754427fc5..8fe5c4add67 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>
@@ -485,6 +485,23 @@ enum isl_dim_layout<br>
 get_isl_dim_layout(const struct gen_device_info *devinfo,<br>
                    enum isl_tiling tiling, GLenum target);<br>
<br>
+static inline struct intel_miptree_aux_buffer *<br>
+intel_miptree_get_aux_buffer(<wbr>const struct intel_mipmap_tree *mt)<br>
+{<br>
+   switch (mt->aux_usage) {<br>
+   case ISL_AUX_USAGE_MCS:<br>
+   case ISL_AUX_USAGE_CCS_D:<br>
+   case ISL_AUX_USAGE_CCS_E:<br>
+      return mt->mcs_buf;<br>
+   case ISL_AUX_USAGE_HIZ:<br>
+      return mt->hiz_buf;<br>
+   case ISL_AUX_USAGE_NONE:<br>
+      return NULL;<br>
+   default:<br>
+      unreachable("Invalid aux_usage!\n");<br>
+   }<br>
+}<br>
+<br>
 void<br>
 intel_get_image_dims(struct gl_texture_image *image,<br>
                      int *width, int *height, int *depth);<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.16.2<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>