summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2012-06-05 11:06:04 -0700
committerPaul Berry <stereotype441@gmail.com>2012-06-07 10:58:22 -0700
commit2a260bdb92ab4d99f7c1f83eccdf76a79929bc9d (patch)
tree6758735c03096aa1ec73b8724640162843f7d4fe
parent514ebc5e2285c1de1ef769ab49492c3cab5e4748 (diff)
msaa: Make it possible to reconfigure the fbo after initial use.
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(). Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
-rw-r--r--tests/spec/ext_framebuffer_multisample/common.cpp36
-rw-r--r--tests/spec/ext_framebuffer_multisample/common.h13
-rw-r--r--tests/spec/ext_framebuffer_multisample/line-smooth.cpp2
-rw-r--r--tests/spec/ext_framebuffer_multisample/multisample-blit.cpp4
-rw-r--r--tests/spec/ext_framebuffer_multisample/point-smooth.cpp2
-rw-r--r--tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp2
-rw-r--r--tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp4
-rw-r--r--tests/spec/ext_framebuffer_multisample/upsample.cpp4
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 a4b585807..647151a19 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 d8ba2e0b6..b27c9de52 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 7a982767e..7f615d96a 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 e0330e2d6..d8380f4ee 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 929878234..287509fbe 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 aa15d7998..b16e70b5c 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 817941142..ae6eac469 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 f6b0944e8..049c12c0c 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