arb_program_interface_query: set vs_input2[1][0] as valid name
[piglit.git] / tests / egl / spec / egl_khr_surfaceless_context / viewport.c
blobcbb5e311f83c8bf46da3a55a44a8451f135b5ab0
1 /* Copyright © 2012, 2015 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 viewport.c
25 * @brief Test calling glViewport with no surface bound via
26 * EGL_KHR_surfaceless_context.
28 * Creates an EGL context and binds it without a surface via
29 * EGL_KHR_surfaceless_context and then calls glViewport. This exposes
30 * a crash in the i965 driver which tries to perform some actions on
31 * the non-existent surface whenever the viewport changes.
34 #include "piglit-util-gl.h"
35 #include "piglit-util-egl.h"
36 #include <EGL/egl.h>
37 #include <EGL/eglext.h>
39 static EGLDisplay egl_dpy;
40 static EGLConfig cfg;
41 static EGLContext ctx;
43 static void
44 choose_config(void)
46 EGLint config_attribs[] = {
47 EGL_NONE
49 EGLint count;
50 EGLint major, minor;
52 egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
54 if (!eglInitialize(egl_dpy, &major, &minor)) {
55 fprintf(stderr, "eglInitialize() failed\n");
56 piglit_report_result(PIGLIT_FAIL);
59 if (!eglChooseConfig(egl_dpy, config_attribs, &cfg, 1, &count) ||
60 count == 0) {
61 fprintf(stderr, "eglChooseConfig() failed\n");
62 piglit_report_result(PIGLIT_FAIL);
66 static void
67 create_context(void)
69 if (!piglit_egl_bind_api(EGL_OPENGL_API))
70 piglit_report_result(PIGLIT_SKIP);
72 ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT,
73 NULL /* attrib_list */);
74 if (!ctx) {
75 piglit_report_result(piglit_check_egl_error(EGL_BAD_MATCH) ?
76 PIGLIT_SKIP :
77 PIGLIT_FAIL);
81 int
82 main(int argc, char **argv)
84 static const GLint expected_viewport[] = { 0, 0, 42, 42 };
85 GLint actual_viewport[4];
86 int i;
88 choose_config();
89 piglit_require_egl_extension(egl_dpy, "EGL_KHR_surfaceless_context");
90 create_context();
92 /* Bind the context with no surface */
93 if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
94 fprintf(stderr, "eglMakeCurrent() failed\n");
95 piglit_report_result(PIGLIT_FAIL);
98 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
100 /* Try changing the viewport */
101 glViewport(expected_viewport[0],
102 expected_viewport[1],
103 expected_viewport[2],
104 expected_viewport[3]);
106 /* Check that it worked */
107 glGetIntegerv(GL_VIEWPORT, actual_viewport);
108 for (i = 0; i < 4; i++) {
109 if (expected_viewport[i] != actual_viewport[i]) {
110 fprintf(stderr,
111 "Viewport does not match\n"
112 " expected: %i %i %i %i\n"
113 " actual: %i %i %i %i\n",
114 expected_viewport[0],
115 expected_viewport[1],
116 expected_viewport[2],
117 expected_viewport[3],
118 actual_viewport[0],
119 actual_viewport[1],
120 actual_viewport[2],
121 actual_viewport[3]);
122 piglit_report_result(PIGLIT_FAIL);
126 piglit_report_result(PIGLIT_PASS);