<div dir="ltr">On 16 April 2013 16:21, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The upside is less CPU overhead in fiddling with GL error handling, the<br>
ability to use the constant color write message in most cases, and no GLSL<br>
clear shaders appearing in MESA_GLSL=dump output.  The downside is more<br>
batch flushing and a total recompute of GL state at the end of blorp.<br>
However, if we're ever going to use the fast color clear feature of CMS<br>
surfaces, we'll need this anyway since it requires very special state<br>
setup.<br>
<br>
This increases the fail rate of some the GLES3conform ARB_sync tests,<br>
because of the initial flush at the start of blorp.  The tests already<br>
intermittently failed (because it's just a bad testing procedure), and we<br>
can return it to its previous fail rate by fixing the initial flush.<br>
<br>
Improves GLB2.7 performance 0.37% +/- 0.11% (n=71/70, outlier removed).<br>
---<br>
 src/mesa/drivers/dri/i965/Makefile.sources    |    1 +<br>
 src/mesa/drivers/dri/i965/brw_blorp.cpp       |    4 +<br>
 src/mesa/drivers/dri/i965/brw_blorp.h         |    4 +<br>
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp |  303 +++++++++++++++++++++++++<br>
 src/mesa/drivers/dri/i965/brw_clear.c         |   11 +<br>
 src/mesa/drivers/dri/i965/brw_context.h       |    1 +<br>
 src/mesa/drivers/dri/i965/gen6_blorp.cpp      |   21 +-<br>
 src/mesa/drivers/dri/i965/gen7_blorp.cpp      |   12 +-<br>
 8 files changed, 343 insertions(+), 14 deletions(-)<br>
 create mode 100644 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources<br>
index be8d630..049ae91 100644<br>
--- a/src/mesa/drivers/dri/i965/Makefile.sources<br>
+++ b/src/mesa/drivers/dri/i965/Makefile.sources<br>
@@ -31,6 +31,7 @@ i965_FILES = \<br>
        intel_tex_validate.c \<br>
        brw_blorp.cpp \<br>
        brw_blorp_blit.cpp \<br>
+       brw_blorp_clear.cpp \<br>
        brw_cc.c \<br>
        brw_cfg.cpp \<br>
        brw_clear.c \<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
index 8a044c1..a2d02bf 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
@@ -148,6 +148,10 @@ brw_blorp_params::brw_blorp_params()<br>
      num_samples(0),<br>
      use_wm_prog(false)<br>
 {<br>
+   color_write_disable[0] = false;<br>
+   color_write_disable[1] = false;<br>
+   color_write_disable[2] = false;<br>
+   color_write_disable[3] = false;<br>
 }<br>
<br>
 extern "C" {<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
index 1b95818..8915080 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_blorp.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
@@ -45,6 +45,9 @@ brw_blorp_blit_miptrees(struct intel_context *intel,<br>
                         int dst_x1, int dst_y1,<br>
                         bool mirror_x, bool mirror_y);<br>
<br>
+bool<br>
+brw_blorp_clear_color(struct intel_context *intel, struct gl_framebuffer *fb);<br>
+<br>
 #ifdef __cplusplus<br>
 } /* end extern "C" */<br>
<br>
@@ -211,6 +214,7 @@ public:<br>
    unsigned num_samples;<br>
    bool use_wm_prog;<br>
    brw_blorp_wm_push_constants wm_push_consts;<br>
+   bool color_write_disable[4];<br>
 };<br>
