diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/arrayobj.h | 1 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 1 | ||||
-rw-r--r-- | src/mesa/main/fbobject.c | 2 | ||||
-rw-r--r-- | src/mesa/main/glformats.c | 365 | ||||
-rw-r--r-- | src/mesa/main/glformats.h | 20 | ||||
-rw-r--r-- | src/mesa/main/image.c | 369 | ||||
-rw-r--r-- | src/mesa/main/image.h | 18 | ||||
-rw-r--r-- | src/mesa/main/mipmap.c | 1 | ||||
-rw-r--r-- | src/mesa/main/pbo.c | 1 | ||||
-rw-r--r-- | src/mesa/main/texparam.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_array.c | 3 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_split_copy.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_split_inplace.c | 2 |
13 files changed, 395 insertions, 392 deletions
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h index e5270fa2cec..4f89064bb66 100644 --- a/src/mesa/main/arrayobj.h +++ b/src/mesa/main/arrayobj.h @@ -30,6 +30,7 @@ #include "glheader.h" #include "mtypes.h" +#include "glformats.h" struct gl_context; diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 40961b15c43..510fd1e18b3 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -51,6 +51,7 @@ #endif #include "framebuffer.h" #include "glapi/glapi.h" +#include "glformats.h" #include "hash.h" #include "image.h" #include "light.h" diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index ca43f810553..ece1251fa40 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -38,8 +38,8 @@ #include "fbobject.h" #include "formats.h" #include "framebuffer.h" +#include "glformats.h" #include "hash.h" -#include "image.h" #include "macros.h" #include "mfeatures.h" #include "mtypes.h" diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index c28543cf008..8c20f7759d9 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -29,6 +29,285 @@ /** + * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. + */ +GLboolean +_mesa_type_is_packed(GLenum type) +{ + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case MESA_UNSIGNED_BYTE_4_4: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + case GL_UNSIGNED_INT_24_8_EXT: + case GL_UNSIGNED_INT_5_9_9_9_REV: + case GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Get the size of a GL data type. + * + * \param type GL data type. + * + * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1 + * if an invalid type enum. + */ +GLint +_mesa_sizeof_type(GLenum type) +{ + switch (type) { + case GL_BITMAP: + return 0; + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_INT: + return sizeof(GLint); + case GL_FLOAT: + return sizeof(GLfloat); + case GL_DOUBLE: + return sizeof(GLdouble); + case GL_HALF_FLOAT_ARB: + return sizeof(GLhalfARB); + case GL_FIXED: + return sizeof(GLfixed); + default: + return -1; + } +} + + +/** + * Same as _mesa_sizeof_type() but also accepting the packed pixel + * format data types. + */ +GLint +_mesa_sizeof_packed_type(GLenum type) +{ + switch (type) { + case GL_BITMAP: + return 0; + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_INT: + return sizeof(GLint); + case GL_HALF_FLOAT_ARB: + return sizeof(GLhalfARB); + case GL_FLOAT: + return sizeof(GLfloat); + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case MESA_UNSIGNED_BYTE_4_4: + return sizeof(GLubyte); + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + return sizeof(GLushort); + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_24_8_EXT: + case GL_UNSIGNED_INT_5_9_9_9_REV: + case GL_UNSIGNED_INT_10F_11F_11F_REV: + return sizeof(GLuint); + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + return 8; + default: + return -1; + } +} + + +/** + * Get the number of components in a pixel format. + * + * \param format pixel format. + * + * \return the number of components in the given format, or -1 if a bad format. + */ +GLint +_mesa_components_in_format(GLenum format) +{ + switch (format) { + case GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_RED_INTEGER_EXT: + case GL_GREEN: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA: + case GL_ALPHA_INTEGER_EXT: + case GL_LUMINANCE: + case GL_LUMINANCE_INTEGER_EXT: + case GL_INTENSITY: + return 1; + + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + case GL_RG: + case GL_YCBCR_MESA: + case GL_DEPTH_STENCIL_EXT: + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + case GL_RG_INTEGER: + return 2; + + case GL_RGB: + case GL_BGR: + case GL_RGB_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + return 3; + + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + return 4; + + default: + return -1; + } +} + + +/** + * Get the bytes per pixel of pixel format type pair. + * + * \param format pixel format. + * \param type pixel type. + * + * \return bytes per pixel, or -1 if a bad format or type was given. + */ +GLint +_mesa_bytes_per_pixel(GLenum format, GLenum type) +{ + GLint comps = _mesa_components_in_format(format); + if (comps < 0) + return -1; + + switch (type) { + case GL_BITMAP: + return 0; /* special case */ + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return comps * sizeof(GLubyte); + case GL_SHORT: + case GL_UNSIGNED_SHORT: + return comps * sizeof(GLshort); + case GL_INT: + case GL_UNSIGNED_INT: + return comps * sizeof(GLint); + case GL_FLOAT: + return comps * sizeof(GLfloat); + case GL_HALF_FLOAT_ARB: + return comps * sizeof(GLhalfARB); + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + if (format == GL_RGB || format == GL_BGR || + format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) + return sizeof(GLubyte); + else + return -1; /* error */ + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + if (format == GL_RGB || format == GL_BGR || + format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) + return sizeof(GLushort); + else + return -1; /* error */ + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || + format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) + return sizeof(GLushort); + else + return -1; + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || + format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) + return sizeof(GLuint); + else + return -1; + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + if (format == GL_YCBCR_MESA) + return sizeof(GLushort); + else + return -1; + case GL_UNSIGNED_INT_24_8_EXT: + if (format == GL_DEPTH_STENCIL_EXT) + return sizeof(GLuint); + else + return -1; + case GL_UNSIGNED_INT_5_9_9_9_REV: + if (format == GL_RGB) + return sizeof(GLuint); + else + return -1; + case GL_UNSIGNED_INT_10F_11F_11F_REV: + if (format == GL_RGB) + return sizeof(GLuint); + else + return -1; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + if (format == GL_DEPTH_STENCIL) + return 8; + else + return -1; + default: + return -1; + } +} + + +/** * Test if the given format is an integer (non-normalized) format. */ GLboolean @@ -595,3 +874,89 @@ _mesa_base_format_to_integer_format(GLenum format) return format; } + +/** + * Does the given base texture/renderbuffer format have the channel + * named by 'pname'? + */ +GLboolean +_mesa_base_format_has_channel(GLenum base_format, GLenum pname) +{ + switch (pname) { + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_RED_TYPE: + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + if (base_format == GL_RED || + base_format == GL_RG || + base_format == GL_RGB || + base_format == GL_RGBA) { + return GL_TRUE; + } + return GL_FALSE; + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_GREEN_TYPE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + if (base_format == GL_RG || + base_format == GL_RGB || + base_format == GL_RGBA) { + return GL_TRUE; + } + return GL_FALSE; + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_BLUE_TYPE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + if (base_format == GL_RGB || + base_format == GL_RGBA) { + return GL_TRUE; + } + return GL_FALSE; + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_ALPHA_TYPE: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + if (base_format == GL_RGBA || + base_format == GL_ALPHA || + base_format == GL_LUMINANCE_ALPHA) { + return GL_TRUE; + } + return GL_FALSE; + case GL_TEXTURE_LUMINANCE_SIZE: + case GL_TEXTURE_LUMINANCE_TYPE: + if (base_format == GL_LUMINANCE || + base_format == GL_LUMINANCE_ALPHA) { + return GL_TRUE; + } + return GL_FALSE; + case GL_TEXTURE_INTENSITY_SIZE: + case GL_TEXTURE_INTENSITY_TYPE: + if (base_format == GL_INTENSITY) { + return GL_TRUE; + } + return GL_FALSE; + case GL_TEXTURE_DEPTH_SIZE: + case GL_TEXTURE_DEPTH_TYPE: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + if (base_format == GL_DEPTH_STENCIL || + base_format == GL_DEPTH_COMPONENT) { + return GL_TRUE; + } + return GL_FALSE; + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + if (base_format == GL_DEPTH_STENCIL || + base_format == GL_STENCIL_INDEX) { + return GL_TRUE; + } + return GL_FALSE; + default: + _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n", + __FUNCTION__, pname); + return GL_FALSE; + } + + return GL_FALSE; +} diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h index 075b07faa0e..efde4f9ba62 100644 --- a/src/mesa/main/glformats.h +++ b/src/mesa/main/glformats.h @@ -35,6 +35,21 @@ extern "C" { #endif extern GLboolean +_mesa_type_is_packed(GLenum type); + +extern GLint +_mesa_sizeof_type( GLenum type ); + +extern GLint +_mesa_sizeof_packed_type( GLenum type ); + +extern GLint +_mesa_components_in_format( GLenum format ); + +extern GLint +_mesa_bytes_per_pixel( GLenum format, GLenum type ); + +extern GLboolean _mesa_is_type_integer(GLenum type); extern GLboolean @@ -73,9 +88,12 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format); extern GLenum _mesa_base_format_to_integer_format(GLenum format); +extern GLboolean +_mesa_base_format_has_channel(GLenum base_format, GLenum pname); + + #ifdef __cplusplus } #endif #endif /* GLFORMATS_H */ - diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 5b70115db78..64176552c3f 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -32,6 +32,7 @@ #include "glheader.h" #include "colormac.h" +#include "glformats.h" #include "image.h" #include "imports.h" #include "macros.h" @@ -41,40 +42,6 @@ /** - * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. - */ -GLboolean -_mesa_type_is_packed(GLenum type) -{ - switch (type) { - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case MESA_UNSIGNED_BYTE_4_4: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - case GL_UNSIGNED_INT_24_8_EXT: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - return GL_TRUE; - } - - return GL_FALSE; -} - - - -/** * Flip the order of the 2 bytes in each word in the given array. * * \param p array. @@ -110,252 +77,6 @@ _mesa_swap4( GLuint *p, GLuint n ) /** - * Get the size of a GL data type. - * - * \param type GL data type. - * - * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1 - * if an invalid type enum. - */ -GLint -_mesa_sizeof_type( GLenum type ) -{ - switch (type) { - case GL_BITMAP: - return 0; - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_DOUBLE: - return sizeof(GLdouble); - case GL_HALF_FLOAT_ARB: - return sizeof(GLhalfARB); - case GL_FIXED: - return sizeof(GLfixed); - default: - return -1; - } -} - - -/** - * Same as _mesa_sizeof_type() but also accepting the packed pixel - * format data types. - */ -GLint -_mesa_sizeof_packed_type( GLenum type ) -{ - switch (type) { - case GL_BITMAP: - return 0; - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_HALF_FLOAT_ARB: - return sizeof(GLhalfARB); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case MESA_UNSIGNED_BYTE_4_4: - return sizeof(GLubyte); - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - return sizeof(GLushort); - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_INT_24_8_EXT: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - return sizeof(GLuint); - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - return 8; - default: - return -1; - } -} - - -/** - * Get the number of components in a pixel format. - * - * \param format pixel format. - * - * \return the number of components in the given format, or -1 if a bad format. - */ -GLint -_mesa_components_in_format( GLenum format ) -{ - switch (format) { - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - case GL_DEPTH_COMPONENT: - case GL_RED: - case GL_RED_INTEGER_EXT: - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - case GL_INTENSITY: - return 1; - - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - case GL_RG: - case GL_YCBCR_MESA: - case GL_DEPTH_STENCIL_EXT: - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - case GL_RG_INTEGER: - return 2; - - case GL_RGB: - case GL_BGR: - case GL_RGB_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - return 3; - - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - return 4; - - default: - return -1; - } -} - - -/** - * Get the bytes per pixel of pixel format type pair. - * - * \param format pixel format. - * \param type pixel type. - * - * \return bytes per pixel, or -1 if a bad format or type was given. - */ -GLint -_mesa_bytes_per_pixel( GLenum format, GLenum type ) -{ - GLint comps = _mesa_components_in_format( format ); - if (comps < 0) - return -1; - - switch (type) { - case GL_BITMAP: - return 0; /* special case */ - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return comps * sizeof(GLubyte); - case GL_SHORT: - case GL_UNSIGNED_SHORT: - return comps * sizeof(GLshort); - case GL_INT: - case GL_UNSIGNED_INT: - return comps * sizeof(GLint); - case GL_FLOAT: - return comps * sizeof(GLfloat); - case GL_HALF_FLOAT_ARB: - return comps * sizeof(GLhalfARB); - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - if (format == GL_RGB || format == GL_BGR || - format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) - return sizeof(GLubyte); - else - return -1; /* error */ - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (format == GL_RGB || format == GL_BGR || - format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) - return sizeof(GLushort); - else - return -1; /* error */ - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || - format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) - return sizeof(GLushort); - else - return -1; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || - format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) - return sizeof(GLuint); - else - return -1; - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - if (format == GL_YCBCR_MESA) - return sizeof(GLushort); - else - return -1; - case GL_UNSIGNED_INT_24_8_EXT: - if (format == GL_DEPTH_STENCIL_EXT) - return sizeof(GLuint); - else - return -1; - case GL_UNSIGNED_INT_5_9_9_9_REV: - if (format == GL_RGB) - return sizeof(GLuint); - else - return -1; - case GL_UNSIGNED_INT_10F_11F_11F_REV: - if (format == GL_RGB) - return sizeof(GLuint); - else - return -1; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - if (format == GL_DEPTH_STENCIL) - return 8; - else - return -1; - default: - return -1; - } -} - - -/** * Do error checking of format/type combinations for glReadPixels, * glDrawPixels and glTex[Sub]Image. Note that depending on the format * and type values, we may either generate GL_INVALID_OPERATION or @@ -722,94 +443,6 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx, } - -/** - * Does the given base texture/renderbuffer format have the channel - * named by 'pname'? - */ -GLboolean -_mesa_base_format_has_channel(GLenum base_format, GLenum pname) -{ - switch (pname) { - case GL_TEXTURE_RED_SIZE: - case GL_TEXTURE_RED_TYPE: - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - if (base_format == GL_RED || - base_format == GL_RG || - base_format == GL_RGB || - base_format == GL_RGBA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_GREEN_SIZE: - case GL_TEXTURE_GREEN_TYPE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - if (base_format == GL_RG || - base_format == GL_RGB || - base_format == GL_RGBA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_BLUE_SIZE: - case GL_TEXTURE_BLUE_TYPE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - if (base_format == GL_RGB || - base_format == GL_RGBA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_ALPHA_SIZE: - case GL_TEXTURE_ALPHA_TYPE: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - if (base_format == GL_RGBA || - base_format == GL_ALPHA || - base_format == GL_LUMINANCE_ALPHA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_LUMINANCE_SIZE: - case GL_TEXTURE_LUMINANCE_TYPE: - if (base_format == GL_LUMINANCE || - base_format == GL_LUMINANCE_ALPHA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_INTENSITY_SIZE: - case GL_TEXTURE_INTENSITY_TYPE: - if (base_format == GL_INTENSITY) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_DEPTH_SIZE: - case GL_TEXTURE_DEPTH_TYPE: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - if (base_format == GL_DEPTH_STENCIL || - base_format == GL_DEPTH_COMPONENT) { - return GL_TRUE; - } - return GL_FALSE; - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (base_format == GL_DEPTH_STENCIL || - base_format == GL_STENCIL_INDEX) { - return GL_TRUE; - } - return GL_FALSE; - default: - _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n", - __FUNCTION__, pname); - return GL_FALSE; - } - - return GL_FALSE; -} - - /** * Return the byte offset of a specific pixel in an image (1D, 2D or 3D). * diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 1de94ac64b2..09770587452 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -38,28 +38,10 @@ _mesa_swap2( GLushort *p, GLuint n ); extern void _mesa_swap4( GLuint *p, GLuint n ); -extern GLboolean -_mesa_type_is_packed(GLenum type); - -extern GLint -_mesa_sizeof_type( GLenum type ); - -extern GLint -_mesa_sizeof_packed_type( GLenum type ); - -extern GLint -_mesa_components_in_format( GLenum format ); - -extern GLint -_mesa_bytes_per_pixel( GLenum format, GLenum type ); - extern GLenum _mesa_error_check_format_and_type(const struct gl_context *ctx, GLenum format, GLenum type); -extern GLboolean -_mesa_base_format_has_channel(GLenum base_format, GLenum pname); - extern GLintptr _mesa_image_offset( GLuint dimensions, const struct gl_pixelstore_attrib *packing, diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 250d3c6dcf9..9f531ae20bb 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -29,6 +29,7 @@ #include "imports.h" #include "formats.h" +#include "glformats.h" #include "mipmap.h" #include "mtypes.h" #include "teximage.h" diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index d4dfbcddd0f..c73d7492f55 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -32,6 +32,7 @@ #include "glheader.h" #include "bufferobj.h" +#include "glformats.h" #include "image.h" #include "imports.h" #include "mtypes.h" diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 9abc503e314..1376219d72a 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -35,7 +35,7 @@ #include "main/context.h" #include "main/enums.h" #include "main/formats.h" -#include "main/image.h" +#include "main/glformats.h" #include "main/macros.h" #include "main/mfeatures.h" #include "main/mtypes.h" diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c index d60b0d7a950..ab46f11887e 100644 --- a/src/mesa/state_tracker/st_atom_array.c +++ b/src/mesa/state_tracker/st_atom_array.c @@ -1,3 +1,4 @@ + /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. @@ -45,7 +46,7 @@ #include "util/u_math.h" #include "main/bufferobj.h" -#include "main/image.h" +#include "main/glformats.h" static GLuint double_types[4] = { diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 528fcfd7f80..a917f39ca4f 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -32,7 +32,7 @@ #include "main/glheader.h" #include "main/bufferobj.h" #include "main/imports.h" -#include "main/image.h" +#include "main/glformats.h" #include "main/macros.h" #include "main/mtypes.h" diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c index 686b30a7663..8a38308052d 100644 --- a/src/mesa/vbo/vbo_split_inplace.c +++ b/src/mesa/vbo/vbo_split_inplace.c @@ -30,7 +30,7 @@ #include "main/mtypes.h" #include "main/macros.h" #include "main/enums.h" -#include "main/image.h" +#include "main/glformats.h" #include "vbo_split.h" |