summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-04-20 12:17:40 -0400
committerMarge Bot <eric+marge@anholt.net>2021-04-20 19:18:55 +0000
commit2417cd3e0e5ae7125860718f43b2dee17e36dab4 (patch)
tree95ba64f86a2a38a8f50f514e7c55621d5f79b280
parent7f8c5844effddddf65770706e1200867f4d53546 (diff)
util/format: add util_format_is_rgbx_or_bgrx
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10351>
-rw-r--r--src/util/format/u_format.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util/format/u_format.h b/src/util/format/u_format.h
index f7b29b407a4..804dd3486a0 100644
--- a/src/util/format/u_format.h
+++ b/src/util/format/u_format.h
@@ -802,6 +802,19 @@ util_format_is_rgba8_variant(const struct util_format_description *desc)
return TRUE;
}
+
+static inline bool
+util_format_is_rgbx_or_bgrx(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
+ desc->nr_channels == 4 &&
+ (desc->swizzle[0] == PIPE_SWIZZLE_X || desc->swizzle[0] == PIPE_SWIZZLE_Z) &&
+ desc->swizzle[1] == PIPE_SWIZZLE_Y &&
+ (desc->swizzle[2] == PIPE_SWIZZLE_Z || desc->swizzle[2] == PIPE_SWIZZLE_X) &&
+ desc->swizzle[3] == PIPE_SWIZZLE_1;
+}
+
/**
* Return total bits needed for the pixel format per block.
*/