<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
new file mode 100644<br>
index 0000000..000f1c6<br>
--- /dev/null<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
@@ -0,0 +1,303 @@<br>
+/*<br>
+ * Copyright © 2013 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include "main/teximage.h"<br>
+#include "main/fbobject.h"<br>
+#include "main/renderbuffer.h"<br>
+<br>
+#include "glsl/ralloc.h"<br>
+<br>
+#include "intel_fbo.h"<br>
+<br>
+#include "brw_blorp.h"<br>
+#include "brw_context.h"<br>
+#include "brw_eu.h"<br>
+#include "brw_state.h"<br>
+<br>
+struct brw_blorp_clear_prog_key<br>
+{<br>
+   uint32_t const_clear;<br>
+};<br></blockquote><div><br></div><div>I found the name and type of "const_clear" really misleading (at first I assumed it was the value we are clearing the buffer to.  Actually it's a boolean that determines whether we use the "replicate data" message).  Can we change this to "bool use_replicate_data_msg" or something?<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+class brw_blorp_clear_params : public brw_blorp_params<br>
+{<br>
+public:<br>
+   brw_blorp_clear_params(struct brw_context *brw,<br>
+                          struct gl_framebuffer *fb,<br>
+                          struct gl_renderbuffer *rb,<br>
+                          GLubyte *color_mask);<br>
+<br>
+   virtual uint32_t get_wm_prog(struct brw_context *brw,<br>
+                                brw_blorp_prog_data **prog_data) const;<br>
+<br>
+private:<br>
+   brw_blorp_clear_prog_key wm_prog_key;<br>
+};<br>
+<br>
+class brw_blorp_clear_program<br>
+{<br>
+public:<br>
+   brw_blorp_clear_program(struct brw_context *brw,<br>
+                          const brw_blorp_clear_prog_key *key);<br>
+   ~brw_blorp_clear_program();<br>
+<br>
+   const GLuint *compile(struct brw_context *brw, GLuint *program_size);<br>
+<br>
+   brw_blorp_prog_data prog_data;<br>
+<br>
+private:<br>
+   void alloc_regs();<br>
+<br>
+   void *mem_ctx;<br>
+   struct brw_context *brw;<br>
+   const brw_blorp_clear_prog_key *key;<br>
+   struct brw_compile func;<br>
+<br>
+   /* Thread dispatch header */<br>
+   struct brw_reg R0;<br>
+<br>
+   /* Pixel X/Y coordinates (always in R1). */<br>
+   struct brw_reg R1;<br>
+<br>
+   /* Register with push constants (a single vec4) */<br>
+   struct brw_reg clear_rgba;<br>
+<br>
+   /* MRF used for sampling and render target writes */<br>
+   GLuint base_mrf;<br></blockquote><div><br></div><div>Actually this mrf is just used for render target writes.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+};<br>
+<br>
+brw_blorp_clear_program::brw_blorp_clear_program(<br>
+      struct brw_context *brw,<br>
+      const brw_blorp_clear_prog_key *key)<br>
+   : mem_ctx(ralloc_context(NULL)),<br>
+     brw(brw),<br>
+     key(key)<br>
+{<br>
+   brw_init_compile(brw, &func, mem_ctx);<br>
+}<br>
+<br>
+brw_blorp_clear_program::~brw_blorp_clear_program()<br>
+{<br>
+   ralloc_free(mem_ctx);<br>
+}<br>
+<br>
+brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw,<br>
+                                               struct gl_framebuffer *fb,<br>
+                                               struct gl_renderbuffer *rb,<br>
+                                               GLubyte *color_mask)<br>
+{<br>
+   struct intel_context *intel = &brw->intel;<br>
+   struct gl_context *ctx = &intel->ctx;<br>
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);<br>
+<br>
+   dst.set(brw, irb->mt, irb->mt_level, irb->mt_layer);<br>
+<br>
+   /* Override the surface format according to the context's sRGB rules. */<br>
+   gl_format format = irb->mt->format;<br>
+   if (!ctx->Color.sRGBEnabled)<br>
+      format = _mesa_get_srgb_format_linear(format);<br>
+   dst.brw_surfaceformat = brw->render_target_format[format];<br></blockquote><div><br></div><div>The code for doing this in gen7_update_renderbuffer_surface() looks very different:<br><br>   gl_format rb_format = intel_rb_format(irb);<br>
   switch (rb_format) {<br>   case MESA_FORMAT_SARGB8:<br>      /* _NEW_BUFFERS<br>       *<br>       * Without GL_EXT_framebuffer_sRGB we shouldn't bind sRGB surfaces to the<br>       * blend/update as sRGB.<br>       */<br>
      if (ctx->Color.sRGBEnabled)<br>     format = brw_format_for_mesa_format(rb_format);<br>      else<br>     format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;<br>      break;<br>   default:<br>      assert(brw_render_target_supported(intel, rb));<br>
      format = brw->render_target_format[rb_format];<br>      if (unlikely(!brw->format_supported_as_render_target[rb_format])) {<br>     _mesa_problem(ctx, "%s: renderbuffer format %s unsupported\n",<br>               __FUNCTION__, _mesa_get_format_name(rb_format));<br>
      }<br>      break;<br>   }<br><br></div><div>(This logic is almost exactly duplicated in brw_update_renderbuffer_surface()).  I'm having trouble reassuring myself that it's equivalent.<br></div><div><br>Can we make a common function to do this job and share it between gen7_update_renderbuffer_surface(), brw_update_renderbuffer_surface(), and brw_blorp_clear_params()?<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+   x0 = fb->_Xmin;<br>
