[Mesa-dev] [PATCH 2/3] i965: Use _mesa_format_x_to_a to support more X -> A blits.

Kenneth Graunke kenneth at whitecape.org
Tue Mar 25 18:01:27 PDT 2014


There's really no reason to limit ourselves to a single format; the
technique works just as well for any format in this family.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 10 ++--------
 src/mesa/drivers/dri/i965/intel_blit.c       | 16 +++++++---------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 9e80935..277c5ff 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -199,18 +199,12 @@ do_blorp_blit(struct brw_context *brw, GLbitfield buffer_bit,
 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
     * blitting from ARGB to XRGB (discarding alpha), and from XRGB to ARGB
     * (overriding alpha to 1.0 via blending).
     */
-   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 _mesa_get_srgb_format_linear(_mesa_format_x_to_a(src_format)) ==
+          _mesa_get_srgb_format_linear(_mesa_format_x_to_a(dst_format));
 }
 
 static bool
diff --git a/src/mesa/drivers/dri/i965/intel_blit.c b/src/mesa/drivers/dri/i965/intel_blit.c
index d482272..fb10072 100644
--- a/src/mesa/drivers/dri/i965/intel_blit.c
+++ b/src/mesa/drivers/dri/i965/intel_blit.c
@@ -166,19 +166,17 @@ intel_miptree_blit(struct brw_context *brw,
     * consistent with what we want in the callers (glCopyTexSubImage(),
     * glBlitFramebuffer(), texture validation, etc.).
     */
-   mesa_format src_format = _mesa_get_srgb_format_linear(src_mt->format);
-   mesa_format dst_format = _mesa_get_srgb_format_linear(dst_mt->format);
+   mesa_format src_format =
+      _mesa_get_srgb_format_linear(_mesa_format_x_to_a(src_mt->format));
+   mesa_format dst_format =
+      _mesa_get_srgb_format_linear(_mesa_format_x_to_a(dst_mt->format));
 
    /* The blitter doesn't support doing any format conversions.  We do also
     * support blitting ARGB8888 to XRGB8888 (trivial, the values dropped into
     * the X channel don't matter), and XRGB8888 to ARGB8888 by setting the A
     * channel to 1.0 at the end.
     */
-   if (src_format != dst_format &&
-      ((src_format != MESA_FORMAT_B8G8R8A8_UNORM &&
-        src_format != MESA_FORMAT_B8G8R8X8_UNORM) ||
-       (dst_format != MESA_FORMAT_B8G8R8A8_UNORM &&
-        dst_format != MESA_FORMAT_B8G8R8X8_UNORM))) {
+   if (src_format != dst_format) {
       perf_debug("%s: Can't use hardware blitter from %s to %s, "
                  "falling back.\n", __FUNCTION__,
                  _mesa_get_format_name(src_format),
@@ -275,8 +273,8 @@ intel_miptree_blit(struct brw_context *brw,
       return false;
    }
 
-   if (src_mt->format == MESA_FORMAT_B8G8R8X8_UNORM &&
-       dst_mt->format == MESA_FORMAT_B8G8R8A8_UNORM) {
+   if (src_mt->format != dst_mt->format &&
+       _mesa_format_x_to_a(src_mt->format) == dst_mt->format) {
       intel_miptree_set_alpha_to_one(brw, dst_mt,
                                      dst_x, dst_y,
                                      width, height);
-- 
1.9.0



More information about the mesa-dev mailing list