Commit 5af7535e authored by Matt Turner's avatar Matt Turner

egl_khr_create_context: Add common test infrastructure

v2: - Require EGL_KHR_surfaceless_context instead of other surfaceless
      extensions.
    - Fix for-loop typo.
    - Make EGL_KHR_create_context_setup take a renderable_type_mask argument.
    - Make EGL_KHR_create_context_setup return whether it succeeded.
    - PIGLIT_SKIP if eglChooseConfig fails (in the case of requesting an
      ES 1.x context when 1.x isn't supported).
    - Add version_is_valid_for_context helper function.
parent 15223f78
......@@ -17,3 +17,6 @@ egl['egl-query-surface-EGL_BAD_ATTRIBUTE'] = plain_test('egl-query-surface --bad
egl['egl-query-surface-EGL_BAD_SURFACE'] = plain_test('egl-query-surface --bad-surface')
egl['egl-query-surface-EGL_HEIGHT'] = plain_test('egl-query-surface --attr=EGL_HEIGHT')
egl['egl-query-surface-EGL_WIDTH'] = plain_test('egl-query-surface --attr=EGL_WIDTH')
create_context = Group();
egl['EGL_KHR_create_context'] = create_context
......@@ -20,6 +20,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(egl-create-surface pthread ${X11_X11_LIB})
piglit_add_executable (egl-query-surface egl-util.c egl-query-surface.c)
target_link_libraries(egl-query-surface pthread ${X11_X11_LIB})
add_subdirectory(spec)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# vim: ft=cmake:
add_subdirectory (egl_khr_create_context)
include_directories(
${GLEXT_INCLUDE_DIR}
${OPENGL_INCLUDE_PATH}
${GLPROTO_INCLUDE_DIRS}
)
link_libraries (
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${X11_X11_LIB}
)
# vim: ft=cmake:
/* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <ctype.h>
#include <errno.h>
#include "common.h"
static Display *dpy = NULL;
EGLDisplay egl_dpy;
EGLConfig cfg;
EGLContext ctx;
bool
parse_version_string(const char *string, int *major, int *minor)
{
char *next;
int ma;
int mi;
if (string == NULL)
return false;
next = (char *)string;
while (!isdigit(*next) && *next != '\0')
next++;
if (next[0] == '\0')
return false;
errno = 0;
ma = strtol(next, &next, 10);
if (next == NULL || errno != 0)
return false;
while (!isdigit(*next) && *next != '\0')
next++;
if (next[0] == '\0')
return false;
mi = strtol(next, &next, 10);
if (errno != 0)
return false;
*major = ma;
*minor = mi;
return true;
}
static void
check_extensions(void)
{
static const char *extensions[] = {
"EGL_KHR_create_context",
"EGL_KHR_surfaceless_context"
};
int i;
const char *extension_string = eglQueryString(egl_dpy, EGL_EXTENSIONS);
for (i = 0; i < ARRAY_SIZE(extensions); i++) {
if (!strstr(extension_string, extensions[i])) {
fprintf(stderr, "missing extension %s\n",
extensions[i]);
piglit_report_result(PIGLIT_SKIP);
}
}
}
bool
EGL_KHR_create_context_setup(EGLint renderable_type_mask)
{
EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_DEPTH_SIZE, 1,
EGL_RENDERABLE_TYPE, renderable_type_mask,
EGL_NONE
};
EGLint count;
EGLint major, minor;
dpy = XOpenDisplay(NULL);
if (dpy == NULL) {
fprintf(stderr, "couldn't open display\n");
piglit_report_result(PIGLIT_FAIL);
}
egl_dpy = eglGetDisplay(dpy);
if (egl_dpy == EGL_NO_DISPLAY) {
fprintf(stderr, "eglGetDisplay() failed\n");
piglit_report_result(PIGLIT_FAIL);
}
if (!eglInitialize(egl_dpy, &major, &minor)) {
fprintf(stderr, "eglInitialize() failed\n");
piglit_report_result(PIGLIT_FAIL);
}
if (!eglChooseConfig(egl_dpy, config_attribs, &cfg, 1, &count) ||
count == 0) {
fprintf(stderr, "eglChooseConfig() failed\n");
return false;
}
check_extensions();
return true;
}
void
EGL_KHR_create_context_teardown(void)
{
eglTerminate(egl_dpy);
}
/* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "piglit-util-gl-common.h"
#include <X11/Xlib.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
extern EGLDisplay egl_dpy;
extern EGLConfig cfg;
extern EGLContext ctx;
extern bool parse_version_string(const char *string, int *major, int *minor);
extern bool EGL_KHR_create_context_setup(EGLint renderable_type_mask);
extern void EGL_KHR_create_context_teardown(void);
static inline bool
version_is_valid_for_context(int ctx_major, int major, int minor)
{
if (ctx_major == 1) {
if (major == 1 && (minor == 0 || minor == 1)) {
return true;
}
} else if (ctx_major == 2) {
/* GLES 3.0 is backward compatible with 2.0 and is the only version
* currently available that is compatible with 2.0.
*/
if ((major == 2 || major == 3) && minor == 0) {
return true;
}
}
return false;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment