better error checking related to YCbCr images

This commit is contained in:
Brian Paul
2002-10-02 17:25:05 +00:00
parent 54f3aab0c7
commit d8419c730e

View File

@@ -1,4 +1,4 @@
/* $Id: teximage.c,v 1.117 2002/09/27 02:45:38 brianp Exp $ */ /* $Id: teximage.c,v 1.118 2002/10/02 17:25:05 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -959,6 +959,24 @@ texture_error_check( GLcontext *ctx, GLenum target,
_mesa_error(ctx, GL_INVALID_ENUM, message); _mesa_error(ctx, GL_INVALID_ENUM, message);
return GL_TRUE; /* error */ return GL_TRUE; /* error */
} }
if (target != GL_TEXTURE_2D &&
target != GL_PROXY_TEXTURE_2D &&
target != GL_TEXTURE_RECTANGLE_NV &&
target != GL_PROXY_TEXTURE_RECTANGLE_NV) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)");
return GL_TRUE;
}
if (border != 0) {
if (!isProxy) {
char message[100];
sprintf(message,
"glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
dimensions, border);
_mesa_error(ctx, GL_INVALID_VALUE, message);
}
return GL_TRUE;
}
} }
if (is_compressed_format(internalFormat)) { if (is_compressed_format(internalFormat)) {
@@ -1011,36 +1029,40 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
GLint maxLevels = 0; GLint maxLevels = 0;
if (dimensions == 1) { if (dimensions == 1) {
if (target != GL_TEXTURE_1D) { if (target == GL_TEXTURE_1D) {
maxLevels = ctx->Const.MaxTextureLevels;
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" ); _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" );
return GL_TRUE; return GL_TRUE;
} }
maxLevels = ctx->Const.MaxTextureLevels;
} }
else if (dimensions == 2) { else if (dimensions == 2) {
if (ctx->Extensions.ARB_texture_cube_map) { if (ctx->Extensions.ARB_texture_cube_map &&
if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && target <=GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
target != GL_TEXTURE_2D) { maxLevels = ctx->Const.MaxCubeTextureLevels;
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
return GL_TRUE;
}
} }
else if (target != GL_TEXTURE_2D) { else if (ctx->Extensions.NV_texture_rectangle &&
target == GL_TEXTURE_RECTANGLE_NV) {
maxLevels = 1;
}
else if (target == GL_TEXTURE_2D) {
maxLevels = ctx->Const.MaxTextureLevels;
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
return GL_TRUE; return GL_TRUE;
} }
if (target == GL_PROXY_TEXTURE_2D && target == GL_TEXTURE_2D)
maxLevels = ctx->Const.MaxTextureLevels;
else
maxLevels = ctx->Const.MaxCubeTextureLevels;
} }
else if (dimensions == 3) { else if (dimensions == 3) {
if (target != GL_TEXTURE_3D) { if (target == GL_TEXTURE_3D) {
maxLevels = ctx->Const.Max3DTextureLevels;
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" ); _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" );
return GL_TRUE; return GL_TRUE;
} }
maxLevels = ctx->Const.Max3DTextureLevels;
} }
else { else {
_mesa_problem( ctx, "bad dims in texture_error_check" ); _mesa_problem( ctx, "bad dims in texture_error_check" );
@@ -1401,6 +1423,11 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
} }
} }
if (teximage->IntFormat == GL_YCBCR_MESA) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D");
return GL_TRUE;
}
/* if we get here, the parameters are OK */ /* if we get here, the parameters are OK */
return GL_FALSE; return GL_FALSE;
} }