<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 16, 2017 at 2:01 PM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
<br>
When intel_miptree_alloc_non_msrt_<wbr>mcs fails, fall back to normal blorp<br>
color clear instead of falling back to meta. With this change,<br>
brw_blorp_clear_color can never fail.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<wbr>blorp.c | 28 +++++++++++++---------------<br>
src/mesa/drivers/dri/i965/brw_<wbr>blorp.h | 2 +-<br>
src/mesa/drivers/dri/i965/brw_<wbr>clear.c | 19 ++++++++++---------<br>
3 files changed, 24 insertions(+), 25 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 24867e8..6a79984 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
@@ -725,7 +725,7 @@ irb_logical_mt_layer(struct intel_renderbuffer *irb)<br>
return physical_to_logical_layer(irb-<wbr>>mt, irb->mt_layer);<br>
}<br>
<br>
-static bool<br>
+static void<br>
do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
struct gl_renderbuffer *rb, unsigned buf,<br>
bool partial_clear, bool encode_srgb)<br>
@@ -750,7 +750,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
<br>
/* If the clear region is empty, just return. */<br>
if (x0 == x1 || y0 == y1)<br>
- return true;<br>
+ return;<br>
<br>
bool can_fast_clear = !partial_clear;<br>
<br>
@@ -782,14 +782,16 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
if (!irb->mt->mcs_buf) {<br></blockquote><div><br></div><div>You might as well roll this check into the one above it and drop a level of nesting.<br><br></div><div>Other than that, this looks great. Thanks!<br><br>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
assert(!intel_miptree_is_<wbr>lossless_compressed(brw, irb->mt));<br>
if (!intel_miptree_alloc_non_<wbr>msrt_mcs(brw, irb->mt, false)) {<br>
- /* MCS allocation failed--probably this will only happen in<br>
- * out-of-memory conditions. But in any case, try to recover<br>
- * by falling back to a non-blorp clear technique.<br>
+ /* There are a few reasons in addition to out-of-memory, that can<br>
+ * cause intel_miptree_alloc_non_msrt_<wbr>mcs to fail. Try to recover<br>
+ * by falling back to non-fast clear.<br>
*/<br>
- return false;<br>
+ can_fast_clear = false;<br>
}<br>
}<br>
+ }<br>
<br>
+ if (can_fast_clear) {<br>
const enum isl_aux_state aux_state =<br>
intel_miptree_get_aux_state(<wbr>irb->mt, irb->mt_level, logical_layer);<br>
union isl_color_value clear_color =<br>
@@ -802,7 +804,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
if (aux_state == ISL_AUX_STATE_CLEAR &&<br>
memcmp(&irb->mt->fast_clear_<wbr>color,<br>
&clear_color, sizeof(clear_color)) == 0)<br>
- return true;<br>
+ return;<br>
<br>
irb->mt->fast_clear_color = clear_color;<br>
<br>
@@ -872,10 +874,10 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
blorp_batch_finish(&batch);<br>
}<br>
<br>
- return true;<br>
+ return;<br>
}<br>
<br>
-bool<br>
+void<br>
brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,<br>
GLbitfield mask, bool partial_clear, bool encode_srgb)<br>
{<br>
@@ -894,15 +896,11 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,<br>
if (rb == NULL)<br>
continue;<br>
<br>
- if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear,<br>
- encode_srgb)) {<br>
- return false;<br>
- }<br>
-<br>
+ do_single_blorp_clear(brw, fb, rb, buf, partial_clear, encode_srgb);<br>
irb->need_downsample = true;<br>
}<br>
<br>
- return true;<br>
+ return;<br>
}<br>
<br>
void<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h<br>
index fd1b5cc..636c993 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.h<br>
@@ -59,7 +59,7 @@ brw_blorp_copy_miptrees(struct brw_context *brw,<br>
unsigned dst_x, unsigned dst_y,<br>
unsigned src_width, unsigned src_height);<br>
<br>
-bool<br>
+void<br>
brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,<br>
GLbitfield mask, bool partial_clear, bool encode_srgb);<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
index 809e279..77c0dc4 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
@@ -228,16 +228,14 @@ brw_clear(struct gl_context *ctx, GLbitfield mask)<br>
}<br>
<br>
if (mask & BUFFER_BITS_COLOR) {<br>
- const bool encode_srgb = ctx->Color.sRGBEnabled;<br>
- if (brw_blorp_clear_color(brw, fb, mask, partial_clear, encode_srgb)) {<br>
- debug_mask("blorp color", mask & BUFFER_BITS_COLOR);<br>
- mask &= ~BUFFER_BITS_COLOR;<br>
- }<br>
+ brw_blorp_clear_color(brw, fb, mask, partial_clear,<br>
+ ctx->Color.sRGBEnabled);<br>
+ debug_mask("blorp color", mask & BUFFER_BITS_COLOR);<br>
+ mask &= ~BUFFER_BITS_COLOR;<br>
}<br>
<br>
- GLbitfield tri_mask = mask & (BUFFER_BITS_COLOR |<br>
- BUFFER_BIT_STENCIL |<br>
- BUFFER_BIT_DEPTH);<br>
+ GLbitfield tri_mask = mask & (BUFFER_BIT_STENCIL |<br>
+ BUFFER_BIT_DEPTH);<br>
<br>
if (tri_mask) {<br>
debug_mask("tri", tri_mask);<br>
@@ -250,7 +248,10 @@ brw_clear(struct gl_context *ctx, GLbitfield mask)<br>
}<br>
}<br>
<br>
- /* Any strange buffers get passed off to swrast */<br>
+ /* Any strange buffers get passed off to swrast. The only thing that<br>
+ * should be left at this point is the accumulation buffer.<br>
+ */<br>
+ assert((mask & ~BUFFER_BIT_ACCUM) == 0);<br>
if (mask) {<br>
debug_mask("swrast", mask);<br>
_swrast_Clear(ctx, mask);<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
2.9.4<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>