<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 6, 2016 at 12:28 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">Once mcs buffer gets allocated without delay for lossless<br>
compression (same as we do for msaa), one gets regression in:<br>
<br>
GL45-CTS.texture_barrier_ARB.<wbr>same-texel-rw<br>
<br>
Setting the auxiliary surface for both sampling engine and data<br>
port seems to fix this. I haven't found any hardware documentation<br>
backing this though.<br>
<br>
v2 (Jason): Prepare also for the case where surface is sampled with<br>
non-compressible format forcing also rendering without<br>
compression.<br>
<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/brw_<wbr>wm_surface_state.c | 74 +++++++++++++++++++++++-<br>
1 file changed, 71 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
index af102a9..05b214f 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
@@ -77,6 +77,76 @@ static const struct surface_state_info surface_state_infos[] = {<br>
[9] = {16, 64, 8, 10, SKL_MOCS_WB, SKL_MOCS_PTE},<br>
};<br>
<br>
+static unsigned<br>
+brw_find_matching_rb(const struct gl_framebuffer *fb,<br>
+ const struct intel_mipmap_tree *mt)<br>
+{<br>
+ for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {<br>
+ const struct intel_renderbuffer *irb =<br>
+ intel_renderbuffer(fb->_<wbr>ColorDrawBuffers[i]);<br>
+<br>
+ if (irb->mt == mt)<br>
+ return i;<br>
+ }<br>
+<br>
+ return fb->_NumColorDrawBuffers;<br>
+}<br>
+<br>
+static bool<br>
+brw_needs_aux_surface(const struct brw_context *brw,<br>
+ const struct intel_mipmap_tree *mt, int flags,<br>
+ const struct isl_view *view)<br>
+{<br>
+ if (!mt->mcs_mt)<br>
+ return false;<br>
+<br>
+ if (view->usage & ISL_SURF_USAGE_RENDER_TARGET_<wbr>BIT &&<br>
+ !(flags & INTEL_RENDERBUFFER_AUX_<wbr>DISABLED))<br>
+ return true;<br>
+<br>
+ const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;<br>
+ const bool is_lossless_compressed =<br>
+ intel_miptree_is_lossless_<wbr>compressed(brw, mt);<br>
+ const bool view_format_lossless_<wbr>compressed =<br>
+ isl_format_supports_lossless_<wbr>compression(brw->intelScreen-><wbr>devinfo,<br>
+ view->format);<br>
+ const unsigned rb_index = brw_find_matching_rb(fb, mt);<br>
+<br>
+ /* If the underlying surface is compressed but it is sampled using a<br>
+ * format that the sampling engine doesn't support as compressed, there<br>
+ * is no alternative but to treat the surface as non-compressed.<br>
+ */<br>
+ if (is_lossless_compressed && !view_format_lossless_<wbr>compressed) {<br>
+ /* Logic elsewhere needs to take care to resolve the color buffer prior<br>
+ * to sampling it as non-compressed.<br>
+ */<br>
+ assert(mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_<wbr>RESOLVED);<br>
+<br>
+ /* In practise it looks that setting the same lossless compressed<br>
+ * surface to be sampled without auxiliary surface and to be written<br>
+ * with auxiliary surface confuses the hardware. Therefore any<br>
+ * corresponding renderbuffer must be set up with auxiliary buffer<br>
+ * disabled.<br>
+ */<br>
+ assert(rb_index == fb->_NumColorDrawBuffers ||<br>
+ brw->draw_aux_buffer_disabled[<wbr>rb_index]);<br>
+ return false;<br>
+ }<br>
+<br>
+ /* In practise it looks that setting the same lossless compressed surface<br>
+ * to be sampled without auxiliary surface and to be written with auxiliary<br>
+ * surface confuses the hardware. Therefore sampler engine must be provided<br>
+ * with auxiliary buffer regardless of the fast clear state if the same<br>
+ * surface is also going to be written during the same rendering pass.<br>
+ */<br>
+ if (is_lossless_compressed && rb_index < fb->_NumColorDrawBuffers) {<br>
+ assert(!brw->draw_aux_buffer_<wbr>disabled[rb_index]);<br>
+ return true;<br>
+ }<br>
+<br>
+ return mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_<wbr>RESOLVED;]<br></blockquote><div><br></div><div>How much of this really belongs in emit_surface_state? It seems like we ought to have someone else make those decisions and simply pass us the AUX_DISABLED bit.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
static void<br>
brw_emit_surface_state(struct brw_context *brw,<br>
struct intel_mipmap_tree *mt, int flags,<br>
@@ -140,9 +210,7 @@ brw_emit_surface_state(struct brw_context *brw,<br>
struct isl_surf *aux_surf = NULL, aux_surf_s;<br>
uint64_t aux_offset = 0;<br>
enum isl_aux_usage aux_usage = ISL_AUX_USAGE_NONE;<br>
- if (mt->mcs_mt &&<br>
- ((view.usage & ISL_SURF_USAGE_RENDER_TARGET_<wbr>BIT) ||<br>
- mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_<wbr>RESOLVED)) {<br>
+ if (brw_needs_aux_surface(brw, mt, flags, &view)) {<br>
intel_miptree_get_aux_isl_<wbr>surf(brw, mt, &aux_surf_s, &aux_usage);<br>
aux_surf = &aux_surf_s;<br>
assert(mt->mcs_mt->offset == 0);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<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>