diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2013-07-27 12:04:20 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2013-08-06 12:20:01 -0700 |
commit | d1419857d7adec89b7b733bd17644be7e89f494f (patch) | |
tree | f36de653b68d689edf776256efa4a874a3900a42 /src | |
parent | c15b2d86e28072d47980350e2fe77bd5459d3061 (diff) |
mesa: Don't call driver RenderTexture for really broken textures
This fixes the segfault in the '0x0 texture' subtest of piglit's
fbo-incomplete test.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "9.1 9.2" mesa-stable@lists.freedesktop.org
(cherry picked from commit fb49713f8ed099559d255403dc1065a06305e0d8)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/fbobject.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 6b978d92ff3..abb3d49c0d0 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -343,6 +343,22 @@ _mesa_remove_attachment(struct gl_context *ctx, } /** + * Verify a couple error conditions that will lead to an incomplete FBO and + * may cause problems for the driver's RenderTexture path. + */ +static bool +driver_RenderTexture_is_safe(const struct gl_renderbuffer_attachment *att) +{ + const struct gl_texture_image *const texImage = + att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + + if (texImage->Width == 0 || texImage->Height == 0 || texImage->Depth == 0) + return false; + + return true; +} + +/** * Create a renderbuffer which will be set up by the driver to wrap the * texture image slice. * @@ -391,7 +407,8 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx, rb->NumSamples = texImage->NumSamples; rb->TexImage = texImage; - ctx->Driver.RenderTexture(ctx, fb, att); + if (driver_RenderTexture_is_safe(att)) + ctx->Driver.RenderTexture(ctx, fb, att); } /** @@ -1885,7 +1902,8 @@ check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Texture && att->Renderbuffer->TexImage) { + if (att->Texture && att->Renderbuffer->TexImage + && driver_RenderTexture_is_safe(att)) { ctx->Driver.RenderTexture(ctx, fb, att); } } |