<p dir="ltr"></p>
<p dir="ltr">On Sep 7, 2016 10:24 AM, "Topi Pohjolainen" <<a href="mailto:topi.pohjolainen@gmail.com">topi.pohjolainen@gmail.com</a>> wrote:<br>
><br>
> 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.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>
> v3: Split asserts and decision making.<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_wm_surface_state.c | 63 +++++++++++++++++++++---<br>
> 1 file changed, 56 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
> index c1273c5..054c5c8 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
> @@ -140,9 +140,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_BIT) ||<br>
> - mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_RESOLVED)) {<br>
> + if (mt->mcs_mt && !(flags & INTEL_AUX_BUFFER_DISABLED)) {<br>
> intel_miptree_get_aux_isl_surf(brw, mt, &aux_surf_s, &aux_usage);<br>
> aux_surf = &aux_surf_s;<br>
> assert(mt->mcs_mt->offset == 0);<br>
> @@ -425,6 +423,54 @@ swizzle_to_scs(GLenum swizzle, bool need_green_to_blue)<br>
> return (need_green_to_blue && scs == HSW_SCS_GREEN) ? HSW_SCS_BLUE : scs;<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->_ColorDrawBuffers[i]);<br>
> +<br>
> + if (irb->mt == mt)<br>
> + return i;<br>
> + }<br>
> +<br>
> + return fb->_NumColorDrawBuffers;<br>
> +}<br>
> +<br>
> +static bool<br>
> +brw_disable_aux_surface(const struct brw_context *brw,<br>
> + const struct intel_mipmap_tree *mt)<br>
> +{<br>
> + /* Nothing to disable. */<br>
> + if (!mt->mcs_mt)<br>
> + return false;<br>
> +<br>
> + /* There are special cases only for lossless compression. */<br>
> + if (!intel_miptree_is_lossless_compressed(brw, mt))<br>
> + return mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVED;<br>
> +<br>
> + const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;<br>
> + const unsigned rb_index = brw_find_matching_rb(fb, mt);<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 with<br>
> + * auxiliary buffer enabled.<br>
> + */<br>
> + if (rb_index < fb->_NumColorDrawBuffers) {<br>
> + if (brw->draw_aux_buffer_disabled[rb_index]) {<br>
> + assert(mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVED);<br>
> + }<br>
> +<br>
> + return brw->draw_aux_buffer_disabled[rb_index];</p>
<p dir="ltr">Can we use "mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVED" here as well? For render targets we want to look at aux_buffer_disabled but for textures (which is the only case that uses this function), fast_clear_state should be sufficient.</p>
<p dir="ltr">> + }<br>
> +<br>
> + return mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVED;<br>
> +}<br>
> +<br>
> void<br>
> brw_update_texture_surface(struct gl_context *ctx,<br>
> unsigned unit,<br>
> @@ -542,7 +588,8 @@ brw_update_texture_surface(struct gl_context *ctx,<br>
> obj->Target == GL_TEXTURE_CUBE_MAP_ARRAY)<br>
> view.usage |= ISL_SURF_USAGE_CUBE_BIT;<br>
><br>
> - const int flags = 0;<br>
> + const int flags =<br>
> + brw_disable_aux_surface(brw, mt) ? INTEL_AUX_BUFFER_DISABLED : 0;<br>
> brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
> surface_state_infos[brw->gen].tex_mocs,<br>
> surf_offset, surf_index,<br>
> @@ -1113,7 +1160,8 @@ update_renderbuffer_read_surfaces(struct brw_context *brw)<br>
> .usage = ISL_SURF_USAGE_TEXTURE_BIT,<br>
> };<br>
><br>
> - const int flags = 0;<br>
> + const int flags = brw->draw_aux_buffer_disabled[i] ?<br>
> + INTEL_AUX_BUFFER_DISABLED : 0;<br>
> brw_emit_surface_state(brw, irb->mt, flags, target, view,<br>
> surface_state_infos[brw->gen].tex_mocs,<br>
> surf_offset, surf_index,<br>
> @@ -1672,8 +1720,9 @@ update_image_surface(struct brw_context *brw,<br>
> };<br>
><br>
> const int surf_index = surf_offset - &brw->wm.base.surf_offset[0];<br>
> -<br>
> - const int flags = 0;<br>
> + const int flags =<br>
> + mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVED ?<br>
> + INTEL_AUX_BUFFER_DISABLED : 0;</p>
<p dir="ltr">According to brw_context, images should *always* be resolved. Can we make this check an assert and always pass AUX_BUFFER_DISABLED?</p>
<p dir="ltr">> brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
> surface_state_infos[brw->gen].tex_mocs,<br>
> surf_offset, surf_index,<br>
> --<br>
> 2.5.5<br>
><br>
> _______________________________________________<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">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></p>