[Mesa-dev] [PATCH 2/4] mesa: add _mesa_get_format_max_bits()

Brian Paul brianp at vmware.com
Sun Dec 18 18:18:40 PST 2011


Returns max bits per channel for the given format.
---
 src/mesa/main/formats.c |   16 ++++++++++++++++
 src/mesa/main/formats.h |    3 +++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 1f83a53..cca0014 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -27,6 +27,7 @@
 #include "imports.h"
 #include "formats.h"
 #include "mfeatures.h"
+#include "macros.h"
 
 
 /**
@@ -1613,6 +1614,21 @@ _mesa_get_format_bits(gl_format format, GLenum pname)
 }
 
 
+GLuint
+_mesa_get_format_max_bits(gl_format format)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   GLuint max = MAX2(info->RedBits, info->GreenBits);
+   max = MAX2(max, info->BlueBits);
+   max = MAX2(max, info->AlphaBits);
+   max = MAX2(max, info->LuminanceBits);
+   max = MAX2(max, info->IntensityBits);
+   max = MAX2(max, info->DepthBits);
+   max = MAX2(max, info->StencilBits);
+   return max;
+}
+
+
 /**
  * Return the data type (or more specifically, the data representation)
  * for the given format.
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index e6b429d..9609343 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -290,6 +290,9 @@ _mesa_get_format_bytes(gl_format format);
 extern GLint
 _mesa_get_format_bits(gl_format format, GLenum pname);
 
+extern GLuint
+_mesa_get_format_max_bits(gl_format format);
+
 extern GLenum
 _mesa_get_format_datatype(gl_format format);
 
-- 
1.7.3.4



More information about the mesa-dev mailing list