From: Anuj Phogat <anuj.pho...@gmail.com> Hi Brian,
>I think something like this would be simpler: > > @@ -1629,7 +1629,9 @@ texture_error_check( struct gl_context *ctx, > target != GL_TEXTURE_2D_ARRAY && > target != GL_PROXY_TEXTURE_2D_ARRAY && > target != GL_TEXTURE_RECTANGLE_ARB && > - target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { > + target != GL_PROXY_TEXTURE_RECTANGLE_ARB && > + !((_mesa_is_cube_face(target) || target == > GL_PROXY_TEXTURE_CUBE_MAP) && > + (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_gpu_shader4))) { > if (!isProxy) > _mesa_error(ctx, GL_INVALID_ENUM, > "glTexImage(target/internalFormat)"); I agree. This is simpler to read and _mesa_is_cube_map_face() can be reused in mesa. Posting an updated patch with your suggestions. > I haven't tested this so the logic might be incorrect. It worked as it is. Just defined a new function _mesa_is_cube_face(). Thanks Anuj Signed-off-by: Anuj Phogat <anuj.pho...@gmail.com> --- src/mesa/main/image.c | 18 ++++++++++++++++++ src/mesa/main/image.h | 3 +++ src/mesa/main/teximage.c | 25 ++++++++++++------------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 7d95dd6..9ba5317 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1086,6 +1086,24 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) } } +/** + * Test if the given texture target is a cubemap face + */ +GLboolean +_mesa_is_cube_map_face(GLenum target) +{ + switch (target) { + case GL_TEXTURE_CUBE_MAP_POSITIVE_X : + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X : + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y : + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y : + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z : + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z : + return GL_TRUE; + default: + return GL_FALSE; + } +} /** * Return the address of a specific pixel in an image (1D, 2D or 3D). diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 46adaec..2c88578 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -84,6 +84,9 @@ _mesa_is_integer_format(GLenum format); extern GLboolean _mesa_is_compressed_format(struct gl_context *ctx, GLenum format); +extern GLboolean +_mesa_is_cube_map_face(GLenum target); + extern GLvoid * _mesa_image_address( GLuint dimensions, const struct gl_pixelstore_attrib *packing, diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index acf7187..43eec61 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1593,28 +1593,27 @@ texture_error_check( struct gl_context *ctx, return GL_TRUE; } } - - /* additional checks for depth textures */ + + /* additional checks for depth textures */ if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { - /* Only 1D, 2D, rect and array textures supported, not 3D or cubes */ + /* Only 1D, 2D, rect, array and cube textures supported, not 3D + * Cubemaps are only supported for GL version > 3.0 or with EXT_gpu_shader4 */ if (target != GL_TEXTURE_1D && target != GL_PROXY_TEXTURE_1D && target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D && - target != GL_TEXTURE_1D_ARRAY && - target != GL_PROXY_TEXTURE_1D_ARRAY && - target != GL_TEXTURE_2D_ARRAY && target != GL_PROXY_TEXTURE_2D_ARRAY && target != GL_TEXTURE_RECTANGLE_ARB && - target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage(target/internalFormat)"); - return GL_TRUE; + target != GL_PROXY_TEXTURE_RECTANGLE_ARB && + !((_mesa_is_cube_map_face(target) || target == GL_PROXY_TEXTURE_CUBE_MAP) && + (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_gpu_shader4))) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage(target/internalFormat)"); + return GL_TRUE; } } - /* additional checks for compressed textures */ + /* additional checks for compressed textures */ if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target, internalFormat)) { if (!isProxy) -- 1.7.7 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev