diff options
author | Vasiliy Ulyanov <v.ulyanov@samsung.com> | 2015-05-18 15:53:58 +0300 |
---|---|---|
committer | jinhyung.jo <jinhyung.jo@samsung.com> | 2015-05-26 18:48:12 +0900 |
commit | 8931c19c44843144405514d5f725c6348fa24355 (patch) | |
tree | c784b7ff1eb1b183fa9c655ec07f6bd3b9d8d3da | |
parent | 36c035445b499ecb9144a4fcf903c1e8490a40d0 (diff) | |
download | emulator-yagl-8931c19c44843144405514d5f725c6348fa24355.tar.gz emulator-yagl-8931c19c44843144405514d5f725c6348fa24355.tar.bz2 emulator-yagl-8931c19c44843144405514d5f725c6348fa24355.zip |
YaGL: Add EGL_KHR_gl_texture_2D_image support
eglCreateImageKHR(...) now supports EGL_GL_TEXTURE_2D_KHR
target (onscreen backend only)
Change-Id: Ie41c494246237ce79e36fde63b49bb7cf876737b
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
-rw-r--r-- | EGL/CMakeLists.txt | 1 | ||||
-rw-r--r-- | EGL/yagl_backend.h | 6 | ||||
-rw-r--r-- | EGL/yagl_display.c | 6 | ||||
-rw-r--r-- | EGL/yagl_egl_calls.c | 37 | ||||
-rw-r--r-- | EGL/yagl_offscreen.c | 10 | ||||
-rw-r--r-- | EGL/yagl_onscreen.c | 14 | ||||
-rw-r--r-- | EGL/yagl_onscreen_image_gl_texture_2d.c | 101 | ||||
-rw-r--r-- | EGL/yagl_onscreen_image_gl_texture_2d.h | 56 | ||||
-rw-r--r-- | GLES_common/yagl_gles_image.c | 42 | ||||
-rw-r--r-- | GLES_common/yagl_gles_image.h | 8 | ||||
-rw-r--r-- | GLESv1_CM/yagl_gles1_interface.c | 10 | ||||
-rw-r--r-- | GLESv2/yagl_gles2_interface.c | 10 | ||||
-rw-r--r-- | include/yagl_client_interface.h | 7 |
13 files changed, 305 insertions, 3 deletions
diff --git a/EGL/CMakeLists.txt b/EGL/CMakeLists.txt index fc78e43..58b295a 100644 --- a/EGL/CMakeLists.txt +++ b/EGL/CMakeLists.txt @@ -21,6 +21,7 @@ set(SOURCES yagl_offscreen_surface.c yagl_onscreen.c yagl_onscreen_image_pixmap.c + yagl_onscreen_image_gl_texture_2d.c yagl_onscreen_surface.c yagl_onscreen_fence.c yagl_onscreen_utils.c diff --git a/EGL/yagl_backend.h b/EGL/yagl_backend.h index 3804820..d939ba6 100644 --- a/EGL/yagl_backend.h +++ b/EGL/yagl_backend.h @@ -47,6 +47,7 @@ struct yagl_native_platform; struct yagl_native_drawable; struct yagl_client_interface; struct wl_resource; +struct yagl_context; struct yagl_backend { @@ -84,6 +85,11 @@ struct yagl_backend struct wl_resource */*buffer*/, struct yagl_client_interface */*iface*/); + struct yagl_image *(*create_image_gl_texture_2d)(struct yagl_display */*dpy*/, + struct yagl_context */*ctx*/, + yagl_object_name /*texture*/, + struct yagl_client_interface */*iface*/); + struct yagl_fence *(*create_fence)(struct yagl_display */*dpy*/); void (*destroy)(struct yagl_backend */*backend*/); diff --git a/EGL/yagl_display.c b/EGL/yagl_display.c index 775d1d6..d18281c 100644 --- a/EGL/yagl_display.c +++ b/EGL/yagl_display.c @@ -57,6 +57,8 @@ #define YAGL_EGL_WL_BIND_WAYLAND_DISPLAY_EXTENSIONS "EGL_WL_bind_wayland_display " +#define YAGL_EGL_GL_TEXTURE_EXTENSIONS "EGL_KHR_gl_texture_2D_image " + #define YAGL_EGL_BUFFER_AGE_EXTENSIONS "EGL_EXT_buffer_age " #define YAGL_EGL_FENCE_EXTENSIONS "EGL_KHR_fence_sync " @@ -306,6 +308,8 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy) len += strlen(YAGL_EGL_FENCE_EXTENSIONS); } + len += strlen(YAGL_EGL_GL_TEXTURE_EXTENSIONS); + dpy->extensions = yagl_malloc(len + 1); strcpy(dpy->extensions, YAGL_EGL_BASE_EXTENSIONS); @@ -325,6 +329,8 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy) if (yagl_egl_fence_supported()) { strcat(dpy->extensions, YAGL_EGL_FENCE_EXTENSIONS); } + + strcat(dpy->extensions, YAGL_EGL_GL_TEXTURE_EXTENSIONS); } pthread_mutex_unlock(&dpy->mutex); diff --git a/EGL/yagl_egl_calls.c b/EGL/yagl_egl_calls.c index 9216560..59aa871 100644 --- a/EGL/yagl_egl_calls.c +++ b/EGL/yagl_egl_calls.c @@ -1631,7 +1631,7 @@ out: } YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, - EGLContext ctx, + EGLContext ctx_, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) @@ -1639,6 +1639,7 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, EGLImageKHR ret = EGL_NO_IMAGE_KHR; struct yagl_client_interface *iface = NULL; struct yagl_display *dpy = NULL; + struct yagl_context *ctx = NULL; struct yagl_native_drawable *native_buffer = NULL; struct yagl_image *image = NULL; int i = 0; @@ -1646,7 +1647,7 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, YAGL_LOG_FUNC_ENTER(eglCreateImageKHR, "dpy = %u, ctx = %u, target = %u, buffer = %p", (yagl_host_handle)dpy_, - (yagl_host_handle)ctx, + (yagl_host_handle)ctx_, target, buffer); @@ -1734,6 +1735,36 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, } break; + case EGL_GL_TEXTURE_2D_KHR: + if (attrib_list) { + while (attrib_list[i] != EGL_NONE) { + switch (attrib_list[i]) { + case EGL_IMAGE_PRESERVED_KHR: + case EGL_GL_TEXTURE_LEVEL_KHR: + break; + default: + YAGL_SET_ERR(EGL_BAD_ATTRIBUTE); + goto out; + } + + i += 2; + } + } + + if (!yagl_validate_context(dpy, ctx_, &ctx)) { + goto out; + } + + image = yagl_get_backend()->create_image_gl_texture_2d(dpy, + ctx, + (yagl_object_name)buffer, + iface); + + if (!image) { + goto out; + } + + break; default: YAGL_SET_ERR(EGL_BAD_PARAMETER); goto out; @@ -1749,6 +1780,8 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, out: yagl_image_release(image); + yagl_context_release(ctx); + YAGL_LOG_FUNC_EXIT("%p", ret); return ret; diff --git a/EGL/yagl_offscreen.c b/EGL/yagl_offscreen.c index 4bb21fa..e8c3781 100644 --- a/EGL/yagl_offscreen.c +++ b/EGL/yagl_offscreen.c @@ -134,6 +134,15 @@ static struct yagl_image return NULL; } +static struct yagl_image + *yagl_offscreen_create_image_gl_texture_2d(struct yagl_display *dpy, + struct yagl_context *ctx, + yagl_object_name texture, + struct yagl_client_interface *iface) +{ + return NULL; +} + static struct yagl_fence *yagl_offscreen_create_fence(struct yagl_display *dpy) { @@ -157,6 +166,7 @@ struct yagl_backend *yagl_offscreen_create() backend->create_pbuffer_surface = &yagl_offscreen_create_pbuffer_surface; backend->create_image_pixmap = &yagl_offscreen_create_image_pixmap; backend->create_image_wl_buffer = &yagl_offscreen_create_image_wl_buffer; + backend->create_image_gl_texture_2d = &yagl_offscreen_create_image_gl_texture_2d; backend->create_fence = &yagl_offscreen_create_fence; backend->destroy = &yagl_offscreen_destroy; backend->y_inverted = 1; diff --git a/EGL/yagl_onscreen.c b/EGL/yagl_onscreen.c index 8fd1f38..4af1863 100644 --- a/EGL/yagl_onscreen.c +++ b/EGL/yagl_onscreen.c @@ -37,6 +37,7 @@ #ifdef YAGL_PLATFORM_WAYLAND #include "yagl_onscreen_image_wl_buffer.h" #endif +#include "yagl_onscreen_image_gl_texture_2d.h" #include "yagl_onscreen_fence.h" #include "yagl_backend.h" #include "yagl_malloc.h" @@ -147,6 +148,18 @@ static struct yagl_image #endif } +static struct yagl_image + *yagl_onscreen_create_image_gl_texture_2d(struct yagl_display *dpy, + struct yagl_context *ctx, + yagl_object_name texture, + struct yagl_client_interface *iface) +{ + struct yagl_onscreen_image_gl_texture_2d *image = + yagl_onscreen_image_gl_texture_2d_create(dpy, ctx, texture, iface); + + return image ? &image->base: NULL; +} + static struct yagl_fence *yagl_onscreen_create_fence(struct yagl_display *dpy) { @@ -172,6 +185,7 @@ struct yagl_backend *yagl_onscreen_create() backend->create_pbuffer_surface = &yagl_onscreen_create_pbuffer_surface; backend->create_image_pixmap = &yagl_onscreen_create_image_pixmap; backend->create_image_wl_buffer = &yagl_onscreen_create_image_wl_buffer; + backend->create_image_gl_texture_2d = &yagl_onscreen_create_image_gl_texture_2d; backend->create_fence = &yagl_onscreen_create_fence; backend->destroy = &yagl_onscreen_destroy; backend->y_inverted = 0; diff --git a/EGL/yagl_onscreen_image_gl_texture_2d.c b/EGL/yagl_onscreen_image_gl_texture_2d.c new file mode 100644 index 0000000..ede3b1c --- /dev/null +++ b/EGL/yagl_onscreen_image_gl_texture_2d.c @@ -0,0 +1,101 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Vasily Ulyanov <v.ulyanov@samsung.com> + * Jinhyung Jo <jinhyung.jo@samsung.com> + * YeongKyoon Lee <yeongkyoon.lee@samsung.com> + * + * 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 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. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "yagl_onscreen_image_gl_texture_2d.h" +#include "yagl_client_interface.h" +#include "yagl_client_image.h" +#include "yagl_egl_state.h" +#include "yagl_context.h" +#include "yagl_malloc.h" + +static void yagl_onscreen_image_gl_texture_2d_update(struct yagl_image *image) +{ +} + +static void yagl_onscreen_image_gl_texture_2d_destroy(struct yagl_ref *ref) +{ + struct yagl_onscreen_image_gl_texture_2d *image = (struct yagl_onscreen_image_gl_texture_2d *)ref; + + yagl_object_release(image->texture_obj); + + yagl_image_cleanup(&image->base); + + yagl_free(image); +} + + +struct yagl_onscreen_image_gl_texture_2d + *yagl_onscreen_image_gl_texture_2d_create(struct yagl_display *dpy, + struct yagl_context *ctx, + yagl_object_name texture, + struct yagl_client_interface *iface) +{ + struct yagl_client_image *client_image; + struct yagl_onscreen_image_gl_texture_2d *image; + struct yagl_object *texture_obj = NULL; + + image = yagl_malloc0(sizeof(*image)); + + client_image = iface->wrap_texture(iface, + ctx->client_ctx, + texture, + &texture_obj); + + if (!client_image) { + yagl_set_error(EGL_BAD_PARAMETER); + goto fail; + } + + yagl_image_init(&image->base, + &yagl_onscreen_image_gl_texture_2d_destroy, + dpy, + (EGLImageKHR)image, + client_image); + + yagl_client_image_release(client_image); + + image->base.update = &yagl_onscreen_image_gl_texture_2d_update; + + image->texture_obj = texture_obj; + + return image; + +fail: + if (texture_obj) { + yagl_object_release(texture_obj); + } + + yagl_free(image); + + return NULL; +} diff --git a/EGL/yagl_onscreen_image_gl_texture_2d.h b/EGL/yagl_onscreen_image_gl_texture_2d.h new file mode 100644 index 0000000..16b1245 --- /dev/null +++ b/EGL/yagl_onscreen_image_gl_texture_2d.h @@ -0,0 +1,56 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Vasily Ulyanov <v.ulyanov@samsung.com> + * Jinhyung Jo <jinhyung.jo@samsung.com> + * YeongKyoon Lee <yeongkyoon.lee@samsung.com> + * + * 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 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. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef _YAGL_ONSCREEN_IMAGE_GL_TEXTURE_2D_H_ +#define _YAGL_ONSCREEN_IMAGE_GL_TEXTURE_2D_H_ + +#include "yagl_image.h" +#include "EGL/egl.h" + +struct yagl_context; +struct yagl_client_interface; + +struct yagl_onscreen_image_gl_texture_2d +{ + struct yagl_image base; + + struct yagl_object *texture_obj; +}; + +struct yagl_onscreen_image_gl_texture_2d + *yagl_onscreen_image_gl_texture_2d_create(struct yagl_display *dpy, + struct yagl_context *ctx, + yagl_object_name texture, + struct yagl_client_interface *iface); + +#endif diff --git a/GLES_common/yagl_gles_image.c b/GLES_common/yagl_gles_image.c index bdd81a0..ffb95a6 100644 --- a/GLES_common/yagl_gles_image.c +++ b/GLES_common/yagl_gles_image.c @@ -33,6 +33,9 @@ #include "GL/gl.h" #include "yagl_gles_image.h" +#include "yagl_gles_texture.h" +#include "yagl_client_context.h" +#include "yagl_sharegroup.h" #include "yagl_malloc.h" #include "yagl_host_gles_calls.h" @@ -56,7 +59,9 @@ static void yagl_gles_image_destroy(struct yagl_ref *ref) { struct yagl_gles_image *image = (struct yagl_gles_image*)ref; - yagl_host_glDeleteObjects(&image->tex_global_name, 1); + if (image->own_tex) { + yagl_host_glDeleteObjects(&image->tex_global_name, 1); + } yagl_client_image_cleanup(&image->base); @@ -74,8 +79,43 @@ struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name) image->base.update = &yagl_gles_image_update; image->tex_global_name = tex_global_name; + image->own_tex = 1; + + return image; +} + +struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx, + yagl_object_name tex_local_name, + struct yagl_object **obj) +{ + struct yagl_gles_texture *texture_obj; + struct yagl_gles_image *image; + + texture_obj = (struct yagl_gles_texture *)yagl_sharegroup_acquire_object(ctx->sg, + YAGL_NS_TEXTURE, + tex_local_name); + + if (!texture_obj) { + goto fail; + } + + image = yagl_malloc0(sizeof(*image)); + + yagl_client_image_init(&image->base, &yagl_gles_image_destroy); + + image->base.update = &yagl_gles_image_update; + + image->tex_global_name = texture_obj->global_name; + image->own_tex = 0; + + *obj = &texture_obj->base; return image; + +fail: + yagl_gles_texture_release(texture_obj); + + return NULL; } void yagl_gles_image_acquire(struct yagl_gles_image *image) diff --git a/GLES_common/yagl_gles_image.h b/GLES_common/yagl_gles_image.h index ece73a3..431eb79 100644 --- a/GLES_common/yagl_gles_image.h +++ b/GLES_common/yagl_gles_image.h @@ -37,15 +37,23 @@ #include "yagl_types.h" #include "yagl_client_image.h" +struct yagl_client_context; + struct yagl_gles_image { struct yagl_client_image base; yagl_object_name tex_global_name; + + int own_tex; }; struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name); +struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx, + yagl_object_name tex_local_name, + struct yagl_object **obj); + /* * Passing NULL won't hurt, this is for convenience. */ diff --git a/GLESv1_CM/yagl_gles1_interface.c b/GLESv1_CM/yagl_gles1_interface.c index 93e3a00..0d73156 100644 --- a/GLESv1_CM/yagl_gles1_interface.c +++ b/GLESv1_CM/yagl_gles1_interface.c @@ -52,6 +52,15 @@ static struct yagl_client_image return &yagl_gles_image_create(tex_global_name)->base; } +static struct yagl_client_image + *yagl_gles1_wrap_texture(struct yagl_client_interface *iface, + struct yagl_client_context *ctx, + yagl_object_name tex_local_name, + struct yagl_object **texture_obj) +{ + return &yagl_gles_image_wrap_tex(ctx,tex_local_name, texture_obj)->base; +} + static void yagl_gles1_release_tex_image(struct yagl_client_interface *iface, void *cookie) { @@ -64,5 +73,6 @@ YAGL_API struct yagl_client_interface yagl_gles1_interface = { .create_ctx = &yagl_gles1_create_ctx, .create_image = &yagl_gles1_create_image, + .wrap_texture = &yagl_gles1_wrap_texture, .release_tex_image = &yagl_gles1_release_tex_image }; diff --git a/GLESv2/yagl_gles2_interface.c b/GLESv2/yagl_gles2_interface.c index be48b1f..4b24e09 100644 --- a/GLESv2/yagl_gles2_interface.c +++ b/GLESv2/yagl_gles2_interface.c @@ -60,6 +60,15 @@ static struct yagl_client_image return &yagl_gles_image_create(tex_global_name)->base; } +static struct yagl_client_image + *yagl_gles2_wrap_texture(struct yagl_client_interface *iface, + struct yagl_client_context *ctx, + yagl_object_name tex_local_name, + struct yagl_object **texture_obj) +{ + return &yagl_gles_image_wrap_tex(ctx, tex_local_name, texture_obj)->base; +} + static void yagl_gles2_release_tex_image(struct yagl_client_interface *iface, void *cookie) { @@ -72,5 +81,6 @@ YAGL_API struct yagl_client_interface yagl_gles2_interface = { .create_ctx = &yagl_gles2_create_ctx, .create_image = &yagl_gles2_create_image, + .wrap_texture = &yagl_gles2_wrap_texture, .release_tex_image = &yagl_gles2_release_tex_image }; diff --git a/include/yagl_client_interface.h b/include/yagl_client_interface.h index db5e461..62fb3df 100644 --- a/include/yagl_client_interface.h +++ b/include/yagl_client_interface.h @@ -39,6 +39,7 @@ struct yagl_client_context; struct yagl_client_image; struct yagl_sharegroup; +struct yagl_object; struct yagl_client_interface { @@ -50,6 +51,12 @@ struct yagl_client_interface *(*create_image)(struct yagl_client_interface */*iface*/, yagl_object_name /*tex_global_name*/); + struct yagl_client_image + *(*wrap_texture)(struct yagl_client_interface */*iface*/, + struct yagl_client_context */*ctx*/, + yagl_object_name /*tex_local_name*/, + struct yagl_object **/*obj*/); + void (*release_tex_image)(struct yagl_client_interface */*iface*/, void */*cookie*/); }; |