[Piglit] [PATCH 15/20] msaa: Make it possible to reconfigure the fbo after initial use.

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


This patch makes it safe to re-initialize the state of an Fbo object
to a new configuration.  This will be necessary to allow this object
to be used for testing formats, since one piglit test will have to
test several different Fbo formats in sequence.

To reflect the fact that initialization of the Fbo object is no longer
a one-time action, we now use the name setup() for the function that
sets the Fbo state, rather than init().
---
 tests/spec/ext_framebuffer_multisample/common.cpp  |   36 ++++++++++----------
 tests/spec/ext_framebuffer_multisample/common.h    |   13 +++++--
 .../ext_framebuffer_multisample/line-smooth.cpp    |    2 +-
 .../multisample-blit.cpp                           |    4 +-
 .../ext_framebuffer_multisample/point-smooth.cpp   |    2 +-
 .../ext_framebuffer_multisample/polygon-smooth.cpp |    2 +-
 .../ext_framebuffer_multisample/unaligned-blit.cpp |    4 +-
 .../spec/ext_framebuffer_multisample/upsample.cpp  |    4 +-
 8 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp
index a4b5858..647151a 100644
--- a/tests/spec/ext_framebuffer_multisample/common.cpp
+++ b/tests/spec/ext_framebuffer_multisample/common.cpp
@@ -120,19 +120,12 @@ FboConfig::FboConfig(int num_samples, int width, int height)
 }
 
 Fbo::Fbo()
-	: config(0, 0, 0) /* will be overwritten when init() is called */
+	: config(0, 0, 0), /* will be overwritten on first call to setup() */
+	  gl_objects_generated(false)
 {
 }
 
 void
-Fbo::init(const FboConfig &initial_config)
-{
-	generate_gl_objects();
-	this->config = initial_config;
-	setup();
-}
-
-void
 Fbo::generate_gl_objects(void)
 {
 	glGenFramebuffers(1, &handle);
@@ -140,22 +133,29 @@ Fbo::generate_gl_objects(void)
 	glGenRenderbuffers(1, &color_rb);
 	glGenRenderbuffers(1, &depth_rb);
 	glGenRenderbuffers(1, &stencil_rb);
+	gl_objects_generated = true;
 }
 
 void
 Fbo::set_samples(int num_samples)
 {
-	this->config.num_samples = num_samples;
-	setup();
+	FboConfig new_config = this->config;
+	new_config.num_samples = num_samples;
+	setup(new_config);
 }
 
 /**
  * Modify the state of the framebuffer object to reflect the state in
- * this->config.
+ * new_config.
  */
 void
-Fbo::setup()
+Fbo::setup(const FboConfig &new_config)
 {
+	this->config = new_config;
+
+	if (!gl_objects_generated)
+		generate_gl_objects();
+
 	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, handle);
 
 	/* Color buffer */
@@ -1061,24 +1061,24 @@ Test::init(int num_samples, bool small, bool combine_depth_stencil,
 				  small ? 16 : pattern_width,
 				  small ? 16 : pattern_height);
 	test_fbo_config.combine_depth_stencil = combine_depth_stencil;
-	test_fbo.init(test_fbo_config);
+	test_fbo.setup(test_fbo_config);
 
 	FboConfig multisample_fbo_config = test_fbo_config;
 	multisample_fbo_config.num_samples = num_samples;
-	multisample_fbo.init(multisample_fbo_config);
+	multisample_fbo.setup(multisample_fbo_config);
 
-	resolve_fbo.init(test_fbo_config);
+	resolve_fbo.setup(test_fbo_config);
 
 	FboConfig supersample_fbo_config = test_fbo_config;
 	supersample_fbo_config.width = 1024;
 	supersample_fbo_config.height = 1024;
 	supersample_fbo_config.attach_texture = true;
-	supersample_fbo.init(supersample_fbo_config);
+	supersample_fbo.setup(supersample_fbo_config);
 
 	FboConfig downsample_fbo_config = test_fbo_config;
 	downsample_fbo_config.width = 1024 / supersample_factor;
 	downsample_fbo_config.height = 1024 / supersample_factor;
-	downsample_fbo.init(downsample_fbo_config);
+	downsample_fbo.setup(downsample_fbo_config);
 
 	pattern->compile();
 	downsample_prog.compile(supersample_factor);
diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h
index d8ba2e0..b27c9de 100644
--- a/tests/spec/ext_framebuffer_multisample/common.h
+++ b/tests/spec/ext_framebuffer_multisample/common.h
@@ -78,10 +78,8 @@ class Fbo
 public:
 	Fbo();
 
-	void init(const FboConfig &initial_config);
-	void generate_gl_objects();
 	void set_samples(int num_samples);
