i965: Check for alpha channel just like in gen6+.
authorRafael Antognolli <rafael.antognolli@intel.com>
Fri, 2 Jun 2017 21:41:19 +0000 (14:41 -0700)
committerRafael Antognolli <rafael.antognolli@intel.com>
Thu, 13 Jul 2017 22:39:49 +0000 (15:39 -0700)
gen6+ uses _mesa_base_format_has_channel() to check for the alpha
channel, while gen4-5 use ctx->DrawBuffer->Visual.alphaBits. By using
_mesa_base_format_has_channel() here we keep the same behavior accross
all gen.

While initially both ways of checking the alpha channel seemed correct
to me, this change also seems to fix fbo-blending-formats piglit test on
gen4.

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_cc.c

index f0aa7b89704fba3e7843b66ee5fa08204872d20c..1574788736c0d0621656d23376be7366b02872e6 100644 (file)
@@ -34,6 +34,7 @@
 #include "brw_state.h"
 #include "brw_defines.h"
 #include "brw_util.h"
+#include "main/glformats.h"
 #include "main/macros.h"
 #include "main/stencil.h"
 #include "intel_batchbuffer.h"
@@ -126,7 +127,9 @@ static void upload_cc_unit(struct brw_context *brw)
        * force the destination alpha to 1.0.  This means replacing GL_DST_ALPHA
        * with GL_ONE and GL_ONE_MINUS_DST_ALPHA with GL_ZERO.
        */
-      if (ctx->DrawBuffer->Visual.alphaBits == 0) {
+      const struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
+      if (rb && !_mesa_base_format_has_channel(rb->_BaseFormat,
+                                               GL_TEXTURE_ALPHA_TYPE)) {
         srcRGB = brw_fix_xRGB_alpha(srcRGB);
         srcA   = brw_fix_xRGB_alpha(srcA);
         dstRGB = brw_fix_xRGB_alpha(dstRGB);