summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorAnuj Phogat <[email protected]>2013-01-07 15:55:31 -0800
committerIan Romanick <[email protected]>2013-01-15 15:08:12 -0800
commit252573ae0fe6c928885f005cf6e77200b45601fb (patch)
tree1910a5021dff5daed20fff232fe109a679c41b68 /src/mesa/main
parentf727fc630462c91f19a59e8b48e3a4224dd0ec52 (diff)
mesa: Fix GL error generation in glBlitFramebuffer()
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. v3 (Kayden): Refactor code to be a bit more readable. Signed-off-by: Anuj Phogat <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/fbobject.c64
1 files changed, 49 insertions, 15 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index a525877a336..4e960ad63c1 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2849,14 +2849,33 @@ _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.
- */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(stencil buffer size mismatch)");
- return;
+ 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.
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBlitFramebuffer(stencil attachment format mismatch)");
+ return;
+ }
+
+ int read_z_bits = _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS);
+ int draw_z_bits = _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS);
+
+ /* If both buffers also have depth data, the depth formats must match
+ * as well. If one doesn't have depth, it's not blitted, so we should
+ * ignore the depth format check.
+ */
+ if (read_z_bits > 0 && draw_z_bits > 0 &&
+ (read_z_bits != draw_z_bits ||
+ _mesa_get_format_datatype(readRb->Format) !=
+ _mesa_get_format_datatype(drawRb->Format))) {
+
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebuffer"
+ "(stencil attachment depth format mismatch)");
+ return;
+ }
}
}
@@ -2875,13 +2894,28 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if ((readRb == NULL) || (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_get_format_datatype(readRb->Format) !=
- _mesa_get_format_datatype(drawRb->Format))) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(depth buffer format mismatch)");
- return;
+ 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_error(ctx, GL_INVALID_OPERATION,
+ "glBlitFramebuffer(depth attachment format mismatch)");
+ return;
+ }
+
+ int read_s_bit = _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS);
+ int draw_s_bit = _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS);
+
+ /* If both buffers also have stencil data, the stencil formats must
+ * match as well. If one doesn't have stencil, it's not blitted, so
+ * we should ignore the stencil format check.
+ */
+ if (read_s_bit > 0 && draw_s_bit > 0 && read_s_bit != draw_s_bit) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebuffer"
+ "(depth attachment stencil bits mismatch)");
+ return;
+ }
}
}