summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNanley Chery <[email protected]>2018-04-30 10:40:18 -0700
committerDylan Baker <[email protected]>2018-05-30 16:56:47 -0700
commit66fa6eceb9bea83b1428c2c36c983b3c0d60c22e (patch)
tree8c41b6623ef5916dcd746a68684e101ada67544a
parent21d51b4cea081b4828410de6e6e617c3a544e701 (diff)
i965/miptree: Fix handling of uninitialized MCS buffers
Before this patch, if we failed to initialize an MCS buffer, we'd end up in a state in which the miptree thinks it has an MCS buffer, but doesn't. We also leaked the clear_color_bo if it existed. With this patch, we now free the miptree aux buffer resources and let intel_miptree_alloc_mcs() know that the MCS buffer no longer exists. Cc: <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> (cherry picked from commit 816f2dc67da72be8993e724aeda4c2ec2f5a2978)
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 139f3f0c194..654120987ce 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1655,7 +1655,7 @@ intel_miptree_copy_teximage(struct brw_context *brw,
intel_obj->needs_validate = true;
}
-static void
+static bool
intel_miptree_init_mcs(struct brw_context *brw,
struct intel_mipmap_tree *mt,
int init_value)
@@ -1675,13 +1675,14 @@ intel_miptree_init_mcs(struct brw_context *brw,
void *map = brw_bo_map(brw, mt->aux_buf->bo, MAP_WRITE | MAP_RAW);
if (unlikely(map == NULL)) {
fprintf(stderr, "Failed to map mcs buffer into GTT\n");
- brw_bo_unreference(mt->aux_buf->bo);
- free(mt->aux_buf);
- return;
+ intel_miptree_aux_buffer_free(mt->aux_buf);
+ mt->aux_buf = NULL;
+ return false;
}
void *data = map;
memset(data, init_value, mt->aux_buf->size);
brw_bo_unmap(mt->aux_buf->bo);
+ return true;
}
static struct intel_miptree_aux_buffer *
@@ -1761,15 +1762,14 @@ intel_miptree_alloc_mcs(struct brw_context *brw,
const uint32_t alloc_flags = 0;
mt->aux_buf = intel_alloc_aux_buffer(brw, "mcs-miptree",
&temp_mcs_surf, alloc_flags, mt);
- if (!mt->aux_buf) {
+ if (!mt->aux_buf ||
+ !intel_miptree_init_mcs(brw, mt, 0xFF)) {
free(aux_state);
return false;
}
mt->aux_state = aux_state;
- intel_miptree_init_mcs(brw, mt, 0xFF);
-
return true;
}