[Mesa-dev] [PATCH 1/2] i965: Change intel_disable_rb_aux_buffer into get_drawbuffer_index().

Kenneth Graunke kenneth at whitecape.org
Fri Oct 6 05:02:39 UTC 2017


The bulk of the work in intel_disable_rb_aux_buffer() is finding the
drawbuffer index for the given BO.  After that, disabling the auxiliary
buffers is an easy one liner.

This lets us ask whether a texture is also bound as a renderbuffer
before making any decisions.  We'll use this in the next patch.

Cc: nanleychery at gmail.com
Cc: jason at jlekstrand.net
---
 src/mesa/drivers/dri/i965/brw_draw.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index c7ed7284501..cab3758d7b5 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -336,22 +336,21 @@ brw_merge_inputs(struct brw_context *brw,
    }
 }
 
-static bool
-intel_disable_rb_aux_buffer(struct brw_context *brw, const struct brw_bo *bo)
+static int
+get_drawbuffer_index(struct brw_context *brw, const struct brw_bo *bo)
 {
    const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;
-   bool found = false;
 
    for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {
       const struct intel_renderbuffer *irb =
          intel_renderbuffer(fb->_ColorDrawBuffers[i]);
 
       if (irb && irb->mt->bo == bo) {
-         found = brw->draw_aux_buffer_disabled[i] = true;
+         return i;
       }
    }
 
-   return found;
+   return -1;
 }
 
 /**
@@ -382,13 +381,14 @@ brw_predraw_resolve_inputs(struct brw_context *brw)
       struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, i);
       enum isl_format view_format =
          translate_tex_format(brw, tex_obj->_Format, sampler->sRGBDecode);
+      int drawbuf_idx = get_drawbuffer_index(brw, tex_obj->mt->bo);
 
       bool aux_supported;
       intel_miptree_prepare_texture(brw, tex_obj->mt, view_format,
                                     &aux_supported);
 
-      if (!aux_supported && devinfo->gen >= 9 &&
-          intel_disable_rb_aux_buffer(brw, tex_obj->mt->bo)) {
+      if (!aux_supported && devinfo->gen >= 9 && drawbuf_idx != -1) {
+         brw->draw_aux_buffer_disabled[i] = true;
          perf_debug("Sampling renderbuffer with non-compressible format - "
                     "turning off compression\n");
       }
@@ -413,9 +413,11 @@ brw_predraw_resolve_inputs(struct brw_context *brw)
 
             if (tex_obj && tex_obj->mt) {
                intel_miptree_prepare_image(brw, tex_obj->mt);
+               int drawbuf_idx = get_drawbuffer_index(brw, tex_obj->mt->bo);
 
                if (tex_obj->mt->aux_usage == ISL_AUX_USAGE_CCS_E &&
-                   intel_disable_rb_aux_buffer(brw, tex_obj->mt->bo)) {
+                   drawbuf_idx != -1) {
+                  brw->draw_aux_buffer_disabled[i] = true;
                   perf_debug("Using renderbuffer as shader image - turning "
                              "off lossless compression\n");
                }
-- 
2.14.2



More information about the mesa-dev mailing list