summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2018-11-22 15:17:13 +0100
committerEmil Velikov <[email protected]>2018-11-26 15:37:07 +0000
commit1a905e4c5b3bff052085b3efdc17fe2fb252bad3 (patch)
treef1b344444b0bf10c507d5b8f58800bb7a60f04ae /src/mesa/main
parent6b9b7ce38ca3ae7745ed6faf95f4a7b03843ebb4 (diff)
mesa/main: remove bogus error for zero-sized images
The explanation quotes the spec on the following wording to justify the error: "An INVALID_VALUE error is generated if xoffset + width is greater than the texture’s width, yoffset + height is greater than the texture’s height, or zoffset + depth is greater than the texture’s depth." However, this shouldn't generate an error in the case where *all three* of width, xoffset and the texture's width are zero. In this case, we end up generating an unspecified error. So let's remove this check, and instead make sure that we consider this as an empty texture. So let's not generate an error, there's non mandated in the spec in xoffset/yoffset/zoffset = 0 case. We already avoid doing any work in this case, because of the final, non-error generating check in this function. Fixes: b37b35a5d26 "getteximage: assume texture image is empty for non defined levels" Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Juan A. Suarez <[email protected]> (cherry picked from commit 38bbb61252aa503571986080afddd98a56bcf2e7)
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/texgetimage.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 0ab9ed445d6..0c1e5d208b8 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -900,8 +900,7 @@ select_tex_image(const struct gl_texture_object *texObj, GLenum target,
/**
* Error-check the offset and size arguments to
- * glGet[Compressed]TextureSubImage(). Also checks if the specified
- * texture image is missing.
+ * glGet[Compressed]TextureSubImage().
* \return true if error, false if no error.
*/
static bool
@@ -913,6 +912,7 @@ dimensions_error_check(struct gl_context *ctx,
const char *caller)
{
const struct gl_texture_image *texImage;
+ GLuint imageWidth = 0, imageHeight = 0, imageDepth = 0;
if (xoffset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset = %d)", caller, xoffset);
@@ -1002,61 +1002,38 @@ dimensions_error_check(struct gl_context *ctx,
}
texImage = select_tex_image(texObj, target, level, zoffset);
- if (!texImage) {
- /* Trying to return a non-defined level is a valid operation per se, as
- * OpenGL 4.6 spec, section 8.11.4 ("Texture Image Queries") does not
- * handle this case as an error.
- *
- * Rather, we need to look at section 8.22 ("Texture State and Proxy
- * State"):
- *
- * "Each initial texture image is null. It has zero width, height, and
- * depth, internal format RGBA, or R8 for buffer textures, component
- * sizes set to zero and component types set to NONE, the compressed
- * flag set to FALSE, a zero compressed size, and the bound buffer
- * object name is zero."
- *
- * This means we need to assume the image for the non-defined level is
- * an empty image. With this assumption, we can go back to section
- * 8.11.4 and checking again the errors:
- *
- * "An INVALID_VALUE error is generated if xoffset + width is greater
- * than the texture’s width, yoffset + height is greater than the
- * texture’s height, or zoffset + depth is greater than the texture’s
- * depth."
- *
- * Thus why we return INVALID_VALUE.
- */
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(missing image)", caller);
- return true;
+ if (texImage) {
+ imageWidth = texImage->Width;
+ imageHeight = texImage->Height;
+ imageDepth = texImage->Depth;
}
- if (xoffset + width > texImage->Width) {
+ if (xoffset + width > imageWidth) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(xoffset %d + width %d > %u)",
- caller, xoffset, width, texImage->Width);
+ caller, xoffset, width, imageWidth);
return true;
}
- if (yoffset + height > texImage->Height) {
+ if (yoffset + height > imageHeight) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(yoffset %d + height %d > %u)",
- caller, yoffset, height, texImage->Height);
+ caller, yoffset, height, imageHeight);
return true;
}
if (target != GL_TEXTURE_CUBE_MAP) {
/* Cube map error checking was done above */
- if (zoffset + depth > texImage->Depth) {
+ if (zoffset + depth > imageDepth) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(zoffset %d + depth %d > %u)",
- caller, zoffset, depth, texImage->Depth);
+ caller, zoffset, depth, imageDepth);
return true;
}
}
/* Extra checks for compressed textures */
- {
+ if (texImage) {
GLuint bw, bh, bd;
_mesa_get_format_block_size_3d(texImage->TexFormat, &bw, &bh, &bd);
if (bw > 1 || bh > 1 || bd > 1) {