From 2efa3d4f9fd1e1683c5366d402d8740ecfb688e5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 18 Nov 2011 17:39:00 -0700 Subject: [PATCH] mesa: define, use _mesa_is_cube_face() in several places Reviewed-by: Kenneth Graunke --- src/mesa/main/fbobject.c | 10 +--------- src/mesa/main/texgetimage.c | 9 ++++----- src/mesa/main/teximage.c | 9 +++------ src/mesa/main/teximage.h | 10 ++++++++++ 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f8b148cee8b..5b329f5c3e5 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -78,14 +78,6 @@ static struct gl_renderbuffer DummyRenderbuffer; static struct gl_framebuffer IncompleteFramebuffer; -static inline GLboolean -is_cube_face(GLenum target) -{ - return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); -} - - /** * Is the given FBO a user-created FBO? */ @@ -2008,7 +2000,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, } else { err = (texObj->Target == GL_TEXTURE_CUBE_MAP) - ? !is_cube_face(textarget) + ? !_mesa_is_cube_face(textarget) : (texObj->Target != textarget); } } diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 31d49f2d823..06506594d63 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -386,11 +386,10 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, * so we don't have to worry about those. * XXX more format combinations could be supported here. */ - if ((target == GL_TEXTURE_1D || - target == GL_TEXTURE_2D || - target == GL_TEXTURE_RECTANGLE || - (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { + if (target == GL_TEXTURE_1D || + target == GL_TEXTURE_2D || + target == GL_TEXTURE_RECTANGLE || + _mesa_is_cube_face(target)) { if ((texImage->TexFormat == MESA_FORMAT_ARGB8888 || texImage->TexFormat == MESA_FORMAT_SARGB8) && format == GL_BGRA && diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index a84d6873d3d..c8ea4329fe4 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -522,8 +522,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) GLuint _mesa_tex_target_to_face(GLenum target) { - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) + if (_mesa_is_cube_face(target)) return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; else return 0; @@ -3094,8 +3093,7 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, } /* For cube map, width must equal height */ - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) { + if (_mesa_is_cube_face(target) && width != height) { *reason = "width != height"; return GL_INVALID_VALUE; } @@ -3183,8 +3181,7 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions, return GL_INVALID_ENUM; /*target*/ maxLevels = ctx->Const.MaxCubeTextureLevels; } - else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + else if (_mesa_is_cube_face(target)) { if (!ctx->Extensions.ARB_texture_cube_map) return GL_INVALID_ENUM; /*target*/ maxLevels = ctx->Const.MaxCubeTextureLevels; diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index fd315bea3db..9cc7d5a543e 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -36,6 +36,16 @@ #include "formats.h" +/** Is the given value one of the 6 cube faces? */ +static inline GLboolean +_mesa_is_cube_face(GLenum target) +{ + return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB); +} + + + /** \name Internal functions */ /*@{*/ -- 2.30.2