From: Anuj Phogat Date: Fri, 6 Jun 2014 19:35:55 +0000 (-0700) Subject: mesa: Add utility function _mesa_is_enum_format_unorm() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=938b3d003401538ceadac28ec5fe0e6ca583d2a6;p=mesa.git mesa: Add utility function _mesa_is_enum_format_unorm() V2: Add missing formats. Cc: Signed-off-by: Anuj Phogat Reviewed-by: Jason Ekstrand --- diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 77eee4f22ea..0fb25ba0ff3 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -409,6 +409,77 @@ _mesa_is_enum_format_unsized(GLenum format) } } +/** + * Test if the given format is a UNORM (unsigned-normalized) format. + */ +GLboolean +_mesa_is_enum_format_unorm(GLenum format) +{ + switch(format) { + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + case 1: + case GL_LUMINANCE: + case GL_SLUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + case 2: + case GL_LUMINANCE_ALPHA: + case GL_SLUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + case GL_R8: + case GL_R16: + case GL_RG: + case GL_RG8: + case GL_RG16: + case 3: + case GL_RGB: + case GL_BGR: + case GL_SRGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB565: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + case 4: + case GL_ABGR_EXT: + case GL_RGBA: + case GL_BGRA: + case GL_SRGB_ALPHA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_TRUE; + default: + return GL_FALSE; + } +} + /** * Test if the given format is a SNORM (signed-normalized) format. */ diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h index 6c553aee821..7b032157076 100644 --- a/src/mesa/main/glformats.h +++ b/src/mesa/main/glformats.h @@ -59,6 +59,9 @@ _mesa_is_type_unsigned(GLenum type); extern GLboolean _mesa_is_enum_format_unsized(GLenum format); +extern GLboolean +_mesa_is_enum_format_unorm(GLenum format); + extern GLboolean _mesa_is_enum_format_snorm(GLenum format);