From 63559cbc54832f5f73db289474a5bb5d4af4d6f4 Mon Sep 17 00:00:00 2001 From: Stanislav Vorobiov Date: Tue, 22 Oct 2013 14:14:05 +0400 Subject: YaGL: GLESv3 supported in EGL Change-Id: Ife98eb6614f8371bd79f93e57db5fade0dabd0fe --- EGL/yagl_egl_calls.c | 28 +++++++++++++++++++--------- EGL/yagl_egl_state.c | 13 +++++++++++++ EGL/yagl_egl_state.h | 2 ++ EGL/yagl_state.c | 20 ++++++++++++++++++++ 4 files changed, 54 insertions(+), 9 deletions(-) (limited to 'EGL') diff --git a/EGL/yagl_egl_calls.c b/EGL/yagl_egl_calls.c index 88b29a5..cc6e3e2 100644 --- a/EGL/yagl_egl_calls.c +++ b/EGL/yagl_egl_calls.c @@ -3,6 +3,7 @@ #include "yagl_display.h" #include "yagl_log.h" #include "yagl_egl_state.h" +#include "yagl_state.h" #include "yagl_malloc.h" #include "yagl_surface.h" #include "yagl_context.h" @@ -49,6 +50,8 @@ static int yagl_get_client_api(const EGLint *attrib_list, yagl_client_api *clien *client_api = yagl_client_api_gles1; } else if (attrib_list[i + 1] == 2) { *client_api = yagl_client_api_gles2; + } else if (attrib_list[i + 1] == 3) { + *client_api = yagl_client_api_gles3; } else { return 0; } @@ -879,10 +882,7 @@ YAGL_API EGLBoolean eglBindTexImage(EGLDisplay dpy_, surface_, buffer); - iface = yagl_get_client_interface(yagl_client_api_gles2); - if (!iface) { - iface = yagl_get_client_interface(yagl_client_api_gles1); - } + iface = yagl_get_any_client_interface(); if (!iface) { YAGL_SET_ERR(EGL_BAD_ALLOC); @@ -1060,6 +1060,12 @@ YAGL_API EGLContext eglCreateContext(EGLDisplay dpy_, goto out; } + if ((client_api == yagl_client_api_gles3) && + (yagl_get_host_gl_version() <= yagl_gl_2)) { + YAGL_SET_ERR(EGL_BAD_ATTRIBUTE); + goto out; + } + iface = yagl_get_client_interface(client_api); if (!iface) { @@ -1080,7 +1086,7 @@ YAGL_API EGLContext eglCreateContext(EGLDisplay dpy_, goto out; } - client_ctx = iface->create_ctx(iface, sg); + client_ctx = iface->create_ctx(iface, client_api, sg); ctx = yagl_context_create(host_context, dpy, client_ctx); assert(ctx); @@ -1355,6 +1361,7 @@ YAGL_API EGLBoolean eglQueryContext(EGLDisplay dpy_, switch (ctx->client_ctx->client_api) { case yagl_client_api_gles1: case yagl_client_api_gles2: + case yagl_client_api_gles3: if (value) { *value = EGL_OPENGL_ES_API; } @@ -1388,6 +1395,11 @@ YAGL_API EGLBoolean eglQueryContext(EGLDisplay dpy_, *value = 2; } break; + case yagl_client_api_gles3: + if (value) { + *value = 3; + } + break; case yagl_client_api_ogl: case yagl_client_api_ovg: default: @@ -1567,10 +1579,7 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, target, buffer); - iface = yagl_get_client_interface(yagl_client_api_gles2); - if (!iface) { - iface = yagl_get_client_interface(yagl_client_api_gles1); - } + iface = yagl_get_any_client_interface(); if (!iface) { YAGL_SET_ERR(EGL_BAD_ALLOC); @@ -1936,6 +1945,7 @@ YAGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* ret = yagl_get_gles1_sym(procname); break; case yagl_client_api_gles2: + case yagl_client_api_gles3: ret = yagl_get_gles2_sym(procname); break; default: diff --git a/EGL/yagl_egl_state.c b/EGL/yagl_egl_state.c index f57cb7a..da76e49 100644 --- a/EGL/yagl_egl_state.c +++ b/EGL/yagl_egl_state.c @@ -291,6 +291,7 @@ struct yagl_client_interface *yagl_get_client_interface(yagl_client_api client_a } return state->gles1_iface; case yagl_client_api_gles2: + case yagl_client_api_gles3: if (!state->gles2_iface) { state->gles2_iface = yagl_get_gles1_sym("yagl_gles2_interface"); } @@ -299,3 +300,15 @@ struct yagl_client_interface *yagl_get_client_interface(yagl_client_api client_a return NULL; } } + +struct yagl_client_interface *yagl_get_any_client_interface() +{ + struct yagl_client_interface *iface; + + iface = yagl_get_client_interface(yagl_client_api_gles2); + if (!iface) { + iface = yagl_get_client_interface(yagl_client_api_gles1); + } + + return iface; +} diff --git a/EGL/yagl_egl_state.h b/EGL/yagl_egl_state.h index 9e541e1..be7f22d 100644 --- a/EGL/yagl_egl_state.h +++ b/EGL/yagl_egl_state.h @@ -36,6 +36,8 @@ void yagl_reset_state(); struct yagl_client_interface *yagl_get_client_interface(yagl_client_api client_api); +struct yagl_client_interface *yagl_get_any_client_interface(); + /* * @} */ diff --git a/EGL/yagl_state.c b/EGL/yagl_state.c index a09f612..558f1b9 100644 --- a/EGL/yagl_state.c +++ b/EGL/yagl_state.c @@ -42,6 +42,8 @@ struct yagl_state struct yagl_backend *backend; + yagl_gl_version gl_version; + uint8_t *tmp_buff; uint32_t tmp_buff_size; }; @@ -235,6 +237,17 @@ static struct yagl_state *yagl_get_state() exit(1); } + switch (user_info.gl_version) { + case yagl_gl_2: + case yagl_gl_3: + case yagl_gl_3_es3: + break; + default: + fprintf(stderr, "Critical error! Bad host OpenGL version reported by kernel: %d!\n", + user_info.gl_version); + exit(1); + } + state->regs = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ|PROT_WRITE, @@ -283,6 +296,8 @@ static struct yagl_state *yagl_get_state() break; } + state->gl_version = user_info.gl_version; + pthread_setspecific(g_state_key, state); pthread_atfork(NULL, NULL, &yagl_state_atfork); @@ -336,6 +351,11 @@ yagl_object_name yagl_get_global_name() return ret; } +yagl_gl_version yagl_get_host_gl_version() +{ + return yagl_get_state()->gl_version; +} + struct yagl_backend *yagl_get_backend() { return yagl_get_state()->backend; -- cgit v1.2.3