From: Brian Paul Date: Tue, 6 Dec 2011 03:40:48 +0000 (-0700) Subject: mesa: add MAX_PIXEL_BYTES define X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=db247dd7b37e22bf9545d8cb8360e06d68e50912;p=mesa.git mesa: add MAX_PIXEL_BYTES define In a few places we need to allocate space for some number of generic pixels. Use this new define instead of a magic number like 16 or 4 * sizeof(GLuint). Reviewed-by: Jose Fonseca Reviewed-by: Eric Anholt --- diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 595da773ba5..1f83a5368d7 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -1553,6 +1553,8 @@ _mesa_get_format_bytes(gl_format format) { const struct gl_format_info *info = _mesa_get_format_info(format); ASSERT(info->BytesPerBlock); + ASSERT(info->BytesPerBlock <= MAX_PIXEL_BYTES || + _mesa_is_format_compressed(format)); return info->BytesPerBlock; } diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 3960f028e4a..e6b429d5f37 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -46,6 +46,14 @@ extern "C" { #define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) +/** + * Max number of bytes for any non-compressed pixel format below, or for + * intermediate pixel storage in Mesa. This should never be less than + * 16. Maybe 32 someday? + */ +#define MAX_PIXEL_BYTES 16 + + /** * Mesa texture/renderbuffer image formats. */