Mesa (9.1): mesa: Don' t call driver RenderTexture for really broken textures

Carl Worth cworth at kemper.freedesktop.org
Thu Oct 3 23:15:58 UTC 2013


Module: Mesa
Branch: 9.1
Commit: 398c705c3d75bb3b9223eb676ce84a296b302a5a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=398c705c3d75bb3b9223eb676ce84a296b302a5a

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sat Jul 27 12:04:20 2013 -0700

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 at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: "9.1 9.2" mesa-stable at lists.freedesktop.org
(cherry picked from commit fb49713f8ed099559d255403dc1065a06305e0d8)

Conflicts:
	src/mesa/main/fbobject.c

---

 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 0701e85..62a3728 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.
  *
@@ -383,7 +399,8 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
       rb->NeedsFinishRenderTexture = ctx->Driver.FinishRenderTexture != NULL;
    }
 
-   ctx->Driver.RenderTexture(ctx, fb, att);
+   if (driver_RenderTexture_is_safe(att))
+      ctx->Driver.RenderTexture(ctx, fb, att);
 }
 
 /**
@@ -1785,7 +1802,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 && _mesa_get_attachment_teximage(att)) {
+      if (att->Texture && _mesa_get_attachment_teximage(att)
+          && driver_RenderTexture_is_safe(att)) {
          ctx->Driver.RenderTexture(ctx, fb, att);
       }
    }




More information about the mesa-commit mailing list