mesa: Add utility function _mesa_is_enum_format_snorm()
authorAnuj Phogat <anuj.phogat@gmail.com>
Fri, 6 Jun 2014 21:47:52 +0000 (14:47 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Tue, 5 Aug 2014 00:11:25 +0000 (17:11 -0700)
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 304d45298e5d692d0bff0cd623d95bd42faf7195..a0c7170dd32b43a0d62eca4b85a020f909810979 100644 (file)
@@ -353,6 +353,43 @@ _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type)
    }
 }
 
+/**
+ * Test if the given format is a SNORM (signed-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_snorm(GLenum format)
+{
+   switch (format) {
+   /* signed, normalized texture formats */
+   case GL_RED_SNORM:
+   case GL_R8_SNORM:
+   case GL_R16_SNORM:
+   case GL_RG_SNORM:
+   case GL_RG8_SNORM:
+   case GL_RG16_SNORM:
+   case GL_RGB_SNORM:
+   case GL_RGB8_SNORM:
+   case GL_RGB16_SNORM:
+   case GL_RGBA_SNORM:
+   case GL_RGBA8_SNORM:
+   case GL_RGBA16_SNORM:
+   case GL_ALPHA_SNORM:
+   case GL_ALPHA8_SNORM:
+   case GL_ALPHA16_SNORM:
+   case GL_LUMINANCE_SNORM:
+   case GL_LUMINANCE8_SNORM:
+   case GL_LUMINANCE16_SNORM:
+   case GL_LUMINANCE_ALPHA_SNORM:
+   case GL_LUMINANCE8_ALPHA8_SNORM:
+   case GL_LUMINANCE16_ALPHA16_SNORM:
+   case GL_INTENSITY_SNORM:
+   case GL_INTENSITY8_SNORM:
+   case GL_INTENSITY16_SNORM:
+      return GL_TRUE;
+   default:
+      return GL_FALSE;
+   }
+}
 
 /**
  * Test if the given format is an integer (non-normalized) format.
index d64114ec9b0ba1df590225ecb96255d2cdace9aa..76e9a2493d649f639f149f5bbcb9152d820dd6d6 100644 (file)
@@ -56,6 +56,9 @@ _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type);
 extern GLboolean
 _mesa_is_type_unsigned(GLenum type);
 
+extern GLboolean
+_mesa_is_enum_format_snorm(GLenum format);
+
 extern GLboolean
 _mesa_is_enum_format_integer(GLenum format);