[Mesa-dev] [PATCH] GlBlitFramebuffer Specification Fix
Max Qian
public at maxqia.com
Mon Oct 10 04:44:17 UTC 2016
The specification says that if the depth AND stencil formats
do not match, not or. This fixes bug #97921.
---
src/mesa/main/blit.c | 46 +++++++++++++++++++---------------------------
1 file changed, 19 insertions(+), 27 deletions(-)
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index e739130..62afeb4 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -334,7 +334,7 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
mask &= ~GL_STENCIL_BUFFER_BIT;
}
else {
- int read_z_bits, draw_z_bits;
+ int read_z_bits, draw_z_bits, read_s_bit, draw_s_bit;
if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -343,28 +343,24 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
return;
}
- 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,
- "%s(stencil attachment format mismatch)", func);
- return;
- }
-
read_z_bits = _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS);
draw_z_bits = _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS);
+ read_s_bit = _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS);
+ draw_s_bit = _mesa_get_format_bits(drawRb->Format, GL_STENCIL_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))) {
+ if ((read_s_bit != draw_s_bit) &&
+ (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)))) {
+ /* There is no need to check the stencil datatype here, because
+ * there is only one: GL_UNSIGNED_INT.
+ */
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(stencil attachment depth format mismatch)", func);
return;
@@ -388,7 +384,7 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
mask &= ~GL_DEPTH_BUFFER_BIT;
}
else {
- int read_s_bit, draw_s_bit;
+ int read_z_bits, draw_z_bits, read_s_bit, draw_s_bit;
if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -397,15 +393,8 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
return;
}
- 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,
- "%s(depth attachment format mismatch)", func);
- return;
- }
-
+ read_z_bits = _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS);
+ draw_z_bits = _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS);
read_s_bit = _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS);
draw_s_bit = _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS);
@@ -413,9 +402,12 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
* 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) {
+ if ((read_s_bit > 0 && draw_s_bit > 0 && read_s_bit != draw_s_bit) &&
+ (read_z_bits != draw_z_bits ||
+ (_mesa_get_format_datatype(readRb->Format) !=
+ _mesa_get_format_datatype(drawRb->Format)))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(depth attachment stencil bits mismatch)", func);
+ "%s(depth attachment stencil bits and format mismatch)", func);
return;
}
}
--
2.10.0
More information about the mesa-dev
mailing list