[Piglit] [PATCH 3/5] Test that fast color clears work properly after a blit.
Paul Berry
stereotype441 at gmail.com
Wed May 22 10:20:25 PDT 2013
---
tests/all.tests | 1 +
tests/fast_color_clear/CMakeLists.gl.txt | 1 +
tests/fast_color_clear/blit-between-clears.c | 117 +++++++++++++++++++++++++++
3 files changed, 119 insertions(+)
create mode 100644 tests/fast_color_clear/blit-between-clears.c
diff --git a/tests/all.tests b/tests/all.tests
index fed16d7..d9a1d10 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2336,6 +2336,7 @@ for subtest in ('sample', 'read_pixels', 'blit', 'copy'):
test_name = ' '.join(
['fcc-read-after-clear', subtest, buffer_type])
add_concurrent_test(fast_color_clear, test_name)
+add_concurrent_test(fast_color_clear, 'fcc-blit-between-clears')
asmparsertest = Group()
def add_asmparsertest(group, shader):
diff --git a/tests/fast_color_clear/CMakeLists.gl.txt b/tests/fast_color_clear/CMakeLists.gl.txt
index 087cefa..4035569 100644
--- a/tests/fast_color_clear/CMakeLists.gl.txt
+++ b/tests/fast_color_clear/CMakeLists.gl.txt
@@ -11,5 +11,6 @@ link_libraries (
)
piglit_add_executable (fcc-read-after-clear read-after-clear.c)
+piglit_add_executable (fcc-blit-between-clears blit-between-clears.c)
# vim: ft=cmake:
diff --git a/tests/fast_color_clear/blit-between-clears.c b/tests/fast_color_clear/blit-between-clears.c
new file mode 100644
index 0000000..c730d5e
--- /dev/null
+++ b/tests/fast_color_clear/blit-between-clears.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2013 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 blit-between-clears.c
+ *
+ * Some implementations (i965/gen7+ in particular) contain logic to
+ * avoid performing a redundant fast color clear on a buffer that is
+ * already in the cleared state. This test verifies that blitting to
+ * a buffer takes it out of the cleared state, so a subsequent fast
+ * color clear will take effect.
+ */
+
+#include "piglit-util-gl-common.h"
+
+#define RB_WIDTH 512
+#define RB_HEIGHT 512
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+ config.supports_gl_compat_version = 11;
+ config.window_width = RB_WIDTH;
+ config.window_height = RB_HEIGHT;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static GLuint fb;
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint rb;
+ GLenum fb_status;
+
+ /* Requirements */
+ piglit_require_gl_version(11);
+ piglit_require_extension("GL_ARB_framebuffer_object");
+
+ /* Set up framebuffer */
+ glGenFramebuffers(1, &fb);
+ glBindFramebuffer(GL_FRAMEBUFFER, fb);
+ glGenRenderbuffers(1, &rb);
+ glBindRenderbuffer(GL_RENDERBUFFER, rb);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA,
+ RB_WIDTH, RB_HEIGHT);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER, rb);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+ fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ if (fb_status != GL_FRAMEBUFFER_COMPLETE) {
+ printf("Framebuffer status: %s\n",
+ piglit_get_gl_enum_name(fb_status));
+ piglit_report_result(PIGLIT_FAIL);
+ }
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ static const GLfloat green[] = { 0.0, 1.0, 0.0, 1.0 };
+
+ /* Fast clear the auxiliary framebuffer to red. */
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
+ glClearColor(1, 0, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Fast clear the window system framebuffer to green. */
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
+ glClearColor(0, 1, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Blit the auxiliary framebuffer to the window system
+ * framebuffer, turning it red.
+ */
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
+ glBlitFramebuffer(0, 0, RB_WIDTH, RB_HEIGHT,
+ 0, 0, piglit_width, piglit_height,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+ /* Fast clear the window system framebuffer back to green. */
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Verify that the second clear actually took effect. */
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo);
+ pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+ green) && pass;
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ pass = false;
+
+ piglit_present_results();
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
--
1.8.2.3
More information about the Piglit
mailing list