From 488d7fc67d36bc0e5247f5d011e8ad4c2dceb5a7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 24 Dec 2011 08:54:25 -0700 Subject: [PATCH] mesa: add _mesa_get_format_max_bits() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Returns max bits per channel for the given format. Reviewed-by: José Fonseca --- src/mesa/main/formats.c | 16 ++++++++++++++++ src/mesa/main/formats.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 1f83a5368d7..cca0014b178 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 e6b429d5f37..9609343387f 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); -- 2.30.2