Skip to content
Snippets Groups Projects
Commit d575455b authored by Erik Faye-Lund's avatar Erik Faye-Lund Committed by Emil Velikov
Browse files

mesa/main: fix incorrect depth-error


If glGetTexImage or glGetnTexImage is called with a level that doesn't
exist, we get an error message on this form:

Mesa: User error: GL_INVALID_VALUE in glGetTexImage(depth = 0)

This is clearly nonsensical, because these APIs don't even have a
depth-parameter. The reason is that get_texture_image_dims() return
all-zero dimensions for non-existent texture-images, and we go on to
validate these dimensions as if they were user-input, because
glGetTextureSubImage requires checking.

So let's split this logic in two, so glGetTextureSubImage can have
stricter input-validation. All arguments that are no longer validated
are generated internally by mesa, so there's no use in validating them.

Fixes: 42891dba "gettextsubimage: verify zoffset and depth are correct"
Signed-off-by: default avatarErik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: default avatarJuan A. Suarez <jasuarez@igalia.com>
(cherry picked from commit c120dbfe)
parent 7d8a9087
No related branches found
No related tags found
No related merge requests found
......@@ -1255,7 +1255,6 @@ static bool
getteximage_error_check(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, GLsizei bufSize,
GLvoid *pixels, const char *caller)
......@@ -1269,6 +1268,49 @@ getteximage_error_check(struct gl_context *ctx,
return true;
}
if (width == 0 || height == 0 || depth == 0) {
/* Not an error, but nothing to do. Return 'true' so that the
* caller simply returns.
*/
return true;
}
if (pbo_error_check(ctx, target, width, height, depth,
format, type, bufSize, pixels, caller)) {
return true;
}
texImage = select_tex_image(texObj, target, level, 0);
if (teximage_error_check(ctx, texImage, format, caller)) {
return true;
}
return false;
}
/**
* Do error checking for all (non-compressed) get-texture-image functions.
* \return true if any error, false if no errors.
*/
static bool
gettexsubimage_error_check(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, GLsizei bufSize,
GLvoid *pixels, const char *caller)
{
struct gl_texture_image *texImage;
assert(texObj);
if (common_error_check(ctx, texObj, target, level, width, height, depth,
format, type, bufSize, pixels, caller)) {
return true;
}
if (dimensions_error_check(ctx, texObj, target, level,
xoffset, yoffset, zoffset,
width, height, depth, caller)) {
......@@ -1417,7 +1459,7 @@ _mesa_GetnTexImageARB(GLenum target, GLint level, GLenum format, GLenum type,
get_texture_image_dims(texObj, target, level, &width, &height, &depth);
if (getteximage_error_check(ctx, texObj, target, level,
0, 0, 0, width, height, depth,
width, height, depth,
format, type, bufSize, pixels, caller)) {
return;
}
......@@ -1448,7 +1490,7 @@ _mesa_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
get_texture_image_dims(texObj, target, level, &width, &height, &depth);
if (getteximage_error_check(ctx, texObj, target, level,
0, 0, 0, width, height, depth,
width, height, depth,
format, type, INT_MAX, pixels, caller)) {
return;
}
......@@ -1482,7 +1524,7 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, GLenum type,
&width, &height, &depth);
if (getteximage_error_check(ctx, texObj, texObj->Target, level,
0, 0, 0, width, height, depth,
width, height, depth,
format, type, bufSize, pixels, caller)) {
return;
}
......@@ -1515,9 +1557,10 @@ _mesa_GetTextureSubImage(GLuint texture, GLint level,
return;
}
if (getteximage_error_check(ctx, texObj, texObj->Target, level,
xoffset, yoffset, zoffset, width, height, depth,
format, type, bufSize, pixels, caller)) {
if (gettexsubimage_error_check(ctx, texObj, texObj->Target, level,
xoffset, yoffset, zoffset,
width, height, depth,
format, type, bufSize, pixels, caller)) {
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment