[Piglit] [PATCH] glean: Fix fbo errors case

Chris Forbes chrisf at ijw.co.nz
Mon Mar 24 22:33:51 PDT 2014


If the framebuffer has no attachments at all, the first incomplete
status generated is FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT.

Adjust the tests for FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER and
FRAMEBUFFER_INCOMPLETE_READ_BUFFER to avoid tripping over this, by
adding a depth renderbuffer attachment.

This extra attachment is chosen to avoid imposing additional
requirements -- multiple color attachments are not required, nor
are depth textures.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76579
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 tests/glean/tfbo.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/glean/tfbo.cpp b/tests/glean/tfbo.cpp
index d39eb6f..fcf457f 100644
--- a/tests/glean/tfbo.cpp
+++ b/tests/glean/tfbo.cpp
@@ -1218,6 +1218,7 @@ FBOTest::testErrorHandling(void)
 {
         GLuint fbs[1];
         GLuint textures[2];
+	GLuint renderbuffer;
         GLenum status;
 	bool have_ARB_ES2 = GLUtils::haveExtension("GL_ARB_ES2_compatibility");
 
@@ -1309,13 +1310,25 @@ FBOTest::testErrorHandling(void)
                 // The value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not
                 // be NONE for any color attachment point(s) named by
 		// DRAW_BUFFERi.
+		// [Note: to avoid being caught by the no-attachments
+		// case above, we attach a depth renderbuffer.]
                 glGenFramebuffersEXT(1, fbs);
                 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
                 glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT +
                              maxColorAttachment - 1);
+		glGenRenderbuffers(1, &renderbuffer);
+		glBindRenderbuffer(GL_RENDERBUFFER_EXT, renderbuffer);
+		glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
+				      TEXSIZE, TEXSIZE);
+		glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
+					  GL_DEPTH_ATTACHMENT_EXT,
+					  GL_RENDERBUFFER_EXT,
+					  renderbuffer);
                 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
                 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
                 glDeleteFramebuffersEXT(1, fbs);
+		glDeleteTextures(1, textures);
+		glDeleteRenderbuffers(1, &renderbuffer);
                 if (status != GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT &&
 		    !have_ARB_ES2) {
                         REPORT_FAILURE
@@ -1326,14 +1339,25 @@ FBOTest::testErrorHandling(void)
                 // If READ_BUFFER is not NONE, then the value of
                 // FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not be NONE for
                 // the color attachment point named by READ_BUFFER.
+		// [Note: to avoid being caught by the no-attachments
+		// case above, we attach a depth renderbuffer.]
                 glGenFramebuffersEXT(1, fbs);
                 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
                 glDrawBuffer(GL_NONE);
                 glReadBuffer(GL_COLOR_ATTACHMENT0_EXT +
                              maxColorAttachment - 1);
+		glGenRenderbuffers(1, &renderbuffer);
+		glBindRenderbuffer(GL_RENDERBUFFER_EXT, renderbuffer);
+		glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
+				      TEXSIZE, TEXSIZE);
+		glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
+					  GL_DEPTH_ATTACHMENT_EXT,
+					  GL_RENDERBUFFER_EXT,
+					  renderbuffer);
                 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
                 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
                 glDeleteFramebuffersEXT(1, fbs);
+		glDeleteRenderbuffers(1, &renderbuffer);
                 if (status != GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT &&
 		    !have_ARB_ES2) {
                         REPORT_FAILURE
-- 
1.9.1



More information about the Piglit mailing list