glsl-array-bounds: set out-of-bounds array index inside shader
[piglit.git] / tests / glx / glx-egl-switch-context.c
blob56a159f4f1dbbf301258ae0677586e769d604c1e
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 bool pass = true;
63 dpy = piglit_get_glx_display();
64 visinfo = piglit_get_glx_visual(dpy);
65 fbconfig = piglit_glx_get_fbconfig_for_visinfo(dpy, visinfo);
66 win = piglit_get_glx_window(dpy, visinfo);
67 glxWin = glXCreateWindow(dpy, fbconfig, win, NULL);
69 dpy_egl = eglGetDisplay(dpy);
70 if (!dpy_egl)
71 piglit_report_result(PIGLIT_SKIP);
72 if (!eglInitialize(dpy_egl, &major_version, &minor_version))
73 piglit_report_result(PIGLIT_SKIP);
75 ctx_glx = glXCreateContext(dpy, visinfo, NULL, True);
76 ctx_egl = eglCreateContext(dpy_egl, EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT, NULL);
78 glXMakeContextCurrent(dpy, glxWin, glxWin, ctx_glx);
79 eglMakeCurrent(dpy_egl, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx_egl);
80 glXMakeContextCurrent(dpy, None, None, NULL);
81 eglMakeCurrent(dpy_egl, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx_egl);
82 eglMakeCurrent(dpy_egl, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
84 glXDestroyContext(dpy, ctx_glx);
85 eglDestroyContext(dpy_egl, ctx_egl);
87 eglTerminate(dpy_egl);
89 XFree(visinfo);
91 piglit_report_result(PIGLIT_PASS);
93 return pass;