-	void setup();
+	void setup(const FboConfig &new_config);
 
 	void set_viewport();
 
@@ -113,6 +111,15 @@ public:
 	 * for the stencil buffer.
 	 */
 	GLuint stencil_rb;
+
+private:
+	void generate_gl_objects();
+
+	/**
+	 * True if generate_gl_objects has been called and color_tex,
+	 * color_rb, depth_rb, and stencil_rb have been initialized.
+	 */
+	bool gl_objects_generated;
 };
 
 /**
diff --git a/tests/spec/ext_framebuffer_multisample/line-smooth.cpp b/tests/spec/ext_framebuffer_multisample/line-smooth.cpp
index 7a98276..7f615d9 100644
--- a/tests/spec/ext_framebuffer_multisample/line-smooth.cpp
+++ b/tests/spec/ext_framebuffer_multisample/line-smooth.cpp
@@ -87,7 +87,7 @@ piglit_init(int argc, char **argv)
 	test_pattern = new Lines();
 	test_pattern->compile();
 
-	test_fbo.init(FboConfig(num_samples, pattern_width, pattern_height));
+	test_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));
 
 	glEnable (GL_BLEND);
 	glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
diff --git a/tests/spec/ext_framebuffer_multisample/multisample-blit.cpp b/tests/spec/ext_framebuffer_multisample/multisample-blit.cpp
index e0330e2..d8380f4 100644
--- a/tests/spec/ext_framebuffer_multisample/multisample-blit.cpp
+++ b/tests/spec/ext_framebuffer_multisample/multisample-blit.cpp
@@ -100,8 +100,8 @@ piglit_init(int argc, char **argv)
 	if (manifest_program)
 		manifest_program->compile();
 
-	src_fbo.init(FboConfig(num_samples, pattern_width, pattern_height));
-	dst_fbo.init(FboConfig(num_samples, pattern_width, pattern_height));
+	src_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));
+	dst_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));
 }
 
 enum piglit_result
diff --git a/tests/spec/ext_framebuffer_multisample/point-smooth.cpp b/tests/spec/ext_framebuffer_multisample/point-smooth.cpp
index 9298782..287509f 100644
--- a/tests/spec/ext_framebuffer_multisample/point-smooth.cpp
+++ b/tests/spec/ext_framebuffer_multisample/point-smooth.cpp
@@ -87,7 +87,7 @@ piglit_init(int argc, char **argv)
 	test_pattern = new Points();
 	test_pattern->compile();
 
-	test_fbo.init(FboConfig(num_samples, pattern_width, pattern_height));
+	test_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));
 
 	/* Blending is required to test smooth points */
 	glEnable (GL_BLEND);
diff --git a/tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp b/tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp
index aa15d79..b16e70b 100644
--- a/tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp
+++ b/tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp
@@ -87,7 +87,7 @@ piglit_init(int argc, char **argv)
 	test_pattern = new Triangles();
 	test_pattern->compile();
 
-	ms_fbo.init(FboConfig(num_samples, pattern_width, pattern_height));
+	ms_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));
 
 	/* Enable blending to test GL_POLYGON_SMOOTH */
 	glEnable (GL_BLEND);
diff --git a/tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp b/tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp
index 8179411..ae6eac4 100644
--- a/tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp
+++ b/tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp
@@ -158,8 +158,8 @@ piglit_init(int argc, char **argv)
 	test_pattern->compile();
 	if (manifest_program)
 		manifest_program->compile();
-	src_fbo.init(FboConfig(src_samples, pattern_size, pattern_size));
-	dst_fbo.init(FboConfig(dst_samples, pattern_size, pattern_size));
+	src_fbo.setup(FboConfig(src_samples, pattern_size, pattern_size));
+	dst_fbo.setup(FboConfig(dst_samples, pattern_size, pattern_size));
 }
 
 enum piglit_result
diff --git a/tests/spec/ext_framebuffer_multisample/upsample.cpp b/tests/spec/ext_framebuffer_multisample/upsample.cpp
index f6b0944..049c12c 100644
--- a/tests/spec/ext_framebuffer_multisample/upsample.cpp
+++ b/tests/spec/ext_framebuffer_multisample/upsample.cpp
@@ -114,8 +114,8 @@ piglit_init(int argc, char **argv)
 	if (manifest_program)
 		manifest_program->compile();
 
-	multisample_fbo.init(FboConfig(num_samples, pattern_width,
-				       pattern_height));
+	multisample_fbo.setup(FboConfig(num_samples, pattern_width,
+					pattern_height));
 }
 
 enum piglit_result
-- 
1.7.7.6



More information about the Piglit mailing list