summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2015-06-10 13:52:59 +0200
committerMarek Olšák <marek.olsak@amd.com>2015-07-08 10:53:20 +0200
commit32830a3d94bfc3db32821b098e9ae444752ec267 (patch)
tree0f97d203c0e80f511e7c634883782ad59814402a
parentb7cccd18875b07027f8e96a780781584ea32d2b1 (diff)
egl-gl-colorspace: new test for the EGL extension
-rw-r--r--tests/all.py7
-rw-r--r--tests/egl/CMakeLists.gl.txt2
-rw-r--r--tests/egl/egl-gl-colorspace.c107
-rw-r--r--tests/egl/egl-util.c4
-rw-r--r--tests/egl/egl-util.h1
5 files changed, 120 insertions, 1 deletions
diff --git a/tests/all.py b/tests/all.py
index 110a5a4c4..8e45a83fe 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4195,6 +4195,13 @@ with profile.group_manager(
with profile.group_manager(
PiglitGLTest,
+ grouptools.join('spec', 'egl_khr_gl_colorspace'),
+ exclude_platforms=['glx']) as g:
+ g(['egl-gl-colorspace'], 'linear')
+ g(['egl-gl-colorspace', 'srgb'], 'srgb')
+
+with profile.group_manager(
+ PiglitGLTest,
grouptools.join('spec', 'egl_khr_wait_sync'),
exclude_platforms=['glx']) as g:
g(['egl_khr_fence_sync', 'wait_sync'], 'conformance')
diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
index fe055f0a0..34fee6efe 100644
--- a/tests/egl/CMakeLists.gl.txt
+++ b/tests/egl/CMakeLists.gl.txt
@@ -24,6 +24,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(egl-create-pbuffer-surface pthread ${X11_X11_LIB})
piglit_add_executable (egl-configless-context egl-configless-context.c)
target_link_libraries(egl-configless-context pthread ${X11_X11_LIB})
+ piglit_add_executable (egl-gl-colorspace egl-util.c egl-gl-colorspace.c)
+ target_link_libraries(egl-gl-colorspace pthread ${X11_X11_LIB})
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# vim: ft=cmake:
diff --git a/tests/egl/egl-gl-colorspace.c b/tests/egl/egl-gl-colorspace.c
new file mode 100644
index 000000000..b00233dd0
--- /dev/null
+++ b/tests/egl/egl-gl-colorspace.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2015 Advanced Micro Devices, Inc.
+ *
+ * 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-gl.h"
+#include "egl-util.h"
+
+static bool test_srgb;
+
+static enum piglit_result
+draw(struct egl_state *state)
+{
+ enum piglit_result result = PIGLIT_PASS;
+ float green[] = {0, 0.3, 0, 0};
+ float expected_green[4];
+ float expected_blend[4];
+
+ eglMakeCurrent(state->egl_dpy, state->surf, state->surf, state->ctx);
+
+ glViewport(0, 0, state->width, state->height);
+ piglit_ortho_projection(state->width, state->height, GL_FALSE);
+
+ glClearColor(0.5, 0.5, 0.5, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor4f(green[0], green[1], green[2], green[3]);
+
+ /* Draw first without blending. */
+ piglit_draw_rect(0, 0, 20, 20);
+
+ /* Draw second with blending. */
+ piglit_draw_rect(20, 0, 20, 20);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE);
+ piglit_draw_rect(20, 0, 20, 20);
+ glDisable(GL_BLEND);
+
+ /* Check first. */
+ memcpy(expected_green, green, sizeof(float) * 4);
+ if (test_srgb)
+ expected_green[1] = piglit_linear_to_srgb(green[1]);
+ if (!piglit_probe_rect_rgb(0, 0, 20, 20, expected_green))
+ result = PIGLIT_FAIL;
+
+ /* Check second. */
+ memcpy(expected_blend, green, sizeof(float) * 4);
+ if (test_srgb)
+ expected_blend[1] = piglit_linear_to_srgb(green[1] * 2.0);
+ else
+ expected_blend[1] *= 2;
+ if (!piglit_probe_rect_rgb(20, 0, 20, 20, expected_blend))
+ result = PIGLIT_FAIL;
+
+ eglSwapBuffers(state->egl_dpy, state->surf);
+ return result;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct egl_test test;
+ const char *extensions[] = {"EGL_KHR_gl_colorspace", NULL};
+ const EGLint surface_linear[] = {
+ EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_LINEAR,
+ EGL_NONE
+ };
+ const EGLint surface_srgb[] = {
+ EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
+ EGL_NONE
+ };
+ const EGLint test_attribs[] = {
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
+ EGL_NONE
+ };
+
+ piglit_strip_arg(&argc, argv, "-fbo");
+ test_srgb = piglit_strip_arg(&argc, argv, "srgb");
+
+ egl_init_test(&test);
+ test.draw = draw;
+ test.stop_on_failure = true;
+ test.config_attribs = test_attribs;
+ test.surface_attribs = test_srgb ? surface_srgb : surface_linear;
+ test.extensions = extensions;
+
+ return egl_util_run(&test, argc, argv) == PIGLIT_PASS ? EXIT_SUCCESS
+ : EXIT_FAILURE;
+}
diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
index 2e880f8aa..77d8d3fcd 100644
--- a/tests/egl/egl-util.c
+++ b/tests/egl/egl-util.c
@@ -75,6 +75,7 @@ egl_init_test(struct egl_test *test)
static const char *no_extensions[] = { NULL };
test->config_attribs = egl_default_attribs;
+ test->surface_attribs = NULL;
test->draw = NULL;
test->extensions = no_extensions;
test->window_width = egl_default_window_width;
@@ -283,7 +284,8 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
goto fail;
state.surf = eglCreateWindowSurface(state.egl_dpy,
- state.cfg, state.win, NULL);
+ state.cfg, state.win,
+ test->surface_attribs);
if (state.surf == EGL_NO_SURFACE) {
fprintf(stderr, "eglCreateWindowSurface() failed\n");
result = PIGLIT_FAIL;
diff --git a/tests/egl/egl-util.h b/tests/egl/egl-util.h
index 27d292640..249319db4 100644
--- a/tests/egl/egl-util.h
+++ b/tests/egl/egl-util.h
@@ -30,6 +30,7 @@ struct egl_state {
struct egl_test {
const EGLint *config_attribs;
+ const EGLint *surface_attribs;
const char **extensions;
enum piglit_result (*draw)(struct egl_state *state);
EGLint window_width;