[Piglit] [PATCH 7/7] EXT_framebuffer_multisample/negative-mismatched-samples: New test.

Eric Anholt eric at anholt.net
Wed Jan 11 14:32:30 PST 2012


---
 tests/all.tests                                    |    1 +
 .../ext_framebuffer_multisample/CMakeLists.gl.txt  |    1 +
 .../negative-mismatched-samples.c                  |  145 ++++++++++++++++++++
 3 files changed, 147 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c

diff --git a/tests/all.tests b/tests/all.tests
index 810cb0d..dfe5dd8 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1217,6 +1217,7 @@ ext_framebuffer_multisample['dlist'] = concurrent_test('ext_framebuffer_multisam
 ext_framebuffer_multisample['negative-copypixels'] = concurrent_test('ext_framebuffer_multisample-negative-copypixels')
 ext_framebuffer_multisample['negative-copyteximage'] = concurrent_test('ext_framebuffer_multisample-negative-copyteximage')
 ext_framebuffer_multisample['negative-max-samples'] = concurrent_test('ext_framebuffer_multisample-negative-max-samples')
+ext_framebuffer_multisample['negative-mismatched-samples'] = concurrent_test('ext_framebuffer_multisample-negative-mismatched-samples')
 ext_framebuffer_multisample['negative-readpixels'] = concurrent_test('ext_framebuffer_multisample-negative-readpixels')
 ext_framebuffer_multisample['renderbufferstorage-samples'] = concurrent_test('ext_framebuffer_multisample-renderbufferstorage-samples')
 ext_framebuffer_multisample['renderbuffer-samples'] = concurrent_test('ext_framebuffer_multisample-renderbuffer-samples')
diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
index 2e12dfa..f66687f 100644
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
@@ -15,6 +15,7 @@ add_executable (ext_framebuffer_multisample-dlist dlist.c)
 add_executable (ext_framebuffer_multisample-negative-copypixels negative-copypixels.c)
 add_executable (ext_framebuffer_multisample-negative-copyteximage negative-copyteximage.c)
 add_executable (ext_framebuffer_multisample-negative-max-samples negative-max-samples.c)
+add_executable (ext_framebuffer_multisample-negative-mismatched-samples negative-mismatched-samples.c)
 add_executable (ext_framebuffer_multisample-negative-readpixels negative-readpixels.c)
 add_executable (ext_framebuffer_multisample-renderbuffer-samples renderbuffer-samples.c)
 add_executable (ext_framebuffer_multisample-renderbufferstorage-samples renderbufferstorage-samples.c)
diff --git a/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c b/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c
new file mode 100644
index 0000000..c1d3c0e
--- /dev/null
+++ b/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util.h"
+
+/**
+ * @file samples.c
+ *
+ * From the EXT_framebuffer_multisample spec:
+ *
+ *     "Modification to 4.4.4.2 (Framebuffer Completeness)
+ *
+ *          Add an entry to the bullet list:
+ *
+ *          * The value of RENDERBUFFER_SAMPLES_EXT is the same for all attached
+ *            images.
+ *            { FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT }"
+ */
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHED */
+	return PIGLIT_FAIL;
+}
+
+static bool
+test_buffers(GLuint rb0, GLuint samples0,
+	     GLuint rb1, GLuint samples1)
+{
+	GLenum status;
+
+	if (rb0 == rb1)
+		return true;
+
+	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+				     GL_RENDERBUFFER, rb0);
+	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
+				     GL_RENDERBUFFER, rb1);
+
+	status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
+	if (samples0 != samples1) {
+		if (status != GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE) {
+			fprintf(stderr,
+				"Framebuffer with %d and %d samples: "
+				"reported 0x%x, not "
+				"GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
+				samples0, samples1, status);
+			return false;
+		}
+	} else if (status != GL_FRAMEBUFFER_COMPLETE) {
+		fprintf(stderr,
+			"Framebuffer with %d and %d samples incomplete: "
+			"reported 0x%x, not GL_FRAMEBUFFER_COMPLETE\n",
+			samples0, samples1, status);
+		return false;
+	}
+	return true;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLint max_samples, max_draw_buffers;
+	GLuint *rb, fb;
+	GLint *rb_samples;
+	bool pass = true;
+	int i, buf0, buf1;
+	static const GLenum buffers[2] = {
+		GL_COLOR_ATTACHMENT0,
+		GL_COLOR_ATTACHMENT1
+	};
+
+	piglit_require_extension("GL_EXT_framebuffer_multisample");
+	piglit_require_extension("GL_ARB_draw_buffers");
+
+	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
+	if (max_draw_buffers < 2) {
+		printf("test requires 2 draw buffers.\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
+
+	rb = malloc(max_samples * sizeof(*rb));
+	rb_samples = malloc(max_samples * sizeof(*rb_samples));
+
+	glGenFramebuffersEXT(1, &fb);
+	glBindFramebufferEXT(GL_FRAMEBUFFER, fb);
+
+	glDrawBuffers(2, buffers);
+	glReadBuffer(GL_COLOR_ATTACHMENT0);
+
+	glGenRenderbuffers(max_samples, rb);
+
+	for (i = 0; i < max_samples; i++) {
+		glBindRenderbufferEXT(GL_RENDERBUFFER, rb[i]);
+		glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
+						    i,
+						    GL_RGBA, 1, 1);
+
+		glGetRenderbufferParameterivEXT(GL_RENDERBUFFER,
+						GL_RENDERBUFFER_SAMPLES,
+						&rb_samples[i]);
+	}
+
+	for (buf0 = 0; buf0 < max_samples; buf0++) {
+		for (buf1 = 0; buf1 < max_samples; buf1++) {
+			pass = test_buffers(rb[buf0], rb_samples[buf0],
+					    rb[buf1], rb_samples[buf1]) && pass;
+		}
+	}
+
+	glDeleteFramebuffersEXT(1, &fb);
+	glDeleteRenderbuffersEXT(max_samples, rb);
+
+	free(rb);
+	free(rb_samples);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.7.7.3



More information about the Piglit mailing list