diff options
author | Brian Paul <[email protected]> | 2009-10-13 09:04:14 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-10-13 09:05:02 -0600 |
commit | c8413351c33d5758da057b56a140c9ee622a5e4a (patch) | |
tree | 1ed14ffbacafe0f45d5c40b9b7322779474181ad /src/mesa/drivers | |
parent | ca8cafda0b996167647d724ea3da3ec568a9e42f (diff) |
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.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | 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 9cba3a7600c..bae2c01ac2a 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); |