Mesa (master): mesa: do RTT check in _mesa_meta_check_generate_mipmap_fallback()
Brian Paul
brianp at kemper.freedesktop.org
Tue Oct 13 15:05:12 UTC 2009
Module: Mesa
Branch: master
Commit: c8413351c33d5758da057b56a140c9ee622a5e4a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8413351c33d5758da057b56a140c9ee622a5e4a
Author: Brian Paul <brianp at vmware.com>
Date: Tue Oct 13 09:04:14 2009 -0600
mesa: do RTT check in _mesa_meta_check_generate_mipmap_fallback()
We need to check that we can actually render to the texture's format
before doing mipmap generation.
This may fix bug 24219.
---
src/mesa/drivers/common/meta.c | 55 ++++++++++++++++++++++++++++++++++-----
1 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 9cba3a7..bae2c01 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2064,21 +2064,64 @@ _mesa_meta_Bitmap(GLcontext *ctx,
* Check if the call to _mesa_meta_GenerateMipmap() will require a
* software fallback. The fallback path will require that the texture
* images are mapped.
+ * \return GL_TRUE if a fallback is needed, GL_FALSE otherwise
*/
GLboolean
_mesa_meta_check_generate_mipmap_fallback(GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj)
{
- struct gl_texture_image *baseImage =
- _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel);
+ const GLuint fboSave = ctx->DrawBuffer->Name;
+ struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap;
+ struct gl_texture_image *baseImage;
+ GLuint srcLevel;
+ GLenum status;
/* check for fallbacks */
if (!ctx->Extensions.EXT_framebuffer_object ||
- target == GL_TEXTURE_3D ||
- !baseImage ||
- baseImage->IsCompressed) {
+ target == GL_TEXTURE_3D) {
return GL_TRUE;
}
+
+ srcLevel = texObj->BaseLevel;
+ baseImage = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
+ if (!baseImage || baseImage->IsCompressed) {
+ return GL_TRUE;
+ }
+
+ /*
+ * Test that we can actually render in the texture's format.
+ */
+ if (!mipmap->FBO)
+ _mesa_GenFramebuffersEXT(1, &mipmap->FBO);
+ _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
+
+ if (target == GL_TEXTURE_1D) {
+ _mesa_FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ target, texObj->Name, srcLevel);
+ }
+ else if (target == GL_TEXTURE_3D) {
+ GLint zoffset = 0;
+ _mesa_FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ target, texObj->Name, srcLevel, zoffset);
+ }
+ else {
+ /* 2D / cube */
+ _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ target, texObj->Name, srcLevel);
+ }
+
+ status = _mesa_CheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
+
+ _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
+
+ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ printf("Can't render\n");
+ return GL_TRUE;
+ }
+
return GL_FALSE;
}
@@ -2152,10 +2195,8 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
}
if (!mipmap->FBO) {
- /* Bind the new renderbuffer to the color attachment point. */
_mesa_GenFramebuffersEXT(1, &mipmap->FBO);
}
-
_mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
_mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
More information about the mesa-commit
mailing list