Mesa (master): i965: Allow the blorp blit between BGR and RGB

Neil Roberts nroberts at kemper.freedesktop.org
Mon Jun 23 19:03:31 UTC 2014


Module: Mesa
Branch: master
Commit: 5f11b10f2c6a7dc94b8abdbffb755505f8a3a0ec
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f11b10f2c6a7dc94b8abdbffb755505f8a3a0ec

Author: Neil Roberts <neil at linux.intel.com>
Date:   Mon Jun 23 17:43:08 2014 +0100

i965: Allow the blorp blit between BGR and RGB

Previously the blorp blitter would only be used if the format is identical or
there is only a difference between whether there is an alpha component or not.
This patch makes it also allow the blorp blitter if the only difference is the
ordering of the RGB components (ie, RGB or BGR).

This is particularly useful since commit 61e264f4fcdba3623 because Mesa now
prefers RGB ordering for textures but the window system buffers are still
created as BGR. That means that the blorp blitter won't be used for the
(probably) common case of blitting from a texture to the window system buffer.

This doesn't cause any regressions in the FBO piglit tests on Haswell. On
Sandybridge it causes the fbo-blit-stretch test to fail but that is only
because it was failing anyway before the above commit and that commit hid the
problem.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68365
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp |   28 +++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 118af27..d7f5f7d 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -120,20 +120,34 @@ do_blorp_blit(struct brw_context *brw, GLbitfield buffer_bit,
 }
 
 static bool
+format_is_rgba_or_rgbx_byte(mesa_format format)
+{
+   switch (format) {
+   case MESA_FORMAT_B8G8R8X8_UNORM:
+   case MESA_FORMAT_B8G8R8A8_UNORM:
+   case MESA_FORMAT_R8G8B8X8_UNORM:
+   case MESA_FORMAT_R8G8B8A8_UNORM:
+      return true;
+   default:
+      return false;
+   }
+}
+
+static bool
 color_formats_match(mesa_format src_format, mesa_format dst_format)
 {
    mesa_format linear_src_format = _mesa_get_srgb_format_linear(src_format);
    mesa_format linear_dst_format = _mesa_get_srgb_format_linear(dst_format);
 
-   /* Normally, we require the formats to be equal.  However, we also support
+   /* Normally, we require the formats to be equal. However, we also support
     * blitting from ARGB to XRGB (discarding alpha), and from XRGB to ARGB
-    * (overriding alpha to 1.0 via blending).
+    * (overriding alpha to 1.0 via blending) as well as swizzling between BGR
+    * and RGB.
     */
-   return linear_src_format == linear_dst_format ||
-          (linear_src_format == MESA_FORMAT_B8G8R8X8_UNORM &&
-           linear_dst_format == MESA_FORMAT_B8G8R8A8_UNORM) ||
-          (linear_src_format == MESA_FORMAT_B8G8R8A8_UNORM &&
-           linear_dst_format == MESA_FORMAT_B8G8R8X8_UNORM);
+
+   return (linear_src_format == linear_dst_format ||
+           (format_is_rgba_or_rgbx_byte(linear_src_format) &&
+            format_is_rgba_or_rgbx_byte(linear_dst_format)));
 }
 
 static bool




More information about the mesa-commit mailing list