[Mesa-dev] [PATCH 04/23] glformats: add functions to detect signed/unsigned integer types

Jordan Justen jordan.l.justen at intel.com
Fri Jan 4 18:41:27 PST 2013


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/main/glformats.c |   54 +++++++++++++++++++++++++++++++++------------
 src/mesa/main/glformats.h |    6 +++++
 2 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index d3ed809..d2126bb 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -353,21 +353,9 @@ _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type)
  * Test if the given format is an integer (non-normalized) format.
  */
 GLboolean
-_mesa_is_enum_format_integer(GLenum format)
+_mesa_is_enum_format_unsigned_int(GLenum format)
 {
    switch (format) {
-   /* generic integer formats */
-   case GL_RED_INTEGER_EXT:
-   case GL_GREEN_INTEGER_EXT:
-   case GL_BLUE_INTEGER_EXT:
-   case GL_ALPHA_INTEGER_EXT:
-   case GL_RGB_INTEGER_EXT:
-   case GL_RGBA_INTEGER_EXT:
-   case GL_BGR_INTEGER_EXT:
-   case GL_BGRA_INTEGER_EXT:
-   case GL_LUMINANCE_INTEGER_EXT:
-   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
-   case GL_RG_INTEGER:
    /* specific integer formats */
    case GL_RGBA32UI_EXT:
    case GL_RGB32UI_EXT:
@@ -393,6 +381,34 @@ _mesa_is_enum_format_integer(GLenum format)
    case GL_INTENSITY8UI_EXT:
    case GL_LUMINANCE8UI_EXT:
    case GL_LUMINANCE_ALPHA8UI_EXT:
+   case GL_RGB10_A2UI:
+      return GL_TRUE;
+   default:
+      return GL_FALSE;
+   }
+}
+
+
+/**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_signed_int(GLenum format)
+{
+   switch (format) {
+   /* generic integer formats */
+   case GL_RED_INTEGER_EXT:
+   case GL_GREEN_INTEGER_EXT:
+   case GL_BLUE_INTEGER_EXT:
+   case GL_ALPHA_INTEGER_EXT:
+   case GL_RGB_INTEGER_EXT:
+   case GL_RGBA_INTEGER_EXT:
+   case GL_BGR_INTEGER_EXT:
+   case GL_BGRA_INTEGER_EXT:
+   case GL_LUMINANCE_INTEGER_EXT:
+   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+   case GL_RG_INTEGER:
+   /* specific integer formats */
    case GL_RGBA32I_EXT:
    case GL_RGB32I_EXT:
    case GL_RG32I:
@@ -417,7 +433,6 @@ _mesa_is_enum_format_integer(GLenum format)
    case GL_INTENSITY8I_EXT:
    case GL_LUMINANCE8I_EXT:
    case GL_LUMINANCE_ALPHA8I_EXT:
-   case GL_RGB10_A2UI:
       return GL_TRUE;
    default:
       return GL_FALSE;
@@ -426,6 +441,17 @@ _mesa_is_enum_format_integer(GLenum format)
 
 
 /**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_integer(GLenum format)
+{
+   return _mesa_is_enum_format_unsigned_int(format) ||
+          _mesa_is_enum_format_signed_int(format);
+}
+
+
+/**
  * Test if the given type is an integer (non-normalized) format.
  */
 GLboolean
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
index ccfb5e1..d1208ef 100644
--- a/src/mesa/main/glformats.h
+++ b/src/mesa/main/glformats.h
@@ -62,6 +62,12 @@ extern GLboolean
 _mesa_is_enum_format_integer(GLenum format);
 
 extern GLboolean
+_mesa_is_enum_format_unsigned_int(GLenum format);
+
+extern GLboolean
+_mesa_is_enum_format_signed_int(GLenum format);
+
+extern GLboolean
 _mesa_is_enum_format_or_type_integer(GLenum format, GLenum type);
 
 extern GLboolean
-- 
1.7.10.4



More information about the mesa-dev mailing list