Mesa (7.10): mesa: Ignore blits to/from missing buffers

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


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

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

mesa: Ignore blits to/from missing buffers

The EXT_framebuffer_object spec (and later specs) say:

     "If a buffer is specified in <mask> and does not exist in both
     the read and draw framebuffers, the corresponding bit is silently
     ignored."

Check for color, depth, and stencil that the source and destination
FBOs have the specified buffers.  If the buffer is missing, remove the
bit from the blit request mask and continue.

Fixes the crash in piglit test 'fbo-missing-attachment-blit from', and
fixes 'fbo-missing-attachment-blit es2 from'.

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 bb4758669c82f8979a56524db1c04ce662c783d8 by Marek)

---

 src/mesa/main/fbobject.c |   45 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 0c5f6af..6c63047 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2292,6 +2292,17 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
    if (mask & GL_COLOR_BUFFER_BIT) {
       colorReadRb = readFb->_ColorReadBuffer;
       colorDrawRb = drawFb->_ColorDrawBuffers[0];
+
+      /* From the EXT_framebuffer_object spec:
+       *
+       *     "If a buffer is specified in <mask> and does not exist in both
+       *     the read and draw framebuffers, the corresponding bit is silently
+       *     ignored."
+       */
+      if ((colorReadRb == NULL) || (colorDrawRb == NULL)) {
+	 colorReadRb = colorDrawRb = NULL;
+	 mask &= ~GL_COLOR_BUFFER_BIT;
+      }
    }
    else {
       colorReadRb = colorDrawRb = NULL;
@@ -2300,10 +2311,19 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
    if (mask & GL_STENCIL_BUFFER_BIT) {
       struct gl_renderbuffer *readRb = readFb->_StencilBuffer;
       struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer;
-      if (!readRb ||
-          !drawRb ||
-          _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != 
-          _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) {
+
+      /* From the EXT_framebuffer_object spec:
+       *
+       *     "If a buffer is specified in <mask> and does not exist in both
+       *     the read and draw framebuffers, the corresponding bit is silently
+       *     ignored."
+       */
+      if ((readRb == NULL) || (drawRb == NULL)) {
+	 readRb = drawRb = NULL;
+	 mask &= ~GL_STENCIL_BUFFER_BIT;
+      }
+      else if (_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) !=
+	       _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glBlitFramebufferEXT(stencil buffer size mismatch");
          return;
@@ -2313,10 +2333,19 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
    if (mask & GL_DEPTH_BUFFER_BIT) {
       struct gl_renderbuffer *readRb = readFb->_DepthBuffer;
       struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer;
-      if (!readRb ||
-          !drawRb ||
-          _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != 
-          _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) {
+
+      /* From the EXT_framebuffer_object spec:
+       *
+       *     "If a buffer is specified in <mask> and does not exist in both
+       *     the read and draw framebuffers, the corresponding bit is silently
+       *     ignored."
+       */
+      if ((readRb == NULL) || (drawRb == NULL)) {
+	 readRb = drawRb = NULL;
+	 mask &= ~GL_DEPTH_BUFFER_BIT;
+      }
+      else if (_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) !=
+	       _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glBlitFramebufferEXT(depth buffer size mismatch");
          return;




More information about the mesa-commit mailing list