<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 13, 2017 at 7:53 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">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> (v1)<br>
Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 64 +++++++++++++++++----------<br>
 1 file changed, 41 insertions(+), 23 deletions(-)<br>
<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 4dbf853eee..0a86d3401d 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>
@@ -1648,6 +1648,41 @@ intel_mcs_miptree_buf_create(<wbr>struct brw_context *brw,<br>
    return buf;<br>
 }<br>
<br>
+static struct intel_miptree_aux_buffer *<br>
+intel_alloc_aux_buffer(struct brw_context *brw,<br>
+                       const char *name,<br>
+                       const struct isl_surf *main_surf,<br></blockquote><div><br></div><div>main_surf is unused in this function.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                       const struct isl_surf *aux_surf,<br>
+                       uint32_t alloc_flags,<br>
+                       struct intel_mipmap_tree *mt)<br>
+{<br>
+   struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1);<br>
+   if (!buf)<br>
+      return false;<br>
+<br>
+   buf->size = aux_surf->size;<br>
+   buf->pitch = aux_surf->row_pitch;<br>
+   buf->qpitch = isl_surf_get_array_pitch_sa_<wbr>rows(aux_surf);<br>
+<br>
+   unsigned pitch = aux_surf->row_pitch;<br>
+<br>
+   /* ISL has stricter set of alignment rules then the drm allocator.<br>
+    * Therefore one can pass the ISL dimensions in terms of bytes instead of<br>
+    * trying to recalculate based on different format block sizes.<br>
+    */<br>
+   buf->bo = brw_bo_alloc_tiled(brw-><wbr>bufmgr, name,<br>
+                                buf->pitch, buf->size / buf->pitch,<br>
+                                1, I915_TILING_Y, &pitch, alloc_flags);<br>
+   if (!buf->bo) {<br>
+      free(buf);<br>
+      return NULL;<br>
+   }<br>
+<br>
+   assert(pitch == buf->pitch);<br>
+<br>
+   return buf;<br>
+}<br>
+<br>
 static bool<br>
 intel_miptree_alloc_mcs(struct brw_context *brw,<br>
                         struct intel_mipmap_tree *mt,<br>
@@ -1733,20 +1768,10 @@ intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
    assert(temp_ccs_surf.size &&<br>
           (temp_ccs_surf.size % temp_ccs_surf.row_pitch == 0));<br>
<br>
-   struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1);<br>
-   if (!buf)<br>
-      return false;<br>
-<br>
    enum isl_aux_state **aux_state =<br>
       create_aux_state_map(mt, ISL_AUX_STATE_PASS_THROUGH);<br>
-   if (!aux_state) {<br>
-      free(buf);<br>
+   if (!aux_state)<br>
       return false;<br>
-   }<br>
-<br>
-   buf->size = temp_ccs_surf.size;<br>
-   buf->pitch = temp_ccs_surf.row_pitch;<br>
-   buf->qpitch = isl_surf_get_array_pitch_sa_<wbr>rows(&temp_ccs_surf);<br>
<br>
    /* In case of compression mcs buffer needs to be initialised requiring the<br>
     * buffer to be immediately mapped to cpu space for writing. Therefore do<br>
@@ -1755,21 +1780,14 @@ intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
     */<br>
    const uint32_t alloc_flags =<br>
       is_lossless_compressed ? 0 : BO_ALLOC_FOR_RENDER;<br>
-<br>
-   /* ISL has stricter set of alignment rules then the drm allocator.<br>
-    * Therefore one can pass the ISL dimensions in terms of bytes instead of<br>
-    * trying to recalculate based on different format block sizes.<br>
-    */<br>
-   buf->bo = brw_bo_alloc_tiled(brw-><wbr>bufmgr, "ccs-miptree",<br>
-                                buf->pitch, buf->size / buf->pitch,<br>
-                                1, I915_TILING_Y, &buf->pitch, alloc_flags);<br>
-   if (!buf->bo) {<br>
-      free(buf);<br>
+   mt->mcs_buf = intel_alloc_aux_buffer(brw, "ccs-miptree",<br>
+                                        &temp_main_surf, &temp_ccs_surf,<br>
+                                        alloc_flags, mt);<br>
+   if (!mt->mcs_buf) {<br>
       free(aux_state);<br>
       return false;<br>
    }<br>
-<br>
-   mt->mcs_buf = buf;<br>
+<br>
    mt->aux_state = aux_state;<br>
<br>
    /* From Gen9 onwards single-sampled (non-msrt) auxiliary buffers are<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">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>