+   x1 = fb->_Xmax;<br>
+   if (rb->Name != 0) {<br>
+      y0 = fb->_Ymin;<br>
+      y1 = fb->_Ymax;<br>
+   } else {<br>
+      y0 = rb->Height - fb->_Ymax;<br>
+      y1 = rb->Height - fb->_Ymin;<br>
+   }<br>
+<br>
+   float *push_consts = (float *)&wm_push_consts;<br>
+<br>
+   push_consts[0] = ctx->Color.ClearColor.f[0];<br>
+   push_consts[1] = ctx->Color.ClearColor.f[1];<br>
+   push_consts[2] = ctx->Color.ClearColor.f[2];<br>
+   push_consts[3] = ctx->Color.ClearColor.f[3];<br>
+<br>
+   use_wm_prog = true;<br>
+<br>
+   memset(&wm_prog_key, 0, sizeof(wm_prog_key));<br>
+<br>
+   wm_prog_key.const_clear = true;<br>
+<br>
+   /* From the SNB PRM (Vol4_Part1):<br>
+    *<br>
+    *     "Replicated data (Message Type = 111) is only supported when<br>
+    *      accessing tiled memory.  Using this Message Type to access linear<br>
+    *      (untiled) memory is UNDEFINED."<br>
+    */<br>
+   if (irb->mt->region->tiling == I915_TILING_NONE)<br>
+      wm_prog_key.const_clear = false;<br>
+<br>
+   /* Constant color writes ignore everyting in blend and color calculator<br>
+    * state.  This is not documented.<br>
+    */<br>
+   for (int i = 0; i < 4; i++) {<br>
+      if (!color_mask[i]) {<br>
+         color_write_disable[i] = true;<br>
+         wm_prog_key.const_clear = false;<br>
+      }<br>
+   }<br>
+}<br>
+<br>
+uint32_t<br>
+brw_blorp_clear_params::get_wm_prog(struct brw_context *brw,<br>
+                                   brw_blorp_prog_data **prog_data) const<br>
+{<br>
+   uint32_t prog_offset;<br>
+   if (!brw_search_cache(&brw->cache, BRW_BLORP_BLIT_PROG,<br></blockquote><div><br></div><div>s/BRW_BLORP_BLIT_PROG/BRW_BLORP_CLEAR_PROG/ here (and in the call to brw_upload_cache() below)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+                         &this->wm_prog_key, sizeof(this->wm_prog_key),<br>
+                         &prog_offset, prog_data)) {<br>
+      brw_blorp_clear_program prog(brw, &this->wm_prog_key);<br>
+      GLuint program_size;<br>
+      const GLuint *program = prog.compile(brw, &program_size);<br>
+      brw_upload_cache(&brw->cache, BRW_BLORP_BLIT_PROG,<br>
+                       &this->wm_prog_key, sizeof(this->wm_prog_key),<br>
+                       program, program_size,<br>
+                       &prog.prog_data, sizeof(prog.prog_data),<br>
+                       &prog_offset, prog_data);<br>
+   }<br>
+   return prog_offset;<br>
+}<br>
+<br>
+void<br>
+brw_blorp_clear_program::alloc_regs()<br>
+{<br>
+   int reg = 0;<br>
+   this->R0 = retype(brw_vec8_grf(reg++, 0), BRW_REGISTER_TYPE_UW);<br>
+   this->R1 = retype(brw_vec8_grf(reg++, 0), BRW_REGISTER_TYPE_UW);<br>
+<br>
+   prog_data.first_curbe_grf = reg;<br>
+   clear_rgba = retype(brw_vec4_grf(reg++, 0), BRW_REGISTER_TYPE_F);<br>
+   reg += BRW_BLORP_NUM_PUSH_CONST_REGS;<br>
+<br>
+   /* Make sure we didn't run out of registers */<br>
+   assert(reg <= GEN7_MRF_HACK_START);<br>
+<br>
+   int mrf = 2;<br>
+   this->base_mrf = mrf;<br>
+}<br>
+<br>
+const GLuint *<br>
+brw_blorp_clear_program::compile(struct brw_context *brw,<br>
+                                 GLuint *program_size)<br>
+{<br>
+   /* Set up prog_data */<br>
+   memset(&prog_data, 0, sizeof(prog_data));<br>
+   prog_data.persample_msaa_dispatch = false;<br>
+<br>
+   alloc_regs();<br>
+<br>
+   brw_set_compression_control(&func, BRW_COMPRESSION_NONE);<br>
+<br>
+   struct brw_reg mrf_rt_write =<br>
+      retype(vec16(brw_message_reg(base_mrf)), BRW_REGISTER_TYPE_F);<br>
+<br>
+   uint32_t mlen, msg_type;<br>
+   if (key->const_clear) {<br>
+      /* The message payload is a single register with the low 4 floats/ints<br>
+       * filled with the constant clear color.<br>
+       */<br>
+      brw_set_mask_control(&func, true);<br></blockquote><div><br></div><div>This would read easier as "brw_set_mask_control(&func, BRW_MASK_DISABLE);"<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+      brw_MOV(&func, vec4(brw_message_reg(base_mrf)), clear_rgba);<br>
+      brw_set_mask_control(&func, false);<br></blockquote><div><br></div><div>And "brw_set_mask_control(&func, BRW_MASK_ENABLE);" here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+<br>
+      msg_type = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED;<br>
+      mlen = 1;<br>
+   } else {<br>
+      for (int i = 0; i < 4; i++) {<br>
+         /* The message payload is pairs of registers for 16 pixels each of r,<br>
+          * g, b, and a.<br>
+          */<br>
+         brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);<br>
+         brw_MOV(&func,<br>
+                 brw_message_reg(base_mrf + i * 2),<br>
+                 brw_vec1_grf(<a href="http://clear_rgba.nr" target="_blank">clear_rgba.nr</a>, i));<br>
+         brw_set_compression_control(&func, BRW_COMPRESSION_NONE);<br>
+      }<br>
+<br>
+      msg_type = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;<br>
+      mlen = 8;<br>
+   }<br>
+<br>
+      /* Now write to the render target and terminate the thread */<br>
+      brw_fb_WRITE(&func,<br>
+                   16 /* dispatch_width */,<br>
+                   base_mrf /* msg_reg_nr */,<br>
+                   mrf_rt_write /* src0 */,<br>
+                   msg_type,<br>
+                   BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX,<br>
+                   mlen,<br>
+                   0 /* response_length */,<br>
+                   true /* eot */,<br>
+                   false /* header present */);<br></blockquote><div><br></div><div>Unexpectedly indented.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+<br>
+   if (unlikely(INTEL_DEBUG & DEBUG_BLORP)) {<br>
+      printf("Native code for BLORP clear:\n");<br>
+      brw_dump_compile(&func, stdout, 0, func.next_insn_offset);<br>
+      printf("\n");<br>
+   }<br>
+   return brw_get_program(&func, program_size);<br>
+}<br>
+<br>
+extern "C" {<br>
+bool<br>
+brw_blorp_clear_color(struct intel_context *intel, struct gl_framebuffer *fb)<br>
+{<br>
+   struct gl_context *ctx = &intel->ctx;<br>
+   struct brw_context *brw = brw_context(ctx);<br>
+<br>
+   /* The constant color clear code doesn't work for multisampled surfaces, so<br>
+    * we need to support falling back to other clear mechanisms.<br>
+    * Unfortunately, our clear code is based on a bitmask that doesn't<br>
+    * distinguish individual color attachments, so we walk the attachments to<br>
+    * see if any require fallback, and fall back for all if any of them need<br>
+    * to.<br>
+    */<br>
+   for (unsigned buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {<br>
+      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf];<br>
+      struct intel_renderbuffer *irb = intel_renderbuffer(rb);<br>
+<br>
+      if (irb && irb->mt->msaa_layout != INTEL_MSAA_LAYOUT_NONE)<br>
+         return false;<br>
+   }<br>
+<br>
+   for (unsigned buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {<br>
+      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf];<br>
+<br>
+      /* If this is an ES2 context or GL_ARB_ES2_compatibility is supported,<br>
+       * the framebuffer can be complete with some attachments missing.  In<br>
+       * this case the _ColorDrawBuffers pointer will be NULL.<br>
+       */<br>
+      if (rb == NULL)<br>
+         continue;<br>
+<br>
+      brw_blorp_clear_params params(brw, fb, rb, ctx->Color.ColorMask[buf]);<br>
+      brw_blorp_exec(intel, &params);<br>
+   }<br>
+<br>
+   return true;<br>
+}<br>
+<br>
+} /* extern "C" */<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c<br>
index c0ac69d..ad6a554 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clear.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clear.c<br>
@@ -41,6 +41,7 @@<br>
 #include "intel_regions.h"<br>
