[Piglit] [PATCH 3/8] arb_texture_multisample: new test for fb configs
Chris Forbes
chrisf at ijw.co.nz
Sat Jan 5 01:07:34 PST 2013
This tests FBO setup with various combinations of multisample textures
and `classic` multisample renderbuffers, and for each, checks:
- That the renderbuffers or textures can be created
- Completeness status
If the configuration is expected to work, additionally:
- Actual sample count >= requested sample count
- Sample positions meet spec requirements (all obtainable, and in [0,1]
Covers the fixedsamplelocations and sample count consistency
requirements in the spec.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
tests/all.tests | 1 +
.../spec/arb_texture_multisample/CMakeLists.gl.txt | 1 +
.../spec/arb_texture_multisample/fb-completeness.c | 242 +++++++++++++++++++++
3 files changed, 244 insertions(+)
create mode 100644 tests/spec/arb_texture_multisample/fb-completeness.c
diff --git a/tests/all.tests b/tests/all.tests
index acaf1ad..379964f 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -844,6 +844,7 @@ add_plain_test(arb_point_sprite, 'point-sprite')
arb_texture_multisample = Group()
spec['ARB_texture_multisample'] = arb_texture_multisample
add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-minmax')
+add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-fb-completeness')
# Group AMD_shader_stencil_export
spec['AMD_shader_stencil_export'] = Group()
diff --git a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
index 90dae9e..d793256 100644
--- a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
@@ -11,5 +11,6 @@ link_libraries (
)
piglit_add_executable (arb_texture_multisample-minmax minmax.c)
+piglit_add_executable (arb_texture_multisample-fb-completeness fb-completeness.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_texture_multisample/fb-completeness.c b/tests/spec/arb_texture_multisample/fb-completeness.c
new file mode 100644
index 0000000..44f9786
--- /dev/null
+++ b/tests/spec/arb_texture_multisample/fb-completeness.c
@@ -0,0 +1,242 @@
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 30;
+
+ config.window_width = 10;
+ config.window_height = 10;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+struct attachment_info
+{
+ GLenum target;
+ GLenum attachment;
+ int samples;
+ int width;
+ int height;
+ bool fixedsamplelocations;
+ GLuint format;
+};
+
+struct test_info
+{
+ char const *name;
+ int expected;
+ struct attachment_info attachments[4];
+};
+
+struct test_info tests[] = {
+ { "single_msaa_color", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "msaa_mrt_color", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "msaa_mixed_texture_and_renderbuffer", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "mixed_msaa_and_plain", GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { GL_RENDERBUFFER, GL_COLOR_ATTACHMENT1, 0, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "msaa_mrt_color_nofixed", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_FALSE },
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_FALSE },
+ { 0 },
+ }
+ },
+ { "mix_fixedmode", GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_FALSE },
+ { 0 },
+ }
+ },
+ { "mix_fixedmode_with_renderbuffer", GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_FALSE },
+ { GL_RENDERBUFFER, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "msaa_depth", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_DEPTH_ATTACHMENT, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "msaa_depth_stencil", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_DEPTH_ATTACHMENT, 4, 64, 64, GL_TRUE,
+ GL_DEPTH_STENCIL
+ },
+ { 0 },
+ }
+ },
+ { "msaa_classic_stencil", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { GL_RENDERBUFFER, GL_STENCIL_ATTACHMENT, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { "msaa_stencil", GL_FRAMEBUFFER_COMPLETE,
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_STENCIL_ATTACHMENT, 4, 64, 64, GL_TRUE },
+ { 0 },
+ }
+ },
+ { 0 },
+};
+
+static GLuint
+choose_format(struct attachment_info *att)
+{
+ if (att->format)
+ return att->format;
+
+ switch(att->attachment) {
+ case GL_DEPTH_ATTACHMENT:
+ return GL_DEPTH_COMPONENT;
+ case GL_STENCIL_ATTACHMENT:
+ return GL_STENCIL_INDEX;
+ default:
+ return GL_RGBA;
+ }
+}
+
+static enum piglit_result
+check_sample_positions(int expected_sample_count)
+{
+ GLint samples;
+ int i;
+
+ glGetIntegerv(GL_SAMPLES, &samples);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ if (samples < expected_sample_count) {
+ printf("Expected sample count at least %d, got %d\n",
+ expected_sample_count, samples);
+ return PIGLIT_FAIL;
+ }
+
+ for (i = 0; i < samples; i++) {
+ float sample_pos[2];
+
+ glGetMultisamplefv(GL_SAMPLE_POSITION, i, sample_pos);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ printf("Sample %d position %2.2f %2.2f\n",
+ i, sample_pos[0], sample_pos[1] );
+
+ if (sample_pos[0] < 0 || sample_pos[0] > 1 ||
+ sample_pos[1] < 0 || sample_pos[1] > 1) {
+ printf("Sample %d out of range\n", i );
+ return PIGLIT_FAIL;
+ }
+ }
+
+ return PIGLIT_PASS;
+}
+
+static enum piglit_result
+exec_test(struct test_info *info)
+{
+ GLuint fb, tex, rb;
+ GLint result;
+ struct attachment_info *att;
+
+ glGenFramebuffers(1, &fb);
+ glBindFramebuffer(GL_FRAMEBUFFER, fb);
+
+ printf("Testing fbo completeness for config '%s'\n", info->name);
+
+ for (att=info->attachments; att->target; att++) {
+ printf(" Att target=%x att=%x samples=%d dims=%d,%d fixed=%d\n",
+ att->target, att->attachment, att->samples,
+ att->width, att->height, att->fixedsamplelocations);
+
+ switch (att->target) {
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
+ glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,
+ att->samples, choose_format(att),
+ att->width, att->height,
+ att->fixedsamplelocations);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glFramebufferTexture2D(GL_FRAMEBUFFER, att->attachment,
+ att->target, tex, 0);
+ break;
+
+ case GL_RENDERBUFFER:
+ /* RENDERBUFFER has fixedsamplelocations implicitly */
+ assert(att->fixedsamplelocations);
+ glGenRenderbuffers(1, &rb);
+ glBindRenderbuffer(GL_RENDERBUFFER, rb);
+ if (att->samples == 0) {
+ /* non-MSAA renderbuffer */
+ glRenderbufferStorage(GL_RENDERBUFFER, choose_format(att),
+ att->width, att->height);
+ }
+ else {
+ glRenderbufferStorageMultisample(GL_RENDERBUFFER,
+ att->samples, choose_format(att),
+ att->width, att->height);
+ }
+
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER,
+ att->attachment, att->target, rb);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+ break;
+
+ default:
+ assert(!"Unsupported target");
+ }
+ }
+
+ result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ printf("glCheckFramebufferStatus: expected %d, got %d\n",
+ info->expected, result);
+ if (result != info->expected)
+ return PIGLIT_FAIL;
+
+ if (result == GL_FRAMEBUFFER_COMPLETE)
+ return check_sample_positions(info->attachments->samples);
+
+ return PIGLIT_PASS;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ struct test_info *info;
+ enum piglit_result result = PIGLIT_PASS;
+
+ for (info = tests; info->name; info++)
+ piglit_merge_result(&result, exec_test(info));
+
+ piglit_report_result(result);
+}
--
1.8.1
More information about the Piglit
mailing list