arb_program_interface_query: set vs_input2[1][0] as valid name
[piglit.git] / tests / egl / spec / egl-1.4 / egl-terminate-then-unbind-context.c
bloba7e3f89d98325540134e90622c7e33825d1980c8
1 /* Copyright © 2013 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 /**
24 * \file
26 * This test makes current a context, terminates the context's display, then
27 * unbinds the context. According to the EGL 1.4 spec (2011.04.06), Section
28 * 3.2 Initialization, no error should occur.
30 * EGLBoolean eglTerminate(EGLDisplay dpy);
32 * Termination marks all EGL-specific resources, such as contexts and
33 * surfaces, associated with the specified display for deletion. Handles
34 * to all such resources are invalid as soon as eglTerminate returns, but
35 * the dpy handle itself remains valid. [...] Applications should not try
36 * to perform useful work with such resources following eglTerminate; only
37 * eglMakeCurrent or eglReleaseThread should be called, to complete
38 * deletion of these resources.
40 * If contexts or surfaces created with respect to dpy are current (see
41 * section 3.7.3) to any thread, then they are not actually destroyed
42 * while they remain current. Such contexts and surfaces will be destroyed
43 * as soon as eglReleaseThread is called from the thread they are bound
44 * to, or eglMakeCurrent is called from that thread with the current
45 * rendering API (see section 3.7) set such that the current context is
46 * affected. [...]
49 #include <stdbool.h>
50 #include <stdio.h>
52 #include "piglit-util-egl.h"
54 #define fail(msg) \
55 do { \
56 fprintf(stderr, "error: %s:%d: %s failed\n", __func__, __LINE__, msg); \
57 piglit_report_result(PIGLIT_FAIL); \
58 } while (0)
60 int
61 main(int argc, char **argv)
63 EGLDisplay dpy;
64 EGLint major_version;
65 EGLint minor_version;
66 EGLConfig config;
67 EGLint num_configs = 0;
68 EGLContext ctx;
69 bool ok;
71 dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY );
72 if (!dpy)
73 fail("eglGetDisplay(EGL_DEFAULT_DISPLAY) failed");
75 ok = eglInitialize(dpy, &major_version, &minor_version);
76 if (!ok)
77 fail("eglInitialize() failed");
79 /* This test tries to be window-system independent, and so avoids
80 * creating any EGLSurface. To call eglMakeCurrent() without a surface
81 * requires EGL_KHR_surfaceless_context.
83 piglit_require_egl_extension(dpy, "EGL_KHR_surfaceless_context");
85 ok = eglChooseConfig(dpy, NULL, &config, 1, &num_configs);
86 if (!ok)
87 fail("eglChooseConfig() failed");
88 if (num_configs == 0)
89 fail("eglChooseConfig() returned no configs\n");
91 ctx = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL );
92 if (!ctx)
93 fail("eglCreateContext() failed");
95 ok = eglMakeCurrent(dpy, NULL, NULL, ctx);
96 if (!ok)
97 fail("eglMakeCurrent()");
99 ok = eglTerminate(dpy);
100 if (!ok)
101 fail("eglTerminate()");
103 /* Unbind the context. */
104 ok = eglMakeCurrent(dpy, NULL, NULL, NULL);
105 if (!ok)
106 fail("eglMakeCurrent(ctx=NULL)");
108 piglit_report_result(PIGLIT_PASS);
109 return 0;