[Piglit] [PATCH] msaa: Add a test for the GL_MULTISAMPLE enable flag.

Paul Berry stereotype441 at gmail.com
Tue Jun 19 07:45:15 PDT 2012


---
 tests/all.tests                                    |    1 +
 .../ext_framebuffer_multisample/CMakeLists.gl.txt  |    1 +
 .../ext_framebuffer_multisample/enable-flag.cpp    |  149 ++++++++++++++++++++
 3 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/ext_framebuffer_multisample/enable-flag.cpp

diff --git a/tests/all.tests b/tests/all.tests
index 42804a7..39b0e9b 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1325,6 +1325,7 @@ ext_framebuffer_multisample['blit-mismatched-samples'] = concurrent_test('ext_fr
 ext_framebuffer_multisample['blit-mismatched-sizes'] = concurrent_test('ext_framebuffer_multisample-blit-mismatched-sizes')
 ext_framebuffer_multisample['blit-mismatched-formats'] = concurrent_test('ext_framebuffer_multisample-blit-mismatched-formats')
 ext_framebuffer_multisample['dlist'] = concurrent_test('ext_framebuffer_multisample-dlist')
+ext_framebuffer_multisample['enable-flag'] = PlainExecTest('ext_framebuffer_multisample-enable-flag -auto')
 ext_framebuffer_multisample['minmax'] = concurrent_test('ext_framebuffer_multisample-minmax')
 ext_framebuffer_multisample['negative-copypixels'] = concurrent_test('ext_framebuffer_multisample-negative-copypixels')
 ext_framebuffer_multisample['negative-copyteximage'] = concurrent_test('ext_framebuffer_multisample-negative-copyteximage')
diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
index 073aec0..b9deef0 100644
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
@@ -15,6 +15,7 @@ piglit_add_executable (ext_framebuffer_multisample-blit-mismatched-sizes common.
 piglit_add_executable (ext_framebuffer_multisample-blit-mismatched-formats common.cpp blit-mismatched-formats.cpp)
 piglit_add_executable (ext_framebuffer_multisample-clip-and-scissor-blit common.cpp clip-and-scissor-blit.cpp)
 piglit_add_executable (ext_framebuffer_multisample-dlist dlist.c)
+piglit_add_executable (ext_framebuffer_multisample-enable-flag enable-flag.cpp common.cpp)
 piglit_add_executable (ext_framebuffer_multisample-formats common.cpp formats.cpp)
 piglit_add_executable (ext_framebuffer_multisample-line-smooth common.cpp line-smooth.cpp)
 piglit_add_executable (ext_framebuffer_multisample-minmax minmax.c)
diff --git a/tests/spec/ext_framebuffer_multisample/enable-flag.cpp b/tests/spec/ext_framebuffer_multisample/enable-flag.cpp
new file mode 100644
index 0000000..4d88390
--- /dev/null
+++ b/tests/spec/ext_framebuffer_multisample/enable-flag.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright © 2012 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.
+ */
+
+/**
+ * \file enable-flag.cpp
+ *
+ * This test verifies the proper functioning of the GL_MULTISAMPLE
+ * flag.  From the GL 3.0 spec (p.116):
+ *
+ *     "Multisample rasterization is enabled or disabled by calling
+ *     Enable or Disable with the symbolic constant MULTISAMPLE."
+ *
+ * Elsewhere in the spec, where multisample rasterization is described
+ * (sections 3.4.3, 3.5.4, and 3.6.6), the following text is
+ * consistently used:
+ *
+ *     "If MULTISAMPLE is enabled, and the value of SAMPLE_BUFFERS is
+ *     one, then..."
+ *
+ * So, in other words, disabling GL_MULTISAMPLE should prevent
+ * multisample rasterization from occurring, even if the draw
+ * framebuffer is multisampled.
+ *
+ *
+ * This test operates by performing the following operations:
+ *
+ * 1. Verify that the default state of GL_MULTISAMPLE is enabled.
+ *
+ * 2. Draw a test image into a multisampled buffer, with
+ *    GL_MULTISAMPLE disabled.
+ *
+ * 3. Blit this image to the left half of the piglit window (which is
+ *    not multisampled) to resolve it.
+ *
+ * 4. Draw the same test image into a single-sampled buffer.
+ *
+ * 5. Blit this image to the right half of the piglit window.
+ *
+ * 6. Verify that the two halves of the piglit window match.  If they
+ *    don't, then presumably the disabling of GL_MULTISAMPLE failed to
+ *    take effect.
+ */
+
+#include "common.h"
+
+int piglit_width = 512; int piglit_height = 256;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA;
+
+namespace {
+
+const int pattern_width = 256; const int pattern_height = 256;
+
+Fbo singlesampled_fbo;
+Fbo multisampled_fbo;
+Triangles triangles;
+
+extern "C" void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	GLint max_samples;
+	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
+
+	singlesampled_fbo.setup(FboConfig(0, pattern_width,
+					  pattern_height));
+	multisampled_fbo.setup(FboConfig(max_samples, pattern_width,
+					 pattern_height));
+	triangles.compile();
+}
+
+extern "C" enum piglit_result
+piglit_display()
+{
+	bool pass = true;
+
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+	glViewport(0, 0, piglit_width, piglit_height);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	/* Verify that the default state of GL_MULTISAMPLE is
+	 * enabled.
+	 */
+	pass = glIsEnabled(GL_MULTISAMPLE) && pass;
+
+	/* Draw a test image into a multisampled buffer, with
+	 * GL_MULTISAMPLE disabled.
+	 */
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisampled_fbo.handle);
+	multisampled_fbo.set_viewport();
+	glDisable(GL_MULTISAMPLE);
+	triangles.draw(TestPattern::no_projection);
+	glEnable(GL_MULTISAMPLE);
+
+	/* Blit this image to the left half of the piglit window
+	 * (which is not multisampled) to resolve it.
+	 */
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, multisampled_fbo.handle);
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
+			  0, 0, pattern_width, pattern_height,
+			  GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+	/* Draw the same test image into a single-sampled buffer. */
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, singlesampled_fbo.handle);
+	singlesampled_fbo.set_viewport();
+	triangles.draw(TestPattern::no_projection);
+
+	/* Blit this image to the right half of the piglit window. */
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, singlesampled_fbo.handle);
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
+			  pattern_width, 0, 2*pattern_width, pattern_height,
+			  GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+	/* Verify that the two halves of the piglit window match.  If
+	 * they don't, then presumably the disabling of GL_MULTISAMPLE
+	 * failed to take effect.
+	 */
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+	pass = piglit_probe_rect_halves_equal_rgba(0, 0, 2*pattern_width,
+						   pattern_height) && pass;
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+} /* Anonymous namespace */
-- 
1.7.7.6



More information about the Piglit mailing list