<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 6, 2017 at 10:57 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"><span class="">On Thu, Oct 05, 2017 at 10:02:39PM -0700, Kenneth Graunke wrote:<br>
> The bulk of the work in intel_disable_rb_aux_buffer() is finding the<br>
> drawbuffer index for the given BO. After that, disabling the auxiliary<br>
> buffers is an easy one liner.<br>
><br>
> This lets us ask whether a texture is also bound as a renderbuffer<br>
> before making any decisions. We'll use this in the next patch.<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 | 18 ++++++++++--------<br>
> 1 file changed, 10 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 c7ed7284501..cab3758d7b5 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
> @@ -336,22 +336,21 @@ brw_merge_inputs(struct brw_context *brw,<br>
> }<br>
> }<br>
><br>
> -static bool<br>
> -intel_disable_rb_aux_buffer(<wbr>struct brw_context *brw, const struct brw_bo *bo)<br>
> +static int<br>
> +get_drawbuffer_index(struct brw_context *brw, const struct brw_bo *bo)<br>
<br>
</span>We can now make brw point to a const struct.<br>
<span class=""><br>
> {<br>
> const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;<br>
> - bool found = false;<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 && irb->mt->bo == bo) {<br>
> - found = brw->draw_aux_buffer_disabled[<wbr>i] = true;<br>
> + return i;<br>
> }<br>
> }<br>
><br>
> - return found;<br>
> + return -1;<br>
> }<br>
><br>
> /**<br>
> @@ -382,13 +381,14 @@ brw_predraw_resolve_inputs(<wbr>struct brw_context *brw)<br>
> struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, i);<br>
> enum isl_format view_format =<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>
> intel_miptree_prepare_texture(<wbr>brw, tex_obj->mt, view_format,<br>
> &aux_supported);<br>
><br>
> - if (!aux_supported && devinfo->gen >= 9 &&<br>
> - intel_disable_rb_aux_buffer(<wbr>brw, tex_obj->mt->bo)) {<br>
> + if (!aux_supported && devinfo->gen >= 9 && drawbuf_idx != -1) {<br>
> + brw->draw_aux_buffer_disabled[<wbr>i] = true;<br>
<br>
</span>Don't we want to index this array with drawbuf_idx? Maybe I don't<br>
understand how the texunit and drawbuffer arrays are related.. I'll do<br>
some reading.<span class=""><br></span></blockquote><div><br></div><div>Good catch. You are 100% right.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> perf_debug("Sampling renderbuffer with non-compressible format - "<br>
> "turning off compression\n");<br>
> }<br>
> @@ -413,9 +413,11 @@ brw_predraw_resolve_inputs(<wbr>struct brw_context *brw)<br>
><br>
> if (tex_obj && tex_obj->mt) {<br>
> intel_miptree_prepare_image(<wbr>brw, tex_obj->mt);<br>
> + int drawbuf_idx = get_drawbuffer_index(brw, tex_obj->mt->bo);<br>
><br>
> if (tex_obj->mt->aux_usage == ISL_AUX_USAGE_CCS_E &&<br>
> - intel_disable_rb_aux_buffer(<wbr>brw, tex_obj->mt->bo)) {<br>
> + drawbuf_idx != -1) {<br>
> + brw->draw_aux_buffer_disabled[<wbr>i] = true;<br>
<br>
</span>You're using the index of the shader stage here.<br>
<div class="HOEnZb"><div class="h5"><br>
> perf_debug("Using renderbuffer as shader image - turning "<br>
> "off lossless compression\n");<br>
> }<br>
> --<br>
> 2.14.2<br>
><br>
</div></div></blockquote></div><br></div></div>