summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-09-27 19:07:44 -0600
committerBrian Paul <[email protected]>2009-09-27 19:07:44 -0600
commitc28d78f8324cfc17936af63c258a1cc55d590d60 (patch)
tree86932dd40ec67f5be25d7f0703668522be3c5bf6 /src/mesa/main
parenta608257a02d2ba4e8119be462bbd40ed238b184a (diff)
mesa: added _mesa_get_format_bits()
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/formats.c31
-rw-r--r--src/mesa/main/formats.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 5c2bf5ece3e..62a2d70744d 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -24,6 +24,7 @@
*/
+#include "imports.h"
#include "formats.h"
#include "config.h"
#include "texstore.h"
@@ -785,3 +786,33 @@ _mesa_format_to_type_and_comps2(gl_format format,
}
}
+
+GLint
+_mesa_get_format_bits(gl_format format, GLenum pname)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+
+ switch (pname) {
+ case GL_TEXTURE_RED_SIZE:
+ return info->RedBits;
+ case GL_TEXTURE_GREEN_SIZE:
+ return info->GreenBits;
+ case GL_TEXTURE_BLUE_SIZE:
+ return info->BlueBits;
+ case GL_TEXTURE_ALPHA_SIZE:
+ return info->AlphaBits;
+ case GL_TEXTURE_INTENSITY_SIZE:
+ return info->IntensityBits;
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ return info->LuminanceBits;
+ case GL_TEXTURE_INDEX_SIZE_EXT:
+ return info->IndexBits;
+ case GL_TEXTURE_DEPTH_SIZE_ARB:
+ return info->DepthBits;
+ case GL_TEXTURE_STENCIL_SIZE_EXT:
+ return info->StencilBits;
+ default:
+ _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()");
+ return 0;
+ }
+}
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index e79991ad410..441cf3eac6d 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -208,6 +208,10 @@ extern void
_mesa_format_to_type_and_comps2(gl_format format,
GLenum *datatype, GLuint *comps);
+extern GLint
+_mesa_get_format_bits(gl_format format, GLenum pname);
+
+
extern void
_mesa_test_formats(void);