<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 29, 2018 at 10:58 AM, Rafael Antognolli <span dir="ltr"><<a href="mailto:rafael.antognolli@intel.com" target="_blank">rafael.antognolli@intel.com</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">On Gen10, whenever we do a fast clear, blorp will update the clear color<br>
state buffer for us, as long as we set the clear color address<br>
correctly.<br>
<br>
However, on a hiz clear, if the surface is already on the fast clear<br>
state we skip the actual fast clear operation and, before gen10, only<br>
updated the miptree. On gen10+ we need to update the clear value state<br>
buffer too, since blorp will not be doing a fast clear and updating it<br>
for us.<br>
<br>
v4:<br>
- do not use clear_value_size in the for loop<br>
- Get the address of the clear color from the aux buffer or the<br>
clear_color_bo, depending on which one is available.<br>
- let core blorp update the clear color, but also update it when we<br>
skip a fast clear depth.<br>
<br>
v5: Better subject (Jordan).<br>
<br>
Signed-off-by: Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com">rafael.antognolli@intel.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<wbr>blorp.c | 11 +++++++++++<br>
src/mesa/drivers/dri/i965/brw_<wbr>clear.c | 22 ++++++++++++++++++++++<br>
2 files changed, 33 insertions(+)<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 a0977598309..e2287cbad3b 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
@@ -185,6 +185,17 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
<br>
surf->aux_addr.buffer = aux_buf->bo;<br>
surf->aux_addr.offset = aux_buf->offset;<br>
+<br>
+ if (devinfo->gen >= 10) {<br>
+ /* If we have a CCS surface and clear_color_bo set, use that bo as<br>
+ * storage for the indirect clear color. Otherwise, use the extra<br>
+ * space at the end of the aux_buffer.<br>
+ */<br></blockquote><div><br></div><div>This comment is out of date now that we have a clear_color_bo/offset in aux_buf. Let's just drop the comment.<br></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">
+ surf->clear_color_addr = (struct blorp_address) {<br>
+ .buffer = aux_buf->clear_color_bo,<br>
+ .offset = aux_buf->clear_color_offset,<br>
+ };<br>
+ }<br>
} else {<br>
surf->aux_addr = (struct blorp_address) {<br>
.buffer = NULL,<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 8aa83722ee9..63c0b241898 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
@@ -108,6 +108,7 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
struct intel_mipmap_tree *mt = depth_irb->mt;<br>
struct gl_renderbuffer_attachment *depth_att = &fb->Attachment[BUFFER_DEPTH];<br>
const struct gen_device_info *devinfo = &brw->screen->devinfo;<br>
+ bool same_clear_value = true;<br>
<br>
if (devinfo->gen < 6)<br>
return false;<br>
@@ -213,6 +214,7 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
}<br>
<br>
intel_miptree_set_depth_clear_<wbr>value(ctx, mt, clear_value);<br>
+ same_clear_value = false;<br>
}<br>
<br>
bool need_clear = false;<br>
@@ -232,6 +234,26 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
* state then simply updating the miptree fast clear value is sufficient<br>
* to change their clear value.<br>
*/<br>
+ if (devinfo->gen >= 10 && !same_clear_value) {<br>
+ /* Before gen10, it was enough to just update the clear value in the<br>
+ * miptree. But on gen10+, we let blorp update the clear value state<br>
+ * buffer when doing a fast clear. Since we are skipping the fast<br>
+ * clear here, we need to update the clear color ourselves.<br>
+ */<br>
+ uint32_t clear_offset = mt->hiz_buf->clear_color_<wbr>offset;<br>
+ union isl_color_value clear_color = { .f32 = { clear_value, } };<br>
+<br>
+ /* We can't update the clear color while the hardware is still using<br>
+ * the previous one for a resolve or sampling from it. So make sure<br>
+ * that there's no pending commands at this point.<br>
+ */<br>
+ brw_emit_pipe_control_flush(<wbr>brw, PIPE_CONTROL_CS_STALL);<br>
+ for (int i = 0; i < 4; i++) {<br>
+ brw_store_data_imm32(brw, mt->hiz_buf->clear_color_bo,<br>
+ clear_offset + i * 4, clear_color.u32[i]);<br>
+ }<br>
+ brw_emit_pipe_control_flush(<wbr>brw, PIPE_CONTROL_STATE_CACHE_<wbr>INVALIDATE);<br></blockquote><div><br></div><div>I'm still not convinced by those pipe controls but I'm also not too worried about this edge case.<br><br>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></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">
+ }<br>
return true;<br>
}<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
--<br>
2.14.3<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>