<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 3, 2018 at 12:03 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">Before this patch, if we failed to initialize an MCS buffer, we'd<br>
end up in a state in which the miptree thinks it has an MCS buffer,<br>
but doesn't. We also leaked the clear_color_bo if it existed.<br>
<br>
With this patch, we now free the miptree aux buffer resources and let<br>
intel_miptree_alloc_mcs() know that the MCS buffer no longer exists.<br>
<br>
Cc: <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 14 +++++++-------<br>
1 file changed, 7 insertions(+), 7 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 b9a564552df..377efae32c9 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>
@@ -1658,7 +1658,7 @@ intel_miptree_copy_teximage(<wbr>struct brw_context *brw,<br>
intel_obj->needs_validate = true;<br>
}<br>
<br>
-static void<br>
+static bool<br>
intel_miptree_init_mcs(struct brw_context *brw,<br>
struct intel_mipmap_tree *mt,<br>
int init_value)<br>
@@ -1678,13 +1678,14 @@ intel_miptree_init_mcs(struct brw_context *brw,<br>
void *map = brw_bo_map(brw, mt->aux_buf->bo, MAP_WRITE | MAP_RAW);<br>
if (unlikely(map == NULL)) {<br>
fprintf(stderr, "Failed to map mcs buffer into GTT\n");<br>
- brw_bo_unreference(mt->aux_<wbr>buf->bo);<br>
- free(mt->aux_buf);<br>
- return;<br>
+ intel_miptree_aux_buffer_free(<wbr>mt->aux_buf);<br>
+ mt->aux_buf = NULL;<br>
+ return false;<br>
}<br>
void *data = map;<br>
memset(data, init_value, mt->aux_buf->size);<br>
brw_bo_unmap(mt->aux_buf->bo);<br>
+ return true;<br>
}<br>
<br>
static struct intel_miptree_aux_buffer *<br>
@@ -1764,15 +1765,14 @@ intel_miptree_alloc_mcs(struct brw_context *brw,<br>
const uint32_t alloc_flags = 0;<br>
mt->aux_buf = intel_alloc_aux_buffer(brw, "mcs-miptree",<br>
&temp_mcs_surf, alloc_flags, mt);<br>
- if (!mt->aux_buf) {<br>
+ if (!mt->aux_buf ||<br>
+ !intel_miptree_init_mcs(brw, mt, 0xFF)) {<br></blockquote><div><br></div><div>You're leaking mt->aux_buf here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
free(aux_state);<br>
return false;<br>
}<br>
<br>
mt->aux_state = aux_state;<br>
<br>
- intel_miptree_init_mcs(brw, mt, 0xFF);<br>
-<br>
return true;<br>
}<br>
<span class="HOEnZb"><font color="#888888"> <br>
-- <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></div>