[Mesa-stable] [PATCH 03/10] mesa: Add error condition for integer formats in glGetTexImage()
Anuj Phogat
anuj.phogat at gmail.com
Fri Mar 21 15:01:35 PDT 2014
OpenGL 4.0 spec, page 306 suggests an INVALID_OPERATION in glGetTexImage
if :
"format is one of the integer formats in table 3.3 and the internal
format of the texture image is not integer, or format is not one of
the integer formats in table 3.3 and the internal format is integer."
Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/main/texgetimage.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 488b678..2bf0fb4 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -790,7 +790,8 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage;
const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
- GLenum baseFormat, err;
+ GLenum baseFormat, dataType, err;
+ GLboolean is_tex_format_integer = false;
if (!legal_getteximage_target(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target);
@@ -823,6 +824,9 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
}
baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+ dataType = _mesa_get_format_datatype(texImage->TexFormat);
+ is_tex_format_integer = dataType == GL_UNSIGNED_INT
+ || dataType == GL_INT;
/* Make sure the requested image format is compatible with the
* texture's format.
@@ -858,6 +862,10 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
return GL_TRUE;
}
+ else if (_mesa_is_enum_format_integer(format) != is_tex_format_integer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
+ return GL_TRUE;
+ }
if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width,
texImage->Height, texImage->Depth,
--
1.8.3.1
More information about the mesa-stable
mailing list