mesa: Fix GetTextureImage error reporting, again

Iago Toral Quiroga fixed this in commit 94f740e3fc,
but it recently regressed in 0d8826f723.
Quoting Iago's original commit message for the fix:

GetTex*Image should return INVALID_ENUM if target is not valid, however,
GetTextureImage does not receive a target, and instead should return
INVALID_OPERATION if the effective target is not valid.  From the
OpenGL 4.6 core profile spec, section 8.11 Texture Queries:

   "An INVALID_OPERATION error is generated by GetTextureImage if the
    effective target is not one of TEXTURE_1D, TEXTURE_2D, TEXTURE_3D,
    TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY,
    TEXTURE_RECTANGLE, or TEXTURE_CUBE_MAP (for GetTextureImage only)."

Note that this differs from the original ARB_direct_state_access spec.

However, the EXT_direct_state_access version does take a target
parameter, so it should continue reporting INVALID_ENUM.

Fixes KHR-GL45.direct_state_access.textures_image_query_errors.

Fixes: 0d8826f723 ("mesa: refactor get_texture_image to remove duplicate code")
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2019-07-23 16:39:31 -07:00 committed by Kenneth Graunke
parent 0e24d10ff5
commit cd02f60c1e

View file

@ -1457,10 +1457,6 @@ _get_texture_image(struct gl_context *ctx,
/* EXT/ARB direct_state_access variants don't call _get_texture_image
* with a NULL texObj */
bool is_dsa = texObj != NULL;
if (!legal_getteximage_target(ctx, target, is_dsa)) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
return;
}
if (!is_dsa) {
texObj = _mesa_get_current_tex_object(ctx, target);
@ -1489,6 +1485,11 @@ _mesa_GetnTexImageARB(GLenum target, GLint level, GLenum format, GLenum type,
GET_CURRENT_CONTEXT(ctx);
static const char *caller = "glGetnTexImageARB";
if (!legal_getteximage_target(ctx, target, false)) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
return;
}
_get_texture_image(ctx, NULL, target, level, format, type,
bufSize, pixels, caller);
}
@ -1501,6 +1502,11 @@ _mesa_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
GET_CURRENT_CONTEXT(ctx);
static const char *caller = "glGetTexImage";
if (!legal_getteximage_target(ctx, target, false)) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
return;
}
_get_texture_image(ctx, NULL, target, level, format, type,
INT_MAX, pixels, caller);
}
@ -1519,6 +1525,11 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, GLenum type,
return;
}
if (!legal_getteximage_target(ctx, texObj->Target, true)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
return;
}
_get_texture_image(ctx, texObj, texObj->Target, level, format, type,
bufSize, pixels, caller);
}
@ -1538,6 +1549,11 @@ _mesa_GetTextureImageEXT(GLuint texture, GLenum target, GLint level,
return;
}
if (!legal_getteximage_target(ctx, target, true)) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
return;
}
_get_texture_image(ctx, texObj, target, level, format, type,
INT_MAX, pixels, caller);
}