From: Jason Ekstrand Date: Tue, 26 Aug 2014 21:26:44 +0000 (-0700) Subject: mesa: Add a _mesa_is_format_color_format helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f89793946af22b720f746a5fb8b33d7b2f3e199b;p=mesa.git mesa: Add a _mesa_is_format_color_format helper Reviewed-by: Jason Ekstrand Reviewed-by: Anuj Phogat --- diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index b10b628235c..6eb80fb575d 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -472,6 +472,25 @@ _mesa_is_format_integer(mesa_format format) return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT); } + +/** + * Return true if the given format is a color format. + */ +GLenum +_mesa_is_format_color_format(mesa_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + switch (info->BaseFormat) { + case GL_DEPTH_COMPONENT: + case GL_STENCIL_INDEX: + case GL_DEPTH_STENCIL: + return false; + default: + return true; + } +} + + /** * Return color encoding for given format. * \return GL_LINEAR or GL_SRGB diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index dd07c35f5d9..4f83208bd4c 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -625,6 +625,9 @@ _mesa_is_format_integer(mesa_format format); extern bool _mesa_is_format_etc2(mesa_format format); +GLenum +_mesa_is_format_color_format(mesa_format format); + extern GLenum _mesa_get_format_color_encoding(mesa_format format);