summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-09-15 18:16:59 -0600
committerBrian Paul <[email protected]>2009-09-15 18:17:43 -0600
commit2914f2b7fd9bd1082f8cce724d234208b900c3d4 (patch)
tree71dd135e2eefd8e3d2e66312fef8f0b8d1465b49 /src/mesa/main/teximage.c
parentef6ee07fc7b356109897fdc311be74d5c6640bf9 (diff)
mesa: move generate mipmap calls
Per the suggestion in the Intel driver, move the calls to ctx->Driver.GenerateMipmap() into core Mesa so that drivers don't have to worry about it.
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 888b5064cc2..b0aa04e9aa4 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2075,6 +2075,23 @@ update_fbo_texture(GLcontext *ctx, struct gl_texture_object *texObj,
}
+/**
+ * If the texture object's GenerateMipmap flag is set and we've
+ * changed the texture base level image, regenerate the rest of the
+ * mipmap levels now.
+ */
+static INLINE void
+check_gen_mipmap(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj, GLint level)
+{
+ ASSERT(target != GL_TEXTURE_CUBE_MAP);
+ if (texObj->GenerateMipmap && level == texObj->BaseLevel) {
+ ASSERT(ctx->Driver.GenerateMipmap);
+ ctx->Driver.GenerateMipmap(ctx, target, texObj);
+ }
+}
+
+
/** Debug helper: override the user-requested internal format */
static GLenum
override_internal_format(GLenum internalFormat, GLint width, GLint height)
@@ -2182,6 +2199,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
ASSERT(texImage->TexFormat);
+ check_gen_mipmap(ctx, target, texObj, level);
+
update_fbo_texture(ctx, texObj, face, level);
/* state update */
@@ -2287,6 +2306,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
ASSERT(texImage->TexFormat);
+ check_gen_mipmap(ctx, target, texObj, level);
+
update_fbo_texture(ctx, texObj, face, level);
/* state update */
@@ -2388,6 +2409,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
ASSERT(texImage->TexFormat);
+ check_gen_mipmap(ctx, target, texObj, level);
+
update_fbo_texture(ctx, texObj, face, level);
/* state update */
@@ -2486,6 +2509,9 @@ _mesa_TexSubImage1D( GLenum target, GLint level,
ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width,
format, type, pixels, &ctx->Unpack,
texObj, texImage);
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
ctx->NewState |= _NEW_TEXTURE;
}
}
@@ -2544,6 +2570,9 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset,
width, height, format, type, pixels,
&ctx->Unpack, texObj, texImage);
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
ctx->NewState |= _NEW_TEXTURE;
}
}
@@ -2598,6 +2627,9 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
width, height, depth,
format, type, pixels,
&ctx->Unpack, texObj, texImage );
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
ctx->NewState |= _NEW_TEXTURE;
}
}
@@ -2659,6 +2691,8 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
ASSERT(texImage->TexFormat);
+ check_gen_mipmap(ctx, target, texObj, level);
+
update_fbo_texture(ctx, texObj, face, level);
/* state update */
@@ -2726,6 +2760,8 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
ASSERT(texImage->TexFormat);
+ check_gen_mipmap(ctx, target, texObj, level);
+
update_fbo_texture(ctx, texObj, face, level);
/* state update */
@@ -2784,6 +2820,9 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
ASSERT(ctx->Driver.CopyTexSubImage1D);
ctx->Driver.CopyTexSubImage1D(ctx, target, level,
xoffset, x, y, width);
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
ctx->NewState |= _NEW_TEXTURE;
}
}
@@ -2841,6 +2880,9 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
ASSERT(ctx->Driver.CopyTexSubImage2D);
ctx->Driver.CopyTexSubImage2D(ctx, target, level, xoffset, yoffset,
x, y, width, height);
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
ctx->NewState |= _NEW_TEXTURE;
}
}
@@ -2899,6 +2941,9 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
ctx->Driver.CopyTexSubImage3D(ctx, target, level,
xoffset, yoffset, zoffset,
x, y, width, height);
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
ctx->NewState |= _NEW_TEXTURE;
}
}
@@ -3146,6 +3191,8 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
imageSize, data,
texObj, texImage);
+ check_gen_mipmap(ctx, target, texObj, level);
+
/* state update */
texObj->_Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
@@ -3242,6 +3289,8 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
border, imageSize, data,
texObj, texImage);
+ check_gen_mipmap(ctx, target, texObj, level);
+
/* state update */
texObj->_Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
@@ -3338,6 +3387,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
border, imageSize, data,
texObj, texImage);
+ check_gen_mipmap(ctx, target, texObj, level);
+
/* state update */
texObj->_Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
@@ -3430,8 +3481,11 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
format, imageSize, data,
texObj, texImage);
}
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
+ ctx->NewState |= _NEW_TEXTURE;
}
- ctx->NewState |= _NEW_TEXTURE;
}
_mesa_unlock_texture(ctx, texObj);
}
@@ -3485,8 +3539,11 @@ _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
format, imageSize, data,
texObj, texImage);
}
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
+ ctx->NewState |= _NEW_TEXTURE;
}
- ctx->NewState |= _NEW_TEXTURE;
}
_mesa_unlock_texture(ctx, texObj);
}
@@ -3542,8 +3599,11 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
format, imageSize, data,
texObj, texImage);
}
+
+ check_gen_mipmap(ctx, target, texObj, level);
+
+ ctx->NewState |= _NEW_TEXTURE;
}
- ctx->NewState |= _NEW_TEXTURE;
}
_mesa_unlock_texture(ctx, texObj);
}