<br>
 #include "brw_context.h"<br>
+#include "brw_blorp.h"<br>
<br>
 #define FILE_DEBUG_FLAG DEBUG_BLIT<br>
<br>
@@ -243,6 +244,16 @@ brw_clear(struct gl_context *ctx, GLbitfield mask)<br>
       }<br>
    }<br>
<br>
+   /* We only have support for blorp as of gen6 so far. */<br>
+   if (intel->gen >= 6) {<br>
+      if (mask & BUFFER_BITS_COLOR) {<br>
+         if (brw_blorp_clear_color(intel, fb)) {<br>
+            debug_mask("blorp color", mask & BUFFER_BITS_COLOR);<br>
+            mask &= ~BUFFER_BITS_COLOR;<br>
+         }<br>
+      }<br>
+   }<br>
+<br>
    GLbitfield tri_mask = mask & (BUFFER_BITS_COLOR |<br>
                                 BUFFER_BIT_STENCIL |<br>
                                 BUFFER_BIT_DEPTH);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index 114c369..7ec448c 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -605,6 +605,7 @@ enum brw_cache_id {<br>
    BRW_CC_UNIT,<br>
    BRW_WM_PROG,<br>
    BRW_BLORP_BLIT_PROG,<br>
+   BRW_BLORP_CLEAR_PROG,<br>
    BRW_SAMPLER,<br>
    BRW_WM_UNIT,<br>
    BRW_SF_PROG,<br>
diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp<br>
index 872c408..3e7467e 100644<br>
--- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp<br>
+++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp<br>
@@ -278,17 +278,18 @@ gen6_blorp_emit_blend_state(struct brw_context *brw,<br>
    blend->blend1.post_blend_clamp_enable = 1;<br>
    blend->blend1.clamp_range = BRW_RENDERTARGET_CLAMPRANGE_FORMAT;<br>
<br>
-   blend->blend1.write_disable_r = false;<br>
-   blend->blend1.write_disable_g = false;<br>
-   blend->blend1.write_disable_b = false;<br>
-   blend->blend1.write_disable_a = false;<br>
+   blend->blend1.write_disable_r = params->color_write_disable[0];<br>
+   blend->blend1.write_disable_g = params->color_write_disable[1];<br>
+   blend->blend1.write_disable_b = params->color_write_disable[2];<br>
+   blend->blend1.write_disable_a = params->color_write_disable[3];<br>
<br>
    /* When blitting from an XRGB source to a ARGB destination, we need to<br>
     * interpret the missing channel as 1.0.  Blending can do that for us:<br>
     * we simply use the RGB values from the fragment shader ("source RGB"),<br>
     * but smash the alpha channel to 1.<br>
     */<br>
-   if (_mesa_get_format_bits(params->dst.mt->format, GL_ALPHA_BITS) > 0 &&<br>
+   if (params-><a href="http://src.mt" target="_blank">src.mt</a> &&<br>
+       _mesa_get_format_bits(params->dst.mt->format, GL_ALPHA_BITS) > 0 &&<br>
        _mesa_get_format_bits(params->src.mt->format, GL_ALPHA_BITS) == 0) {<br>
       blend->blend0.blend_enable = 1;<br>
       blend->blend0.ia_blend_enable = 1;<br>
@@ -1058,16 +1059,18 @@ gen6_blorp_exec(struct intel_context *intel,<br>
                                      depthstencil_offset, cc_state_offset);<br>
    if (params->use_wm_prog) {<br>
       uint32_t wm_surf_offset_renderbuffer;<br>
-      uint32_t wm_surf_offset_texture;<br>
+      uint32_t wm_surf_offset_texture = 0;<br>
       uint32_t sampler_offset;<br>
       wm_push_const_offset = gen6_blorp_emit_wm_constants(brw, params);<br>
       wm_surf_offset_renderbuffer =<br>
          gen6_blorp_emit_surface_state(brw, params, &params->dst,<br>
                                        I915_GEM_DOMAIN_RENDER,<br>
                                        I915_GEM_DOMAIN_RENDER);<br>
-      wm_surf_offset_texture =<br>
-         gen6_blorp_emit_surface_state(brw, params, &params->src,<br>
-                                       I915_GEM_DOMAIN_SAMPLER, 0);<br>
+      if (params-><a href="http://src.mt" target="_blank">src.mt</a>) {<br>
+         wm_surf_offset_texture =<br>
+            gen6_blorp_emit_surface_state(brw, params, &params->src,<br>
+                                          I915_GEM_DOMAIN_SAMPLER, 0);<br>
+      }<br>
       wm_bind_bo_offset =<br>
          gen6_blorp_emit_binding_table(brw, params,<br>
                                        wm_surf_offset_renderbuffer,<br>
diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
index 99e7e58..1c23866 100644<br>
--- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
+++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
@@ -765,17 +765,19 @@ gen7_blorp_exec(struct intel_context *intel,<br>
                                                 depthstencil_offset);<br>
    if (params->use_wm_prog) {<br>
       uint32_t wm_surf_offset_renderbuffer;<br>
-      uint32_t wm_surf_offset_texture;<br>
+      uint32_t wm_surf_offset_texture = 0;<br>
       wm_push_const_offset = gen6_blorp_emit_wm_constants(brw, params);<br>
       wm_surf_offset_renderbuffer =<br>
          gen7_blorp_emit_surface_state(brw, params, &params->dst,<br>
                                        I915_GEM_DOMAIN_RENDER,<br>
                                        I915_GEM_DOMAIN_RENDER,<br>
                                        true /* is_render_target */);<br>
-      wm_surf_offset_texture =<br>
-         gen7_blorp_emit_surface_state(brw, params, &params->src,<br>
-                                       I915_GEM_DOMAIN_SAMPLER, 0,<br>
-                                       false /* is_render_target */);<br>
+      if (params-><a href="http://src.mt" target="_blank">src.mt</a>) {<br>
+         wm_surf_offset_texture =<br>
+            gen7_blorp_emit_surface_state(brw, params, &params->src,<br>
+                                          I915_GEM_DOMAIN_SAMPLER, 0,<br>
+                                          false /* is_render_target */);<br>
+      }<br>
       wm_bind_bo_offset =<br>
          gen6_blorp_emit_binding_table(brw, params,<br>
                                        wm_surf_offset_renderbuffer,<br>
<span class=""><font color="#888888">--<br>
1.7.10.4<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="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>