Mesa (7.10): mesa: Don't try to clear a NULL renderbuffer

Marek Olšák mareko at kemper.freedesktop.org
Sun Jun 12 03:45:38 UTC 2011


Module: Mesa
Branch: 7.10
Commit: 6586475f375abba1d2423d21a94418ae55b502a8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6586475f375abba1d2423d21a94418ae55b502a8

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Jun  7 12:27:04 2011 -0700

mesa: Don't try to clear a NULL renderbuffer

In an ES2 context (or if GL_ARB_ES2_compatibility) is supported, the
framebuffer can be complete with some attachments be missing.  In this
case the _ColorDrawBuffers pointer will be NULL.

Fixes the crash in piglit test fbo-missing-attachment-clear.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37739
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

NOTE: This is a candidate for the stable branches.
(cherry picked from commit 7f9c17aaa82f5a8a1d5f077eba4d5889d3c3b298 by Marek)

---

 src/mesa/swrast/s_clear.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index 75805f9..9e9b531 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -165,6 +165,14 @@ clear_color_buffers(struct gl_context *ctx)
 
    for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {
       struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf];
+
+      /* If this is an ES2 context or GL_ARB_ES2_compatibility is supported,
+       * the framebuffer can be complete with some attachments be missing.  In
+       * this case the _ColorDrawBuffers pointer will be NULL.
+       */
+      if (rb == NULL)
+	 continue;
+
       if (ctx->Color.ColorMask[buf][0] == 0 ||
           ctx->Color.ColorMask[buf][1] == 0 ||
           ctx->Color.ColorMask[buf][2] == 0 ||




More information about the mesa-commit mailing list