mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 11:38:05 +02:00
main: Fix target checking for CompressedTexSubImage*D.
This fixes a dEQP test failure. In the test,
glCompressedTexSubImage2D was called with target = 0 and failed to throw
INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx,
target) being called before the target checking. To remedy this, target
checking was made into its own function and called prior to
_mesa_get_current_tex_object.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89311
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
(cherry picked from commit 549078cb5a)
This commit is contained in:
parent
b0400a58db
commit
8b4db9c687
1 changed files with 65 additions and 15 deletions
|
|
@ -4457,25 +4457,21 @@ out:
|
|||
|
||||
|
||||
/**
|
||||
* Error checking for glCompressedTexSubImage[123]D().
|
||||
* Target checking for glCompressedTexSubImage[123]D().
|
||||
* \return GL_TRUE if error, GL_FALSE if no error
|
||||
* Must come before other error checking so that the texture object can
|
||||
* be correctly retrieved using _mesa_get_current_tex_object.
|
||||
*/
|
||||
static GLboolean
|
||||
compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
|
||||
const struct gl_texture_object *texObj,
|
||||
GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum format, GLsizei imageSize, bool dsa)
|
||||
compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
|
||||
GLint dims, GLenum format, bool dsa,
|
||||
const char *caller)
|
||||
{
|
||||
struct gl_texture_image *texImage;
|
||||
GLint expectedSize;
|
||||
GLboolean targetOK;
|
||||
const char *suffix = dsa ? "ture" : "";
|
||||
|
||||
if (dsa && target == GL_TEXTURE_RECTANGLE) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glCompressedSubTexture%dD(target)", dims);
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller,
|
||||
_mesa_lookup_enum_by_nr(target));
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -4538,7 +4534,9 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
|
|||
}
|
||||
if (invalidformat) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glCompressedTex%sSubImage%uD(target)", suffix, dims);
|
||||
"%s(invalid target %s for format %s)", caller,
|
||||
_mesa_lookup_enum_by_nr(target),
|
||||
_mesa_lookup_enum_by_nr(format));
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -4552,11 +4550,30 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
|
|||
}
|
||||
|
||||
if (!targetOK) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glCompressedTex%sSubImage%uD(target)", suffix, dims);
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller,
|
||||
_mesa_lookup_enum_by_nr(target));
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error checking for glCompressedTexSubImage[123]D().
|
||||
* \return GL_TRUE if error, GL_FALSE if no error
|
||||
*/
|
||||
static GLboolean
|
||||
compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
|
||||
const struct gl_texture_object *texObj,
|
||||
GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum format, GLsizei imageSize, bool dsa)
|
||||
{
|
||||
struct gl_texture_image *texImage;
|
||||
GLint expectedSize;
|
||||
const char *suffix = dsa ? "ture" : "";
|
||||
|
||||
/* this will catch any invalid compressed format token */
|
||||
if (!_mesa_is_compressed_format(ctx, format)) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
|
|
@ -4712,6 +4729,11 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
|
|||
struct gl_texture_object *texObj;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
if (compressed_subtexture_target_check(ctx, target, 1, format, false,
|
||||
"glCompressedTexSubImage1D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
texObj = _mesa_get_current_tex_object(ctx, target);
|
||||
if (!texObj)
|
||||
return;
|
||||
|
|
@ -4734,6 +4756,12 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
|
|||
if (!texObj)
|
||||
return;
|
||||
|
||||
if (compressed_subtexture_target_check(ctx, texObj->Target, 1, format,
|
||||
true,
|
||||
"glCompressedTextureSubImage1D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
_mesa_compressed_texture_sub_image(ctx, 1, texObj, texObj->Target, level,
|
||||
xoffset, 0, 0, width, 1, 1,
|
||||
format, imageSize, data, true);
|
||||
|
|
@ -4749,6 +4777,11 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
|
|||
struct gl_texture_object *texObj;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
if (compressed_subtexture_target_check(ctx, target, 2, format, false,
|
||||
"glCompressedTexSubImage2D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
texObj = _mesa_get_current_tex_object(ctx, target);
|
||||
if (!texObj)
|
||||
return;
|
||||
|
|
@ -4773,6 +4806,12 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
|
|||
if (!texObj)
|
||||
return;
|
||||
|
||||
if (compressed_subtexture_target_check(ctx, texObj->Target, 2, format,
|
||||
true,
|
||||
"glCompressedTextureSubImage2D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
_mesa_compressed_texture_sub_image(ctx, 2, texObj, texObj->Target, level,
|
||||
xoffset, yoffset, 0, width, height, 1,
|
||||
format, imageSize, data, true);
|
||||
|
|
@ -4787,6 +4826,11 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
|
|||
struct gl_texture_object *texObj;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
if (compressed_subtexture_target_check(ctx, target, 3, format, false,
|
||||
"glCompressedTexSubImage3D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
texObj = _mesa_get_current_tex_object(ctx, target);
|
||||
if (!texObj)
|
||||
return;
|
||||
|
|
@ -4812,6 +4856,12 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
|
|||
if (!texObj)
|
||||
return;
|
||||
|
||||
if (compressed_subtexture_target_check(ctx, texObj->Target, 3, format,
|
||||
true,
|
||||
"glCompressedTextureSubImage3D")) {
|
||||
return;
|
||||
}
|
||||
|
||||
_mesa_compressed_texture_sub_image(ctx, 3, texObj, texObj->Target, level,
|
||||
xoffset, yoffset, zoffset,
|
||||
width, height, depth,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue