[Piglit] [PATCH] fbo-blit-d24s8: don't try to blit between different Z/stencil depths

Brian Paul brian.e.paul at gmail.com
Tue Dec 13 16:58:34 PST 2011


From: Brian Paul <brianp at vmware.com>

The docs for glBlitFramebuffer say GL_INVALID_OPERATION is generated
if the source/dest depth/stencil buffer formats do no match.  The spec
is a bit vague on what's meant by formats (do just the component depths
need to match, or must the hw formats match?) but clearly if the depths
don't match, the formats can't match.

This fixes a bogus error that's generated when testing swrast which
usually uses a 16-bit depth buffer for the window and a 24-bit Z
renderbuffer for the FBO.
---
 tests/fbo/fbo-blit-d24s8.c |   92 +++++++++++++++++++++++++------------------
 1 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/tests/fbo/fbo-blit-d24s8.c b/tests/fbo/fbo-blit-d24s8.c
index 11af723..6f8c1f9 100644
--- a/tests/fbo/fbo-blit-d24s8.c
+++ b/tests/fbo/fbo-blit-d24s8.c
@@ -154,6 +154,7 @@ run_test(void)
 	int y1 = PAD * 2 + SIZE;
 	int y2 = PAD * 3 + SIZE * 2;
 	GLenum err;
+	GLint win_depth_bits, fbo_depth_bits, win_stencil_bits, fbo_stencil_bits;
 
 	glViewport(0, 0, piglit_width, piglit_height);
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
@@ -171,6 +172,15 @@ run_test(void)
 
 	fbo = make_fbo(fbo_width, fbo_height);
 
+	/* query depth/stencil sizes */
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+	glGetIntegerv(GL_DEPTH_BITS, &win_depth_bits);
+	glGetIntegerv(GL_STENCIL_BITS, &win_stencil_bits);
+
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+	glGetIntegerv(GL_DEPTH_BITS, &fbo_depth_bits);
+	glGetIntegerv(GL_STENCIL_BITS, &fbo_stencil_bits);
+
 	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
 	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
 	glViewport(0, 0, fbo_width, fbo_height);
@@ -187,46 +197,50 @@ run_test(void)
 	 * Also blit with stencil to exercise this path.
 	 * Not that we need it for this test.
 	 */
-	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
-	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
-	copy(x0, y0, x0 + SIZE, y0 + SIZE,
-	     x0, y1, x0 + SIZE, y1 + SIZE,
-	     GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
-	err = glGetError();
-	if (err != GL_NO_ERROR) {
-		printf("Unexpected GL error state 0x%04x\n", err);
-		piglit_report_result(PIGLIT_FAIL);
-	}
+        if (win_depth_bits == fbo_depth_bits &&
+	    win_stencil_bits == fbo_stencil_bits) {
+		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
+		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
+		copy(x0, y0, x0 + SIZE, y0 + SIZE,
+		     x0, y1, x0 + SIZE, y1 + SIZE,
+		     GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+		err = glGetError();
+		if (err != GL_NO_ERROR) {
+			printf("Unexpected GL error state 0x%04x\n", err);
+			piglit_report_result(PIGLIT_FAIL);
+		}
+
+		/* WIN(bottom) -> FBO(middle) */
+		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
+		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
+		copy(x0, y0, x0 + SIZE, y0 + SIZE,
+		     x0, y1, x0 + SIZE, y1 + SIZE,
+		     GL_DEPTH_BUFFER_BIT);
+
+		/* FBO(middle) -> WIN(top) back to verify WIN -> FBO */
+		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
+		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
+		copy(x0, y1, x0 + SIZE, y1 + SIZE,
+		     x0, y2, x0 + SIZE, y2 + SIZE,
+		     GL_DEPTH_BUFFER_BIT);
+
+		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+		assert(glGetError() == 0);
+
+		printf("Verify 1\n");
+		pass = verify_depth_rect(PAD, y0, SIZE, SIZE) && pass;
+		printf("Verify 2\n");
+		pass = verify_depth_rect(PAD, y1, SIZE, SIZE) && pass;
+		printf("Verify 3\n");
+		pass = verify_depth_rect(PAD, y2, SIZE, SIZE) && pass;
+		printf("Verify 4 (FBO)\n");
+		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+		pass = verify_depth_rect(PAD, y0, SIZE, SIZE) && pass;
+		printf("Verify 5 (FBO)\n");
+		pass = verify_depth_rect(PAD, y1, SIZE, SIZE) && pass;
+        }
 
-	/* WIN(bottom) -> FBO(middle) */
-	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
-	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
-	copy(x0, y0, x0 + SIZE, y0 + SIZE,
-	     x0, y1, x0 + SIZE, y1 + SIZE,
-	     GL_DEPTH_BUFFER_BIT);
-
-	/* FBO(middle) -> WIN(top) back to verify WIN -> FBO */
-	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
-	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
-	copy(x0, y1, x0 + SIZE, y1 + SIZE,
-	     x0, y2, x0 + SIZE, y2 + SIZE,
-	     GL_DEPTH_BUFFER_BIT);
-
-	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-	assert(glGetError() == 0);
-
-    printf("Verify 1\n");
-	pass = verify_depth_rect(PAD, y0, SIZE, SIZE) && pass;
-    printf("Verify 2\n");
-	pass = verify_depth_rect(PAD, y1, SIZE, SIZE) && pass;
-    printf("Verify 3\n");
-	pass = verify_depth_rect(PAD, y2, SIZE, SIZE) && pass;
-    printf("Verify 4 (FBO)\n");
-	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
-	pass = verify_depth_rect(PAD, y0, SIZE, SIZE) && pass;
-    printf("Verify 5 (FBO)\n");
-	pass = verify_depth_rect(PAD, y1, SIZE, SIZE) && pass;
 	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 	assert(glGetError() == 0);
 
-- 
1.7.3.4



More information about the Piglit mailing list