[Mesa-dev] [PATCH 3/7] mesa: Fix GL error generation in glBlitFramebuffer()

Anuj Phogat anuj.phogat at gmail.com
Mon Jan 7 08:16:28 PST 2013


V2:
If mask has GL_STENCIL_BUFFER_BIT set, the depth formats for readRenderBuffer
and drawRenderBuffer must match unless one of the two buffers doesn't have
depth, in which case it's not blitted, so the format check should be ignored.
Same comment goes for stencil formats in depth renderbuffers if mask has
GL_DEPTH_BUFFER_BIT set.

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 src/mesa/main/fbobject.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4b7d4ab..89054ed 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2855,11 +2855,20 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       if ((readRb == NULL) || (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)) {
-	 /* There is no need to check the stencil datatype here, because
-	  * there is only one: GL_UNSIGNED_INT.
-	  */
+      else if ((_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) !=
+                _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) ||
+              /* There is no need to check the stencil datatype here, because
+               * there is only one: GL_UNSIGNED_INT.
+               * The depth formats must match unless one of the two buffers
+               * doesn't have depth, in which case it's not blitted, so the
+               * format check should be ignored.
+               */
+               ((_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) > 0) &&
+                (_mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS) > 0) &&
+                ((_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) !=
+                  _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) ||
+                 (_mesa_get_format_datatype(readRb->Format) !=
+                  _mesa_get_format_datatype(drawRb->Format))))) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glBlitFramebufferEXT(stencil buffer size mismatch)");
          return;
@@ -2884,7 +2893,15 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       else if ((_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) !=
 	        _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) ||
 	       (_mesa_get_format_datatype(readRb->Format) !=
-		_mesa_get_format_datatype(drawRb->Format))) {
+                _mesa_get_format_datatype(drawRb->Format)) ||
+               /* The stencil formats must match unless one of the two buffers
+                * doesn't have stencil, in which case it's not blitted, so the
+                * format check should be ignored.
+                */
+               ((_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) > 0) &&
+                (_mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS) > 0) &&
+                (_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(depth buffer format mismatch)");
          return;
-- 
1.7.7.6



More information about the mesa-dev mailing list