[Piglit] [PATCH 11/20] msaa: Make a data structure for fbo config.
Anuj Phogat
anuj.phogat at gmail.com
Wed Jun 6 15:48:03 PDT 2012
On Tue, Jun 5, 2012 at 5:03 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> This patch creates a data structure to contain the configuration
> parameters passed to Fbo::init(). This allows obscure parameters
> (attach_texture and combine_depth_stencil) to take on default values
> in all tests except those that need to give them special treatment.
> This will be especially important when future patches in the series
> add more obscure configuration parameters.
> ---
> tests/spec/ext_framebuffer_multisample/common.cpp | 70 ++++++++++---------
> tests/spec/ext_framebuffer_multisample/common.h | 31 ++++++++-
> .../ext_framebuffer_multisample/line-smooth.cpp | 4 +-
> .../multisample-blit.cpp | 8 +--
> .../ext_framebuffer_multisample/point-smooth.cpp | 4 +-
> .../ext_framebuffer_multisample/polygon-smooth.cpp | 4 +-
> .../ext_framebuffer_multisample/unaligned-blit.cpp | 8 +--
> .../spec/ext_framebuffer_multisample/upsample.cpp | 5 +-
> 8 files changed, 75 insertions(+), 59 deletions(-)
>
> diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp
> index 0ded77b..195d9c7 100644
> --- a/tests/spec/ext_framebuffer_multisample/common.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/common.cpp
> @@ -110,20 +110,24 @@
>
> #include "common.h"
>
> -/**
> - * \param attach_texture, if true, means to use a texture as color
> - * attachment instead of a renderbuffer.
> - */
> +FboConfig::FboConfig(int num_samples, int width, int height)
> + : num_samples(num_samples),
> + width(width),
> + height(height),
> + combine_depth_stencil(true),
> + attach_texture(false)
> +{
> +}
> +
> void
> -Fbo::init(int num_samples, int width, int height, bool combine_depth_stencil,
> - bool attach_texture)
> +Fbo::init(const FboConfig &initial_config)
> {
> generate();
> - this->width = width;
> - this->height = height;
> - this->combine_depth_stencil = combine_depth_stencil;
> - this->attach_texture = attach_texture;
> - set_samples(num_samples);
> + this->width = initial_config.width;
> + this->height = initial_config.height;
> + this->combine_depth_stencil = initial_config.combine_depth_stencil;
> + this->attach_texture = initial_config.attach_texture;
> + set_samples(initial_config.num_samples);
> }
>
> void
> @@ -1041,28 +1045,28 @@ Test::init(int num_samples, bool small, bool combine_depth_stencil,
> this->pattern_height = pattern_height;
> this->supersample_factor = supersample_factor;
>
> - test_fbo.init(0,
> - small ? 16 : pattern_width,
> - small ? 16 : pattern_height,
> - combine_depth_stencil,
> - false);
> -
> - multisample_fbo.init(num_samples,
> - small ? 16 : pattern_width,
> - small ? 16 : pattern_height,
> - combine_depth_stencil,
> - false);
> - resolve_fbo.init(0,
> - small ? 16 : pattern_width,
> - small ? 16 : pattern_height,
> - combine_depth_stencil,
> - false);
> - supersample_fbo.init(0 /* num_samples */,
> - 1024, 1024, combine_depth_stencil, true);
> - downsample_fbo.init(0 /* num_samples */,
> - 1024 / supersample_factor,
> - 1024 / supersample_factor,
> - combine_depth_stencil, false);
> + FboConfig test_fbo_config(0,
> + small ? 16 : pattern_width,
> + small ? 16 : pattern_height);
> + test_fbo_config.combine_depth_stencil = combine_depth_stencil;
> + test_fbo.init(test_fbo_config);
> +
> + FboConfig multisample_fbo_config = test_fbo_config;
> + multisample_fbo_config.num_samples = num_samples;
> + multisample_fbo.init(multisample_fbo_config);
> +
> + resolve_fbo.init(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);
> +
> + 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);
>
> 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 1287fc0..23b0a40 100644
> --- a/tests/spec/ext_framebuffer_multisample/common.h
> +++ b/tests/spec/ext_framebuffer_multisample/common.h
> @@ -38,6 +38,34 @@ enum test_type_enum {
> };
>
> /**
> + * Information needed to configure a framebuffer object for MSAA
> + * testing.
> + */
> +class FboConfig
> +{
> +public:
> + FboConfig(int num_samples, int width, int height);
> +
> + int num_samples;
> + int width;
> + int height;
> +
> + /**
> + * True if a single renderbuffer should be used as the backing
> + * store for both the depth and stencil attachment points.
> + * Defaults to true.
> + */
> + bool combine_depth_stencil;
> +
> + /**
> + * True if a texture should be used as the backing store for
> + * the color attachment point, false if a renderbuffer should
> + * be used. Defaults to false.
> + */
> + bool attach_texture;
> +};
> +
> +/**
> * Data structure representing one of the framebuffer objects used in
> * the test.
> *
> @@ -48,8 +76,7 @@ enum test_type_enum {
> class Fbo
> {
> public:
> - void init(int num_samples, int width, int height,
> - bool combine_depth_stencil, bool attach_texture);
> + void init(const FboConfig &initial_config);
> void generate();
> void set_samples(int num_samples);
>
> diff --git a/tests/spec/ext_framebuffer_multisample/line-smooth.cpp b/tests/spec/ext_framebuffer_multisample/line-smooth.cpp
> index c9d26fe..7a98276 100644
> --- a/tests/spec/ext_framebuffer_multisample/line-smooth.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/line-smooth.cpp
> @@ -87,9 +87,7 @@ piglit_init(int argc, char **argv)
> test_pattern = new Lines();
> test_pattern->compile();
>
> - test_fbo.init(num_samples, pattern_width, pattern_height,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> + test_fbo.init(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 602b52a..e0330e2 100644
> --- a/tests/spec/ext_framebuffer_multisample/multisample-blit.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/multisample-blit.cpp
> @@ -100,12 +100,8 @@ piglit_init(int argc, char **argv)
> if (manifest_program)
> manifest_program->compile();
>
> - src_fbo.init(num_samples, pattern_width, pattern_height,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> - dst_fbo.init(num_samples, pattern_width, pattern_height,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> + src_fbo.init(FboConfig(num_samples, pattern_width, pattern_height));
> + dst_fbo.init(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 2fe4953..9298782 100644
> --- a/tests/spec/ext_framebuffer_multisample/point-smooth.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/point-smooth.cpp
> @@ -87,9 +87,7 @@ piglit_init(int argc, char **argv)
> test_pattern = new Points();
> test_pattern->compile();
>
> - test_fbo.init(num_samples, pattern_width, pattern_height,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> + test_fbo.init(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 dc086a4..aa15d79 100644
> --- a/tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/polygon-smooth.cpp
> @@ -87,9 +87,7 @@ piglit_init(int argc, char **argv)
> test_pattern = new Triangles();
> test_pattern->compile();
>
> - ms_fbo.init(num_samples, pattern_width, pattern_height,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> + ms_fbo.init(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 5d1f828..8179411 100644
> --- a/tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/unaligned-blit.cpp
> @@ -158,12 +158,8 @@ piglit_init(int argc, char **argv)
> test_pattern->compile();
> if (manifest_program)
> manifest_program->compile();
> - src_fbo.init(src_samples, pattern_size, pattern_size,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> - dst_fbo.init(dst_samples, pattern_size, pattern_size,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> + src_fbo.init(FboConfig(src_samples, pattern_size, pattern_size));
> + dst_fbo.init(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 9ae4c9c..f6b0944 100644
> --- a/tests/spec/ext_framebuffer_multisample/upsample.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/upsample.cpp
> @@ -114,9 +114,8 @@ piglit_init(int argc, char **argv)
> if (manifest_program)
> manifest_program->compile();
>
> - multisample_fbo.init(num_samples, pattern_width, pattern_height,
> - true /* combine_depth_stencil */,
> - false /* attach_texture */);
> + multisample_fbo.init(FboConfig(num_samples, pattern_width,
> + pattern_height));
> }
>
> enum piglit_result
> --
> 1.7.7.6
>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
More information about the Piglit
mailing list