mesa: Add utility function _mesa_is_enum_format_unorm()
authorAnuj Phogat <anuj.phogat@gmail.com>
Fri, 6 Jun 2014 19:35:55 +0000 (12:35 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Tue, 5 Aug 2014 00:12:14 +0000 (17:12 -0700)
V2: Add missing formats.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/main/glformats.c
src/mesa/main/glformats.h

index 77eee4f22ea35319b4813c4482be8b8aac62bba1..0fb25ba0ff3af8b3f483c2c8348b5a78594b10b9 100644 (file)
@@ -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.
  */
index 6c553aee821305f6cab6ef1acf623429ae9ce1fb..7b03215707643ec7d0418ab858a145581827078e 100644 (file)
@@ -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);