mesa: define, use _mesa_is_cube_face() in several places

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Brian Paul
2011-11-18 17:39:00 -07:00
parent a43908fe62
commit 2efa3d4f9f
4 changed files with 18 additions and 20 deletions

View File

@@ -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);
}
}

View File

@@ -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 &&

View File

@@ -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;

View File

@@ -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 */
/*@{*/