aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/image.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-02-08 16:41:27 +0100
committermarha <marha@users.sourceforge.net>2012-02-08 16:41:27 +0100
commit03346747e21e4cd1db30c6a5d8af6705575e3755 (patch)
tree120604af21bdac64007a0a3005dcce420cb76714 /mesalib/src/mesa/main/image.c
parentada3d2c30b5a7a1a79e128b7326d50c3bab77a8a (diff)
downloadvcxsrv-03346747e21e4cd1db30c6a5d8af6705575e3755.tar.gz
vcxsrv-03346747e21e4cd1db30c6a5d8af6705575e3755.tar.bz2
vcxsrv-03346747e21e4cd1db30c6a5d8af6705575e3755.zip
mesa git update 8 feb 2012
Diffstat (limited to 'mesalib/src/mesa/main/image.c')
-rw-r--r--mesalib/src/mesa/main/image.c216
1 files changed, 154 insertions, 62 deletions
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index 3491704f8..750db9444 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -356,18 +356,83 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type )
/**
- * Test for a legal pixel format and type.
+ * 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
+ * GL_INVALID_ENUM.
*
* \param format pixel format.
* \param type pixel type.
*
- * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE
- * otherwise.
+ * \return GL_INVALID_ENUM, GL_INVALID_OPERATION or GL_NO_ERROR
*/
-GLboolean
-_mesa_is_legal_format_and_type(const struct gl_context *ctx,
- GLenum format, GLenum type)
+GLenum
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
+ GLenum format, GLenum type)
{
+ /* special type-based checks (see glReadPixels, glDrawPixels error lists) */
+ switch (type) {
+ case GL_BITMAP:
+ if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) {
+ return GL_INVALID_ENUM;
+ }
+ break;
+
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB) {
+ break; /* OK */
+ }
+ if (format == GL_RGB_INTEGER_EXT &&
+ ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ break; /* OK */
+ }
+ return GL_INVALID_OPERATION;
+
+ 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:
+ if (format == GL_RGBA ||
+ format == GL_BGRA ||
+ format == GL_ABGR_EXT) {
+ break; /* OK */
+ }
+ if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
+ ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ break; /* OK */
+ }
+ return GL_INVALID_OPERATION;
+
+ case GL_UNSIGNED_INT_24_8:
+ if (!ctx->Extensions.EXT_packed_depth_stencil) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_DEPTH_STENCIL) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (!ctx->Extensions.ARB_depth_buffer_float) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_DEPTH_STENCIL) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ default:
+ ; /* fall-through */
+ }
+
+ /* now, for each format, check the type for compatibility */
switch (format) {
case GL_COLOR_INDEX:
case GL_STENCIL_INDEX:
@@ -380,12 +445,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RED:
case GL_GREEN:
case GL_BLUE:
@@ -404,16 +471,17 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RG:
if (!ctx->Extensions.ARB_texture_rg)
- return GL_FALSE;
-
+ return GL_INVALID_ENUM;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
@@ -422,12 +490,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RGB:
switch (type) {
case GL_BYTE:
@@ -441,16 +511,20 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_INT_5_9_9_9_REV:
- return ctx->Extensions.EXT_texture_shared_exponent;
+ return ctx->Extensions.EXT_texture_shared_exponent
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return ctx->Extensions.EXT_packed_float;
+ return ctx->Extensions.EXT_packed_float
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_BGR:
switch (type) {
/* NOTE: no packed types are supported with BGR. That's
@@ -463,12 +537,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RGBA:
case GL_BGRA:
case GL_ABGR_EXT:
@@ -488,28 +564,37 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
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:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_YCBCR_MESA:
+ if (!ctx->Extensions.MESA_ycbcr_texture)
+ return GL_INVALID_ENUM;
if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
- return GL_TRUE;
+ return GL_NO_ERROR;
else
- return GL_FALSE;
+ return GL_INVALID_OPERATION;
+
case GL_DEPTH_STENCIL_EXT:
- if ((ctx->Extensions.EXT_packed_depth_stencil &&
- type == GL_UNSIGNED_INT_24_8_EXT) ||
- (ctx->Extensions.ARB_depth_buffer_float &&
- type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
- return GL_TRUE;
+ if (ctx->Extensions.EXT_packed_depth_stencil &&
+ type == GL_UNSIGNED_INT_24_8)
+ return GL_NO_ERROR;
+ else if (ctx->Extensions.ARB_depth_buffer_float &&
+ type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
+ return GL_NO_ERROR;
else
- return GL_FALSE;
+ return GL_INVALID_ENUM;
+
case GL_DUDV_ATI:
case GL_DU8DV8_ATI:
+ if (!ctx->Extensions.ATI_envmap_bumpmap)
+ return GL_INVALID_ENUM;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
@@ -518,9 +603,9 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
+ return GL_NO_ERROR;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
/* integer-valued formats */
@@ -536,10 +621,11 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_RGB_INTEGER_EXT:
@@ -550,15 +636,17 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
- return ctx->Extensions.ARB_texture_rgb10_a2ui;
+ return ctx->Extensions.ARB_texture_rgb10_a2ui
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_BGR_INTEGER_EXT:
@@ -570,10 +658,11 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
/* NOTE: no packed formats w/ BGR format */
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_RGBA_INTEGER_EXT:
@@ -585,8 +674,9 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
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:
@@ -595,9 +685,10 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
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:
- return ctx->Extensions.ARB_texture_rgb10_a2ui;
+ return ctx->Extensions.ARB_texture_rgb10_a2ui
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_LUMINANCE_INTEGER_EXT:
@@ -609,15 +700,16 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->Extensions.EXT_texture_integer;
+ return ctx->Extensions.EXT_texture_integer
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
default:
- ; /* fall-through */
+ return GL_INVALID_ENUM;
}
- return GL_FALSE;
+ return GL_NO_ERROR;
}