2 * Copyright © 2017 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "piglit-util.h"
25 #include "piglit-util-egl.h"
26 #include "piglit-util-gl.h"
30 * For legacy reasons, eglGetDisplay uses a detection heuristics to establish
31 * the underlying platform.
33 * Yet there is another API eglCopyBuffers that invokes the detection, a seeming
34 * remainder from the days perior to the EGL platform extensions.
36 * With the EGL extensions, the platform specified by the user may differ from
37 * the detected one. which will result in eglCopyBuffers failure.
39 * The check should be dropped.
45 /* Set the env. variable to force the platform 'detection' to use
46 * a platform different than X11.
48 * NOTE: This is not perfect, since driver may ignore the variable, yet
49 * we aim to provide a consistent experience across test runs, build
50 * permutation and/or driver used.
52 setenv("EGL_PLATFORM", "drm", true);
54 /* XXX: test should flag regardless of the following call - testing
57 * NOTE: We cannot do the test twice - with and W/o the call; the
58 * detection result is stored in static variable :-\
60 piglit_egl_get_default_display(EGL_NONE
);
62 /* Use X11 since it's the only platform that has EGL pixmap surfaces */
63 piglit_require_egl_extension(EGL_NO_DISPLAY
, "EGL_EXT_platform_x11");
66 static enum piglit_result
67 draw(struct egl_state
*state
)
69 EGLNativePixmapType pixmap
;
70 enum piglit_result result
= PIGLIT_PASS
;
72 /* Green for a pass */
73 glClearColor(0.0, 1.0, 0.0, 1.0);
74 glClear(GL_COLOR_BUFFER_BIT
);
76 pixmap
= egl_util_create_native_pixmap(state
, egl_default_window_width
,
77 egl_default_window_height
);
78 eglCopyBuffers(state
->egl_dpy
, state
->surf
, pixmap
);
79 if (!piglit_check_egl_error(EGL_SUCCESS
)) {
80 fprintf(stderr
, "eglCopyBuffers() failed\n");
83 glClearColor(1.0, 0.0, 0.0, 1.0);
84 glClear(GL_COLOR_BUFFER_BIT
);
88 eglSwapBuffers(state
->egl_dpy
, state
->surf
);
93 main(int argc
, char *argv
[])
95 static const EGLint test_attribs
[] = {
96 EGL_RENDERABLE_TYPE
, EGL_OPENGL_ES2_BIT
,
101 egl_init_test(&test
);
103 test
.config_attribs
= test_attribs
;
107 if (egl_util_run(&test
, argc
, argv
) != PIGLIT_PASS
)