mesa: add MAX_PIXEL_BYTES define
authorBrian Paul <brianp@vmware.com>
Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 8 Dec 2011 15:56:31 +0000 (08:56 -0700)
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 <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/formats.c
src/mesa/main/formats.h

index 595da77..1f83a53 100644 (file)
@@ -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;
 }
 
index 3960f02..e6b429d 100644 (file)
@@ -47,6 +47,14 @@ extern "C" {
 
 
 /**
+ * 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.
  */
 typedef enum