[Piglit] [PATCH] Add a test for EGL_NV_post_sub_buffer

Fredrik Höglund fredrik at kde.org
Sat Dec 10 10:18:02 PST 2011


Signed-off-by: Fredrik Höglund <fredrik at kde.org>
---
 tests/all_egl.tests                |    1 +
 tests/egl/CMakeLists.gl.txt        |    2 +
 tests/egl/egl-nv-post-sub-buffer.c |  102 ++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 0 deletions(-)
 create mode 100644 tests/egl/egl-nv-post-sub-buffer.c

diff --git a/tests/all_egl.tests b/tests/all_egl.tests
index 669d334..26cb667 100644
--- a/tests/all_egl.tests
+++ b/tests/all_egl.tests
@@ -14,6 +14,7 @@ profile.tests['egl'] = egl
 egl['egl-create-surface'] = plain_test('egl-create-surface')
 egl['egl-nok-swap-region'] = plain_test('egl-nok-swap-region')
 egl['egl-nok-texture-from-pixmap'] = plain_test('egl-nok-texture-from-pixmap')
+egl['egl-nv-post-sub-buffer'] = plain_test('egl-nv-post-sub-buffer')
 egl['egl-query-surface-EGL_BAD_ATTRIBUTE'] = plain_test('egl-query-surface --bad-attr')
 egl['egl-query-surface-EGL_BAD_SURFACE'] = plain_test('egl-query-surface --bad-surface')
 egl['egl-query-surface-EGL_HEIGHT'] = plain_test('egl-query-surface --attr=EGL_HEIGHT')
diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
index 1ab0dd5..f3adea5 100644
--- a/tests/egl/CMakeLists.gl.txt
+++ b/tests/egl/CMakeLists.gl.txt
@@ -23,6 +23,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 	target_link_libraries(egl-create-surface pthread X11)
 	add_executable (egl-query-surface egl-util.c egl-query-surface.c)
 	target_link_libraries(egl-query-surface pthread X11)
+	add_executable (egl-nv-post-sub-buffer egl-util.c egl-nv-post-sub-buffer.c)
+	target_link_libraries(egl-nv-post-sub-buffer pthread X11)
 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 
 # vim: ft=cmake:
diff --git a/tests/egl/egl-nv-post-sub-buffer.c b/tests/egl/egl-nv-post-sub-buffer.c
new file mode 100644
index 0000000..bfae077
--- /dev/null
+++ b/tests/egl/egl-nv-post-sub-buffer.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ * Copyright © 2011 Fredrik Höglund <fredrik at kde.org>
+ *
+ * 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.
+ *
+ * Authors:
+ *    Fredrik Höglund <fredrik at kde.org>
+ *
+ * Based on egl-nok-swap-region by:
+ *    Kristian Høgsberg <krh at bitplanet.net>
+ */
+
+/** @file egl-nv-post-sub-buffer.c
+ *
+ * Test EGL_NV_post_sub_buffer.
+ */
+
+#include "piglit-util.h"
+#include "egl-util.h"
+
+#ifdef EGL_NV_post_sub_buffer
+
+const char *extensions[] = { "EGL_NV_post_sub_buffer", NULL };
+
+static enum piglit_result
+draw(struct egl_state *state)
+{
+	EGLint rect[] = { 10, 10, 10, 10 };
+	PFNEGLPOSTSUBBUFFERNVPROC post_sub_buffer;
+	float red[] = { 1.0, 0.0, 0.0, 1.0};
+	int value;
+
+	post_sub_buffer = (PFNEGLPOSTSUBBUFFERNVPROC)
+		eglGetProcAddress("eglPostSubBufferNV");
+
+	if (post_sub_buffer == NULL) {
+		fprintf(stderr, "could not getproc eglPostSubBufferNV\n");
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	eglQuerySurface(state->egl_dpy, state->surf, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &value);
+	if (value == EGL_FALSE) {
+		fprintf(stderr, "eglPostSubBufferNV not supported by surface\n");
+		piglit_report_result(PIGLIT_PASS);
+	}
+
+	/* Clear background to green */
+	glClearColor(0.0, 1.0, 0.0, 1.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+	eglSwapBuffers(state->egl_dpy, state->surf);
+
+	glClearColor(1.0, 0.0, 0.0, 1.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+	post_sub_buffer(state->egl_dpy, state->surf, rect[0], rect[1], rect[2], rect[3]);
+
+	if (!piglit_probe_pixel_rgba(rect[0] + 5, state->height - rect[1] - 5, red))
+		return PIGLIT_FAIL;
+
+	return PIGLIT_PASS;
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct egl_test test;
+
+	egl_init_test(&test);
+	test.extensions = extensions;
+	test.draw = draw;
+
+	return egl_util_run(&test, argc, argv);
+}
+
+#else
+
+int
+main(int argc, char *argv[])
+{
+	piglit_report_result(PIGLIT_SKIP);
+
+	return 0;
+}
+
+#endif
-- 
1.7.7.3



More information about the Piglit mailing list