<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 6, 2017 at 11:13 AM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Oct 05, 2017 at 10:02:40PM -0700, Kenneth Graunke wrote:<br>
> Jason and I investigated several OpenGL CTS failures where the tests<br>
> bind the same texture for rendering and texturing, at the same time.<br>
> This has defined results as long as the reads happen before writes,<br>
> or the regions are non-overlapping.  Normally, this just works out.<br>
><br>
> However, CCS can cause problems.  If the shader is reading one set of<br>
> pixels, and writing to different pixels that are adjacent, they may end<br>
> up being covered by the same CCS block.  So rendering may be writing a<br>
> CCS block, while the sampler is trying to read it.  Corruption ensues.<br>
><br>
> Disabling CCS is unfortunate, but safe.<br>
><br>
> Fixes several KHR-GL45.texture_barrier.* subtests.<br>
><br>
> Cc: <a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a><br>
> Cc: <a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a><br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>draw.c          |  8 +++++++-<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 13 +++++++------<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h |  2 +-<br>
>  3 files changed, 15 insertions(+), 8 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_draw.c b/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
> index cab3758d7b5..c13fa8c367a 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
> @@ -383,7 +383,13 @@ brw_predraw_resolve_inputs(<wbr>struct brw_context *brw)<br>
>           translate_tex_format(brw, tex_obj->_Format, sampler->sRGBDecode);<br>
>        int drawbuf_idx = get_drawbuffer_index(brw, tex_obj->mt->bo);<br>
><br>
> -      bool aux_supported;<br>
> +      /* Disable auxiliary buffers if there's a self-dependency, where<br>
> +       * we're both texturing from and rendering to the same buffer.<br>
> +       * It's not necessarily safe - concurrent reads and writes to the<br>
> +       * CCS buffer can result in incorrect pixels.<br>
> +       */<br>
> +      bool aux_supported = drawbuf_idx == -1;<br>
> +<br>
>        intel_miptree_prepare_texture(<wbr>brw, tex_obj->mt, view_format,<br>
>                                      &aux_supported);<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> index 5b7cde82f65..29b93dd656c 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> @@ -2651,9 +2651,10 @@ intel_miptree_prepare_texture_<wbr>slices(struct brw_context *brw,<br>
>                                       enum isl_format view_format,<br>
>                                       uint32_t start_level, uint32_t num_levels,<br>
>                                       uint32_t start_layer, uint32_t num_layers,<br>
> -                                     bool *aux_supported_out)<br>
> +                                     bool *aux_supported)<br>
<br>
</div></div>I find the name of this new parameter a little misleading. It suggests<br>
that the caller can determine that the aux surface is usable during the<br>
texture operation, when in fact it is the<br>
intel_miptree_texture_aux_<wbr>usage function in the callee which does this<br>
determination. Since the caller can determine that the aux surface<br>
cannot be used, perhaps something like disable_aux would be a better<br>
fit?<br></blockquote><div><br></div><div>I was thinking the same thing. <br></div></div></div></div>