glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / egl / egl-create-largest-pbuffer-surface.c
blob1bc5c2b529cc60071b6cc65f79d022ab36692b68
1 /*
2 * Copyright © 2016 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.
25 /** @file egl-create-largest-pbuffer-surface.c
27 * Test EGLCreatePBufferSurface behaviour with EGL_LARGEST_PBUFFER attribute.
29 * From EGL 1.5 spec:
31 * "Use EGL_LARGEST_PBUFFER to get the largest available pbuffer when the
32 * allocation of the pbuffer would otherwise fail."
35 #include <limits.h>
36 #include "piglit-util-gl.h"
37 #include "egl-util.h"
39 static enum piglit_result
40 draw(struct egl_state *state)
42 EGLSurface surf;
43 const float purple[] = {1.0, 0.0, 1.0, 1.0};
45 static const EGLint srfPbufferAttr[] =
47 EGL_WIDTH, INT_MAX,
48 EGL_HEIGHT, INT_MAX,
49 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
50 EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
51 EGL_LARGEST_PBUFFER, EGL_TRUE,
52 EGL_NONE
55 surf = eglCreatePbufferSurface(state->egl_dpy, state->cfg,
56 srfPbufferAttr);
58 if (eglGetError() != EGL_SUCCESS || surf == EGL_NO_SURFACE) {
59 fprintf(stderr, "eglCreatePbufferSurface failed\n");
60 piglit_report_result(PIGLIT_FAIL);
63 glEnable(GL_TEXTURE_2D);
65 eglMakeCurrent(state->egl_dpy, state->surf, state->surf, state->ctx);
66 glClearColor(1.0, 1.0, 1.0, 0.0);
67 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
69 eglBindTexImage(state->egl_dpy, surf, EGL_BACK_BUFFER);
70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
73 glViewport(0, 0, state->width, state->height);
74 piglit_ortho_projection(state->width, state->height, GL_FALSE);
76 eglMakeCurrent(state->egl_dpy, surf, surf, state->ctx);
77 glClearColor(purple[0], purple[1], purple[2], purple[3]);
78 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
80 eglMakeCurrent(state->egl_dpy, state->surf, state->surf, state->ctx);
81 piglit_draw_rect_tex(0, 0, state->width, state->height, 0, 0, 1, 1);
83 if (!piglit_probe_rect_rgba(0, 0, state->width, state->height, purple))
84 piglit_report_result(PIGLIT_FAIL);
86 piglit_report_result(PIGLIT_PASS);
89 int
90 main(int argc, char *argv[])
92 struct egl_test test;
93 static const EGLint test_attribs[] =
95 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, EGL_NONE
98 egl_init_test(&test);
99 test.draw = draw;
100 test.stop_on_failure = true;
101 test.config_attribs = test_attribs;
103 if (egl_util_run(&test, argc, argv) != PIGLIT_PASS)
104 return EXIT_FAILURE;
105 return EXIT_SUCCESS;