[Piglit] [PATCH 17/20] msaa: Make a new Fbo::try_setup() function.

Paul Berry stereotype441 at gmail.com
Tue Jun 5 17:03:27 PDT 2012


In contrast to the Fbo::setup() function (which terminates the test if
the framebuffer is incomplete), Fbo::try_setup() merely returns a
boolean indicating whether the framebuffer is complete.  This will be
necessary to allow different color formats to be tested, since we
won't want to terminate the test if a non-renderable color format is
attempted.
---
 tests/spec/ext_framebuffer_multisample/common.cpp |   46 ++++++++++++++-------
 tests/spec/ext_framebuffer_multisample/common.h   |    1 +
 2 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp
index ce0552e..d7cbe9c 100644
--- a/tests/spec/ext_framebuffer_multisample/common.cpp
+++ b/tests/spec/ext_framebuffer_multisample/common.cpp
@@ -147,11 +147,37 @@ Fbo::set_samples(int num_samples)
 
 /**
  * Modify the state of the framebuffer object to reflect the state in
- * new_config.
+ * new_config.  if the resulting framebuffer is incomplete, terminate
+ * the test.
  */
 void
 Fbo::setup(const FboConfig &new_config)
 {
+	if (!try_setup(new_config)) {
+		printf("Framebuffer not complete\n");
+		if (!config.combine_depth_stencil) {
+			/* Some implementations do not support
+			 * separate depth and stencil attachments, so
+			 * don't consider it an error if we fail to
+			 * make a complete framebuffer using separate
+			 * depth and stencil attachments.
+			 */
+			piglit_report_result(PIGLIT_SKIP);
+		} else {
+			piglit_report_result(PIGLIT_FAIL);
+		}
+	}
+}
+
+
+/**
+ * Modify the state of the framebuffer object to reflect the state in
+ * config.  Return true if the resulting framebuffer is complete,
+ * false otherwise.
+ */
+bool
+Fbo::try_setup(const FboConfig &new_config)
+{
 	this->config = new_config;
 
 	if (!gl_objects_generated)
@@ -223,22 +249,12 @@ Fbo::setup(const FboConfig &new_config)
 					  GL_RENDERBUFFER, depth_rb);
 	}
 
-	if (glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
-		printf("Framebuffer not complete\n");
-		if (!config.combine_depth_stencil) {
-			/* Some implementations do not support
-			 * separate depth and stencil attachments, so
-			 * don't consider it an error if we fail to
-			 * make a complete framebuffer using separate
-			 * depth and stencil attachments.
-			 */
-			piglit_report_result(PIGLIT_SKIP);
-		} else {
-			piglit_report_result(PIGLIT_FAIL);
-		}
-	}
+	bool success = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)
+		== GL_FRAMEBUFFER_COMPLETE;
 
 	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+
+	return success;
 }
 
 
diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h
index 3caf8a0..0e6913f 100644
--- a/tests/spec/ext_framebuffer_multisample/common.h
+++ b/tests/spec/ext_framebuffer_multisample/common.h
@@ -86,6 +86,7 @@ public:
 
 	void set_samples(int num_samples);
 	void setup(const FboConfig &new_config);
+	bool try_setup(const FboConfig &new_config);
 
 	void set_viewport();
 
-- 
1.7.7.6



More information about the Piglit mailing list