[Piglit] [PATCH 3/4] fbo: Verify deleting the texture bound to the current FBO

Ian Romanick idr at freedesktop.org
Sat Jul 27 16:10:38 PDT 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Also verify deleting the renderbuffer bound to the current FBO.  Both of
these should result in GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT.
This currently passes on Mesa.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/fbo/fbo-incomplete.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/tests/fbo/fbo-incomplete.cpp b/tests/fbo/fbo-incomplete.cpp
index 13c27b4..76ff122 100644
--- a/tests/fbo/fbo-incomplete.cpp
+++ b/tests/fbo/fbo-incomplete.cpp
@@ -260,6 +260,83 @@ invalid_array_layer(void)
 	return t.pass();
 }
 
+/**
+ * Verify that deleting the texture attached the currently bound FBO
+ * results in incompleteness.
+ */
+bool
+delete_texture_of_current_fbo(void)
+{
+	incomplete_fbo_test t("delete texture of bound FBO",
+			      GL_TEXTURE_2D);
+
+	/* Create a small color texture and attach it.  Everything should
+	 * be fine at this point.
+	 */
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA,
+		     GL_UNSIGNED_BYTE, NULL);
+	glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+			       GL_TEXTURE_2D, t.tex, 0);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		return t.fail();
+
+	if (!t.check_fbo_status(GL_FRAMEBUFFER_COMPLETE))
+		return t.fail();
+
+	/* Now unbind the texture and delete it.  t.rb is set to zero so
+	 * that the destructor won't try to delete it again.
+	 */
+	glBindTexture(GL_TEXTURE_2D, 0);
+	glDeleteTextures(1, &t.tex);
+	t.tex = 0;
+
+	/* Now the deleted attachment is "missing."
+	 */
+	if (!t.check_fbo_status(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT))
+		return t.fail();
+
+	return t.pass();
+}
+
+/**
+ * Verify that deleting the renderbuffer attached the currently bound FBO
+ * results in incompleteness.
+ */
+bool
+delete_renderbuffer_of_current_fbo(void)
+{
+	incomplete_fbo_test t("delete renderbuffer of bound FBO",
+			      GL_RENDERBUFFER);
+
+	/* Create a small color renderbuffer and attach it.  Everything should
+	 * be fine at this point.
+	 */
+	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 4, 4);
+	glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+				  GL_RENDERBUFFER, rb);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		return t.fail();
+
+	if (!t.check_fbo_status(GL_FRAMEBUFFER_COMPLETE))
+		return t.fail();
+
+	/* Now unbind the renderbuffer and delete it.  t.rb is set to zero so
+	 * that the destructor won't try to delete it again.
+	 */
+	glBindRenderbuffer(GL_RENDERBUFFER, 0);
+	glDeleteRenderbuffers(1, &t.rb);
+	t.rb = 0;
+
+	/* Now the deleted attachment is "missing."
+	 */
+	if (!t.check_fbo_status(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT))
+		return t.fail();
+
+	return t.pass();
+}
+
 enum piglit_result
 piglit_display(void)
 {
@@ -277,6 +354,8 @@ piglit_init(int argc, char **argv)
 	pass = incomplete_0_by_0_renderbuffer() && pass;
 	pass = invalid_3d_slice() && pass;
 	pass = invalid_array_layer() && pass;
+	pass = delete_texture_of_current_fbo() && pass;
+	pass = delete_renderbuffer_of_current_fbo() && pass;
 
 	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
-- 
1.8.1.4



More information about the Piglit mailing list