summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2007-05-17 11:13:41 -0700
committerIan Romanick <[email protected]>2007-05-17 14:45:25 -0700
commitfbcac5aa8316354cbd6bb4b13df867a0c7e7c7f1 (patch)
tree10fd22e76ecf0d310824a4f5267e646e31e4d165 /src
parent2b72ab8f8f14b7d5bbf677e9f0a3d6a5475bd75f (diff)
Refactor determining whether a texture target can use compressed format
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/teximage.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 9fb430f39b4..c8ce79ea865 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1300,6 +1300,20 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
/**
+ * Helper function to determine whether a target supports compressed textures
+ */
+static GLboolean
+target_can_be_compressed(GLcontext *ctx, GLenum target)
+{
+ return (((target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D))
+ || ((ctx->Extensions.ARB_texture_cube_map &&
+ (target == GL_PROXY_TEXTURE_CUBE_MAP ||
+ (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)))));
+}
+
+
+/**
* Test the glTexImage[123]D() parameters for errors.
*
* \param ctx GL context.
@@ -1515,21 +1529,10 @@ texture_error_check( GLcontext *ctx, GLenum target,
/* additional checks for compressed textures */
if (is_compressed_format(ctx, internalFormat)) {
- if (target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D) {
- /* OK */
- }
- else if (ctx->Extensions.ARB_texture_cube_map &&
- (target == GL_PROXY_TEXTURE_CUBE_MAP ||
- (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
- /* OK */
- }
- else {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glTexImage%d(target)", dimensions);
- return GL_TRUE;
- }
+ if (!target_can_be_compressed(ctx, target) && !isProxy) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexImage%d(target)", dimensions);
+ return GL_TRUE;
}
if (border != 0) {
if (!isProxy) {
@@ -1704,16 +1707,7 @@ subtexture_error_check2( GLcontext *ctx, GLuint dimensions,
#endif
if (destTex->IsCompressed) {
- if (target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D) {
- /* OK */
- }
- else if (ctx->Extensions.ARB_texture_cube_map &&
- (target == GL_PROXY_TEXTURE_CUBE_MAP ||
- (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
- /* OK */
- }
- else {
+ if (!target_can_be_compressed(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexSubImage%D(target)", dimensions);
return GL_TRUE;