From 26c4d804ffe6e5f04c47feef72e718c5ebf3ebe6 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Fri, 15 Dec 2017 23:04:49 +0100 Subject: [PATCH] i965: Support accelerated blit for depth 30 formats. (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Extend intel_miptree_blit() to handle at least ARGB2101010 -> XRGB2101010, ARGB2101010 -> ARGB2101010, and XRGB2101010 -> XRGB2101010 via the BLT engine, but not XRGB2101010 -> ARGB2101010 yet. This works as tested under Compiz, KDE-5, Gnome-Shell. v2: Restrict BLT fast path to exclude XRGB2101010 -> ARGB2101010, as intel_miptree_set_alpha_to_one() isn't ready to set 2 bit alpha channels to 1.0 yet. However, couldn't find a test case where this specific blit would be needed, so maybe not much of a point to improve here. Signed-off-by: Mario Kleiner Reviewed-by: Tapani Pälli Signed-off-by: Marek Olšák --- src/mesa/drivers/dri/i965/intel_blit.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/intel_blit.c b/src/mesa/drivers/dri/i965/intel_blit.c index 5f25bfaf616..46945b29953 100644 --- a/src/mesa/drivers/dri/i965/intel_blit.c +++ b/src/mesa/drivers/dri/i965/intel_blit.c @@ -170,6 +170,19 @@ intel_miptree_blit_compatible_formats(mesa_format src, mesa_format dst) return (dst == MESA_FORMAT_R8G8B8A8_UNORM || dst == MESA_FORMAT_R8G8B8X8_UNORM); + /* We can also discard alpha when going from A2->X2 for 2 bit alpha, + * however we can't fill the alpha channel with two 1 bits when going + * from X2->A2, because intel_miptree_set_alpha_to_one() is not yet + * ready for this / can only handle 8 bit alpha. + */ + if (src == MESA_FORMAT_B10G10R10A2_UNORM) + return (dst == MESA_FORMAT_B10G10R10A2_UNORM || + dst == MESA_FORMAT_B10G10R10X2_UNORM); + + if (src == MESA_FORMAT_R10G10B10A2_UNORM) + return (dst == MESA_FORMAT_R10G10B10A2_UNORM || + dst == MESA_FORMAT_R10G10B10X2_UNORM); + return false; } @@ -322,7 +335,8 @@ intel_miptree_blit(struct brw_context *brw, /* 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. + * channel to 1.0 at the end. Also trivially ARGB2101010 to XRGB2101010, + * but not XRGB2101010 to ARGB2101010 yet. */ if (!intel_miptree_blit_compatible_formats(src_format, dst_format)) { perf_debug("%s: Can't use hardware blitter from %s to %s, " @@ -789,6 +803,10 @@ intel_miptree_set_alpha_to_one(struct brw_context *brw, DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n", __func__, mt->bo, pitch, x, y, width, height); + /* Note: Currently only handles 8 bit alpha channel. Extension to < 8 Bit + * alpha channel would be likely possible via ROP code 0xfa instead of 0xf0 + * and writing a suitable bit-mask instead of 0xffffffff. + */ BR13 = br13_for_cpp(cpp) | 0xf0 << 16; CMD = XY_COLOR_BLT_CMD; CMD |= XY_BLT_WRITE_ALPHA; -- 2.30.2