arb_copy_image: test copying of different mipmap levels of a texture
[piglit.git] / tests / glx / glx-egl-switch-context.c
blob95bfa4c6a36bfc95bcb2c092f92d4c60c4b91ef8
1 /*
2 * Copyright © 2019 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
13 * Software.
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
21 * IN THE SOFTWARE.
23 /**
24 * \file glx-egl-switch-context.c
26 * Test aims to reproduce SIGSEGV on i965 appearing on certain
27 * sequences of switching glx and egl contexts. Particular sequence
28 * that leads to crash:
30 * 1. Make glx context current
31 * 2. Make egl context current
32 * 3. Drop glx context
33 * 4. Make egl context current
35 * In order to reproduce the crash you also need to export the loader:
36 * export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PATH_TO_MESA_BUILD/lib
38 * \author Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
41 #include "piglit-util-gl.h"
42 #include "piglit-util-egl.h"
43 #include "piglit-glx-util.h"
45 EGLint major_version, minor_version;
47 int piglit_width = 160,
48 piglit_height = 160;
50 int main(int argc, char **argv)
52 Display *dpy;
53 EGLDisplay dpy_egl;
54 XVisualInfo *visinfo;
55 GLXFBConfig fbconfig;
56 Window win;
57 GLXWindow glxWin;
58 GLXContext ctx_glx;
59 EGLContext ctx_egl;
61 for (int i = 1; i < argc; i++) {
62 if (!strcmp(argv[i], "-auto"))
63 piglit_automatic = 1;
64 else
65 fprintf(stderr, "Unknown option: %s\n", argv[i]);
68 bool pass = true;
70 dpy = piglit_get_glx_display();
71 visinfo = piglit_get_glx_visual(dpy);
72 fbconfig = piglit_glx_get_fbconfig_for_visinfo(dpy, visinfo);
73 win = piglit_get_glx_window(dpy, visinfo);
74 glxWin = glXCreateWindow(dpy, fbconfig, win, NULL);
76 dpy_egl = eglGetDisplay(dpy);
77 if (!dpy_egl)
78 piglit_report_result(PIGLIT_SKIP);
79 if (!eglInitialize(dpy_egl, &major_version, &minor_version))
80 piglit_report_result(PIGLIT_SKIP);
82 ctx_glx = glXCreateContext(dpy, visinfo, NULL, True);
83 ctx_egl = eglCreateContext(dpy_egl, EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT, NULL);
85 glXMakeContextCurrent(dpy, glxWin, glxWin, ctx_glx);
86 eglMakeCurrent(dpy_egl, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx_egl);
87 glXMakeContextCurrent(dpy, None, None, NULL);
88 eglMakeCurrent(dpy_egl, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx_egl);
89 eglMakeCurrent(dpy_egl, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
91 glXDestroyContext(dpy, ctx_glx);
92 eglDestroyContext(dpy_egl, ctx_egl);
94 eglTerminate(dpy_egl);
96 XFree(visinfo);
98 piglit_report_result(PIGLIT_PASS);
100 return pass;