tizen 2.4 release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20151029.024837 submit/tizen_2.4/20151028.065715 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 09:30:21 +0000 (18:30 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 09:30:21 +0000 (18:30 +0900)
39 files changed:
CMakeLists.txt
EGL/CMakeLists.txt
EGL/x11/yagl_dri3.c [new file with mode: 0644]
EGL/x11/yagl_dri3.h [new file with mode: 0644]
EGL/x11/yagl_x11_display.c
EGL/x11/yagl_x11_display.h
EGL/yagl_backend.h
EGL/yagl_display.c
EGL/yagl_egl_calls.c
EGL/yagl_egl_calls.in
EGL/yagl_egl_state.c
EGL/yagl_host_egl_calls.c
EGL/yagl_native_display.c
EGL/yagl_offscreen.c
EGL/yagl_onscreen.c
EGL/yagl_onscreen_image_gl_texture_2d.c [new file with mode: 0644]
EGL/yagl_onscreen_image_gl_texture_2d.h [new file with mode: 0644]
EGL/yagl_onscreen_image_tizen_sfc.c [new file with mode: 0644]
EGL/yagl_onscreen_image_tizen_sfc.h [new file with mode: 0644]
GLES_common/yagl_gles_calls.c
GLES_common/yagl_gles_calls.in
GLES_common/yagl_gles_image.c
GLES_common/yagl_gles_image.h
GLES_common/yagl_gles_pixel_formats.c
GLES_common/yagl_host_gles_calls.c
GLES_common/yagl_host_gles_calls.h
GLESv1_CM/yagl_gles1_interface.c
GLESv2/yagl_gles2_calls.c
GLESv2/yagl_gles2_context.c
GLESv2/yagl_gles2_interface.c
GLESv2/yagl_gles2_program.c
GLESv2/yagl_gles3_query.c
include/EGL/egl.h
include/EGL/eglext.h
include/EGL/eglmesaext.h
include/EGL/eglplatform.h
include/yagl_client_interface.h
packaging/emulator-yagl.spec
packaging/opengl-es-setup-yagl-env.sh [deleted file]

index 5702a3a..bced734 100644 (file)
@@ -70,10 +70,16 @@ add_definitions(${LIBDRM_VIGS_CFLAGS})
 include_directories(${LIBDRM_VIGS_INCLUDE_DIRS})
 link_directories(${LIBDRM_VIGS_LIBRARY_DIRS})
 
+pkg_check_modules(LIBTBM REQUIRED libtbm)
+add_definitions(${LIBTBM_CFLAGS})
+include_directories(${LIBTBM_INCLUDE_DIRS})
+link_directories(${LIBTBM_LIBRARY_DIRS})
+
 if (PLATFORM_X11)
     pkg_check_modules(X11 REQUIRED x11)
     pkg_check_modules(XEXT REQUIRED xext)
     pkg_check_modules(XFIXES REQUIRED xfixes)
+    pkg_check_modules(XCB REQUIRED xcb)
 
     add_definitions(${X11_CFLAGS})
     include_directories(${X11_INCLUDE_DIRS})
@@ -86,6 +92,10 @@ if (PLATFORM_X11)
     add_definitions(${XFIXES_CFLAGS})
     include_directories(${XFIXES_INCLUDE_DIRS})
     link_directories(${XFIXES_LIBRARY_DIRS})
+
+    add_definitions(${XCB_CFLAGS})
+    include_directories(${XCB_INCLUDE_DIRS})
+    link_directories(${XCB_LIBRARY_DIRS})
 endif ()
 
 if (PLATFORM_GBM)
index 2aea772..4d40059 100644 (file)
@@ -21,6 +21,8 @@ set(SOURCES
     yagl_offscreen_surface.c
     yagl_onscreen.c
     yagl_onscreen_image_pixmap.c
+    yagl_onscreen_image_gl_texture_2d.c
+    yagl_onscreen_image_tizen_sfc.c
     yagl_onscreen_surface.c
     yagl_onscreen_fence.c
     yagl_onscreen_utils.c
@@ -41,12 +43,14 @@ set(LIBRARIES
     ${CMAKE_THREAD_LIBS_INIT}
     ${LIBDRM_LIBRARIES}
     ${LIBDRM_VIGS_LIBRARIES}
+    ${LIBTBM_LIBRARIES}
     dl
 )
 
 if (PLATFORM_X11)
     set(SOURCES ${SOURCES}
         x11/yagl_dri2.c
+        x11/yagl_dri3.c
         x11/yagl_x11_platform.c
         x11/yagl_x11_display.c
         x11/yagl_x11_drawable.c
@@ -56,6 +60,12 @@ if (PLATFORM_X11)
         ${X11_LIBRARIES}
         ${XEXT_LIBRARIES}
         ${XFIXES_LIBRARIES}
+        ${XCB_LIBRARIES}
+        X11-xcb
+        xcb-dri3
+        xcb-present
+        xshmfence
+        xcb-sync
     )
     add_definitions(-DYAGL_PLATFORM_X11)
 endif ()
diff --git a/EGL/x11/yagl_dri3.c b/EGL/x11/yagl_dri3.c
new file mode 100644 (file)
index 0000000..772e752
--- /dev/null
@@ -0,0 +1,1227 @@
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xlib-xcb.h>
+#include <X11/xshmfence.h>
+#include <xcb/xcb.h>
+#include <xcb/dri3.h>
+#include <xcb/present.h>
+#include <xf86drm.h>
+#include <sys/fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "yagl_dri3.h"
+#include "yagl_x11_drawable.h"
+#include "yagl_x11_display.h"
+#include "yagl_x11_image.h"
+#include "yagl_malloc.h"
+#include "yagl_log.h"
+#include "vigs.h"
+
+static inline void yagl_dri3_fence_reset(xcb_connection_t *c,
+                                         struct yagl_dri3_buffer *buffer)
+{
+    xshmfence_reset(buffer->shm_fence);
+}
+
+static inline void yagl_dri3_fence_set(struct yagl_dri3_buffer *buffer)
+{
+    xshmfence_trigger(buffer->shm_fence);
+}
+
+static inline void yagl_dri3_fence_trigger(xcb_connection_t *c,
+                                           struct yagl_dri3_buffer *buffer)
+{
+    xcb_sync_trigger_fence(c, buffer->sync_fence);
+}
+
+static inline void yagl_dri3_fence_await(xcb_connection_t *c,
+                                         struct yagl_dri3_buffer *buffer)
+{
+    xcb_flush(c);
+    xshmfence_await(buffer->shm_fence);
+}
+
+static inline Bool yagl_dri3_fence_triggered(struct yagl_dri3_buffer *buffer)
+{
+    return xshmfence_query(buffer->shm_fence);
+}
+
+/** yagl_dri3_alloc_render_buffer
+ *
+ * Allocate a render buffer and create an X pixmap from that
+ *
+ * Allocate an xshmfence for synchronization
+ */
+static struct yagl_dri3_buffer *yagl_dri3_alloc_render_buffer(struct yagl_dri3_drawable *drawable,
+                                                              unsigned int format,
+                                                              int width,
+                                                              int height,
+                                                              int depth)
+{
+    Drawable x_drawable = YAGL_X11_DRAWABLE(drawable->base.os_drawable);
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    struct yagl_dri3_buffer *buffer;
+    struct vigs_drm_surface *sfc;
+    xcb_pixmap_t pixmap;
+    xcb_sync_fence_t sync_fence;
+    xcb_void_cookie_t cookie;
+    xcb_generic_error_t *error;
+    struct xshmfence *shm_fence;
+    int buffer_fd, fence_fd;
+    int stride, cpp, ret;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_alloc_render_buffer);
+
+    fence_fd = xshmfence_alloc_shm();
+
+    if (fence_fd < 0) {
+        YAGL_LOG_ERROR("DRI3 Fence object allocation failure %s",
+                       strerror(errno));
+        return NULL;
+    }
+
+    shm_fence = xshmfence_map_shm(fence_fd);
+
+    if (shm_fence == NULL) {
+        YAGL_LOG_ERROR("DRI3 Fence object map failure %s",
+                       strerror(errno));
+        goto err_shm_fence;
+    }
+
+    buffer = yagl_malloc0(sizeof(*buffer));
+
+    if (!buffer) {
+        YAGL_LOG_ERROR("DRI3 Buffer object allocation failure %s",
+                       strerror(errno));
+        goto err_buffer;
+    }
+
+    switch (format) {
+    case vigs_drm_surface_bgrx8888:
+    case vigs_drm_surface_bgra8888:
+        cpp = 4;
+        stride = width * cpp;
+        break;
+    default:
+        cpp = 0;
+        break;
+    }
+
+    if (!cpp) {
+        YAGL_LOG_ERROR("DRI3 buffer format %d invalid", format);
+        goto err_format;
+    }
+
+    ret = vigs_drm_surface_create(drawable->base.dpy->drm_dev,
+                                  width,
+                                  height,
+                                  stride,
+                                  format,
+                                  0, /* scanout */
+                                  &sfc);
+
+    if (ret) {
+        YAGL_LOG_ERROR("DRI3 surface creation failure %s", strerror(errno));
+        goto err_sfc;
+    }
+
+    /* Export allocated buffer */
+    ret = vigs_drm_prime_export_fd(drawable->base.dpy->drm_dev,
+                                   sfc,
+                                   &buffer_fd);
+
+    if (ret) {
+        YAGL_LOG_ERROR("DRI3 fd export failure %s", strerror(errno));
+        goto err_export;
+    }
+
+    /* Import fd at X side */
+    cookie = xcb_dri3_pixmap_from_buffer_checked(c,
+                                                 (pixmap = xcb_generate_id(c)),
+                                                 x_drawable,
+                                                 sfc->gem.size,
+                                                 width,
+                                                 height,
+                                                 stride,
+                                                 depth,
+                                                 cpp * 8, /* bpp */
+                                                 buffer_fd);
+    error = xcb_request_check(c, cookie);
+
+    if (error) {
+        YAGL_LOG_ERROR("DRI3 pixmap_from_buffer failed (pixmap = %p, errcode = %d)",
+                       (void *)pixmap, (int)error->error_code);
+        free(error);
+        goto err_export;
+    }
+
+    cookie = xcb_dri3_fence_from_fd_checked(c,
+                                            pixmap,
+                                            (sync_fence = xcb_generate_id(c)),
+                                            false,
+                                            fence_fd);
+    error = xcb_request_check(c, cookie);
+
+    if (error) {
+        YAGL_LOG_ERROR("DRI3 fence_from_fd failed (pixmap = %p, errcode = %d)",
+                       (void *)pixmap, (int)error->error_code);
+        free(error);
+        goto err_export;
+    }
+
+    buffer->pixmap = pixmap;
+    buffer->own_pixmap = true;
+    buffer->sync_fence = sync_fence;
+    buffer->shm_fence = shm_fence;
+    buffer->width = width;
+    buffer->height = height;
+    buffer->pitch = stride;
+    buffer->sfc = sfc;
+
+    /* Mark the buffer as idle
+     */
+    yagl_dri3_fence_set(buffer);
+
+    return buffer;
+
+err_export:
+    vigs_drm_gem_unref(&sfc->gem);
+
+err_sfc:
+    /* nothing to do here */
+
+err_format:
+    yagl_free(buffer);
+
+err_buffer:
+    xshmfence_unmap_shm(shm_fence);
+
+err_shm_fence:
+    close(fence_fd);
+
+    YAGL_LOG_ERROR("DRI3 alloc_render_buffer failed\n");
+
+    return NULL;
+}
+
+/** yagl_dri3_free_render_buffer
+ *
+ * Free everything associated with one render buffer including pixmap, fence
+ * stuff and the driver surface
+ */
+static void yagl_dri3_free_render_buffer(struct yagl_dri3_drawable *drawable,
+                                         struct yagl_dri3_buffer *buffer)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+
+    if (buffer->own_pixmap) {
+        xcb_free_pixmap(c, buffer->pixmap);
+    }
+
+    if (buffer->sfc) {
+        vigs_drm_gem_unref(&buffer->sfc->gem);
+    }
+
+    xcb_sync_destroy_fence(c, buffer->sync_fence);
+    xshmfence_unmap_shm(buffer->shm_fence);
+
+    yagl_free(buffer);
+}
+
+static void yagl_dri3_update_num_back(struct yagl_dri3_drawable *drawable)
+{
+    drawable->num_back = 1;
+
+    if (drawable->flipping) {
+        if (!drawable->is_pixmap && !(drawable->present_capabilities & XCB_PRESENT_CAPABILITY_ASYNC)) {
+           drawable->num_back++;
+        }
+
+        drawable->num_back++;
+    }
+
+    if (drawable->swap_interval == 0) {
+        drawable->num_back++;
+    }
+
+    if (drawable->num_back < 2) {
+        drawable->num_back = 2;
+    }
+}
+
+/*
+ * Process one Present event
+ */
+static void yagl_dri3_handle_present_event(struct yagl_dri3_drawable *drawable,
+                                           xcb_present_generic_event_t *ge)
+{
+    YAGL_LOG_FUNC_SET(yagl_dri3_handle_present_event);
+
+    switch (ge->evtype) {
+    case XCB_PRESENT_CONFIGURE_NOTIFY: {
+        xcb_present_configure_notify_event_t *ce = (void *)ge;
+
+        YAGL_LOG_DEBUG("XCB_PRESENT_CONFIGURE_NOTIFY: %dx%d => %dx%d",
+                       drawable->width,
+                       drawable->height,
+                       ce->width,
+                       ce->height);
+
+        drawable->width = ce->width;
+        drawable->height = ce->height;
+
+        break;
+    }
+    case XCB_PRESENT_COMPLETE_NOTIFY: {
+        xcb_present_complete_notify_event_t *ce = (void *)ge;
+
+        YAGL_LOG_DEBUG("XCB_PRESENT_COMPLETE_NOTIFY");
+
+        /* Compute the processed SBC number from the received 32-bit serial number merged
+         * with the upper 32-bits of the sent 64-bit serial number while checking for
+         * wrap
+         */
+        if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
+            drawable->recv_sbc = (drawable->send_sbc & 0xffffffff00000000LL) | ce->serial;
+            if (drawable->recv_sbc > drawable->send_sbc) {
+                drawable->recv_sbc -= 0x100000000;
+            }
+
+            switch (ce->mode) {
+            case XCB_PRESENT_COMPLETE_MODE_FLIP:
+                drawable->flipping = true;
+                break;
+            case XCB_PRESENT_COMPLETE_MODE_COPY:
+                drawable->flipping = false;
+                break;
+            }
+
+            yagl_dri3_update_num_back(drawable);
+
+            drawable->ust = ce->ust;
+            drawable->msc = ce->msc;
+        } else {
+            drawable->recv_msc_serial = ce->serial;
+            drawable->notify_ust = ce->ust;
+            drawable->notify_msc = ce->msc;
+        }
+
+        break;
+    }
+    case XCB_PRESENT_EVENT_IDLE_NOTIFY: {
+        xcb_present_idle_notify_event_t *ie = (void *)ge;
+        int b;
+
+        YAGL_LOG_DEBUG("XCB_PRESENT_EVENT_IDLE_NOTIFY");
+
+        for (b = 0; b < sizeof(drawable->buffers) / sizeof(drawable->buffers[0]); b++) {
+            struct yagl_dri3_buffer *buf = drawable->buffers[b];
+
+            if (buf && buf->pixmap == ie->pixmap) {
+                buf->busy = 0;
+
+                if (drawable->num_back <= b && b < DRI3_MAX_BACK) {
+                   yagl_dri3_free_render_buffer(drawable, buf);
+                   drawable->buffers[b] = NULL;
+                }
+
+                break;
+            }
+        }
+
+        break;
+    }
+    }
+
+    free(ge);
+}
+
+/** yagl_dri3_flush_present_events
+ *
+ * Process any present events that have been received from the X server
+ */
+static void yagl_dri3_flush_present_events(struct yagl_dri3_drawable *drawable)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+
+    /* Check to see if any configuration changes have occurred
+     * since we were last invoked
+     */
+    if (drawable->special_event) {
+        xcb_generic_event_t *ev;
+
+        while ((ev = xcb_poll_for_special_event(c, drawable->special_event)) != NULL) {
+            xcb_present_generic_event_t *ge = (void *)ev;
+            yagl_dri3_handle_present_event(drawable, ge);
+        }
+    }
+}
+
+/** yagl_dri3_update_drawable
+ *
+ * Called the first time we use the drawable and then
+ * after we receive present configure notify events to
+ * track the geometry of the drawable
+ */
+static int yagl_dri3_update_drawable(struct yagl_dri3_drawable *drawable)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_update_drawable);
+
+    /* First time through, go get the current drawable geometry
+     */
+    if (drawable->width == 0 || drawable->height == 0 || drawable->depth == 0) {
+        xcb_get_geometry_cookie_t geom_cookie;
+        xcb_get_geometry_reply_t *geom_reply;
+        xcb_void_cookie_t cookie;
+        xcb_generic_error_t *error;
+        xcb_present_query_capabilities_cookie_t present_capabilities_cookie;
+        xcb_present_query_capabilities_reply_t *present_capabilities_reply;
+        Drawable x_drawable = YAGL_X11_DRAWABLE(drawable->base.os_drawable);
+
+        /* Try to select for input on the window.
+         *
+         * If the drawable is a window, this will get our events
+         * delivered.
+         *
+         * Otherwise, we'll get a BadWindow error back from this request which
+         * will let us know that the drawable is a pixmap instead.
+         */
+
+        cookie = xcb_present_select_input_checked(c,
+                                                  (drawable->eid = xcb_generate_id(c)),
+                                                  x_drawable,
+                                                  XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY|
+                                                  XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY|
+                                                  XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
+
+        present_capabilities_cookie = xcb_present_query_capabilities(c, x_drawable);
+
+        /* Create an XCB event queue to hold present events outside of the usual
+         * application event queue
+         */
+        drawable->special_event = xcb_register_for_special_xge(c,
+                                                               &xcb_present_id,
+                                                               drawable->eid,
+                                                               &drawable->base.stamp);
+
+        geom_cookie = xcb_get_geometry(c, x_drawable);
+        geom_reply = xcb_get_geometry_reply(c, geom_cookie, NULL);
+
+        if (!geom_reply) {
+            return false;
+        }
+
+        drawable->width = geom_reply->width;
+        drawable->height = geom_reply->height;
+        drawable->depth = geom_reply->depth;
+        drawable->is_pixmap = false;
+
+        free(geom_reply);
+
+        /* Check to see if our select input call failed. If it failed with a
+         * BadWindow error, then assume the drawable is a pixmap. Destroy the
+         * special event queue created above and mark the drawable as a pixmap
+         */
+
+        error = xcb_request_check(c, cookie);
+
+        present_capabilities_reply = xcb_present_query_capabilities_reply(c,
+                                                                          present_capabilities_cookie,
+                                                                          NULL);
+
+        if (present_capabilities_reply) {
+            drawable->present_capabilities = present_capabilities_reply->capabilities;
+            free(present_capabilities_reply);
+        } else {
+            drawable->present_capabilities = 0;
+        }
+
+        if (error) {
+            if (error->error_code != BadWindow) {
+                free(error);
+                return false;
+            }
+
+            drawable->is_pixmap = true;
+            xcb_unregister_for_special_event(c, drawable->special_event);
+            drawable->special_event = NULL;
+        }
+
+        YAGL_LOG_DEBUG("%s 0x%X initial geometry: %ux%u %u",
+                       drawable->is_pixmap ? "Pixmap": "Window",
+                       x_drawable,
+                       drawable->width,
+                       drawable->height,
+                       drawable->depth);
+    }
+
+    yagl_dri3_flush_present_events(drawable);
+
+    return true;
+}
+
+static xcb_gcontext_t yagl_dri3_drawable_gc(struct yagl_dri3_drawable *drawable)
+{
+    if (!drawable->gc) {
+        Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+        Drawable x_drawable = YAGL_X11_DRAWABLE(drawable->base.os_drawable);
+        xcb_connection_t *c = XGetXCBConnection(x_dpy);
+        uint32_t v = 0;
+
+        xcb_create_gc(c,
+                      (drawable->gc = xcb_generate_id(c)),
+                      x_drawable,
+                      XCB_GC_GRAPHICS_EXPOSURES,
+                      &v);
+    }
+
+    return drawable->gc;
+}
+
+static struct yagl_dri3_buffer *yagl_dri3_back_buffer(struct yagl_dri3_drawable *drawable)
+{
+   return drawable->buffers[DRI3_BACK_ID(drawable->cur_back)];
+}
+
+static struct yagl_dri3_buffer *yagl_dri3_front_buffer(struct yagl_dri3_drawable *drawable)
+{
+   return drawable->buffers[DRI3_FRONT_ID];
+}
+
+static void yagl_dri3_copy_area(xcb_connection_t *c,
+                                xcb_drawable_t src_drawable,
+                                xcb_drawable_t dst_drawable,
+                                xcb_gcontext_t gc,
+                                int16_t src_x,
+                                int16_t src_y,
+                                int16_t dst_x,
+                                int16_t dst_y,
+                                uint16_t width,
+                                uint16_t height)
+{
+   xcb_void_cookie_t cookie;
+
+   cookie = xcb_copy_area_checked(c,
+                                  src_drawable,
+                                  dst_drawable,
+                                  gc,
+                                  src_x,
+                                  src_y,
+                                  dst_x,
+                                  dst_y,
+                                  width,
+                                  height);
+   xcb_discard_reply(c, cookie.sequence);
+}
+
+static void yagl_dri3_copy_drawable(struct yagl_dri3_drawable *drawable,
+                                    Drawable dest,
+                                    Drawable src)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    struct yagl_dri3_buffer *front = yagl_dri3_front_buffer(drawable);
+
+    yagl_dri3_fence_reset(c, front);
+    yagl_dri3_copy_area(c,
+                        src,
+                        dest,
+                        yagl_dri3_drawable_gc(drawable),
+                        0,
+                        0,
+                        0,
+                        0,
+                        drawable->width,
+                        drawable->height);
+    yagl_dri3_fence_trigger(c, front);
+    yagl_dri3_fence_await(c, front);
+}
+
+static inline int yagl_dri3_pixmap_buf_id(enum yagl_dri3_buffer_type buffer_type)
+{
+   if (buffer_type == yagl_dri3_buffer_back) {
+       return DRI3_BACK_ID(0);
+   } else {
+       return DRI3_FRONT_ID;
+   }
+}
+
+/** yagl_dri3_get_pixmap_buffer
+ *
+ * Get the DRM object for a pixmap from the X server
+ */
+static struct yagl_dri3_buffer *yagl_dri3_get_pixmap_buffer(struct yagl_dri3_drawable *drawable,
+                                                            unsigned int format,
+                                                            enum yagl_dri3_buffer_type buffer_type)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    int buf_id = yagl_dri3_pixmap_buf_id(buffer_type);
+    struct yagl_dri3_buffer *buffer = drawable->buffers[buf_id];
+    Pixmap pixmap = YAGL_X11_DRAWABLE(drawable->base.os_drawable);
+    xcb_dri3_buffer_from_pixmap_cookie_t bp_cookie;
+    xcb_dri3_buffer_from_pixmap_reply_t  *bp_reply;
+    xcb_sync_fence_t sync_fence;
+    struct xshmfence *shm_fence;
+    struct vigs_drm_surface *sfc;
+    int fence_fd, *fds;
+    int ret;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_get_pixmap_buffer);
+
+    if (buffer) {
+        return buffer;
+    }
+
+    buffer = yagl_malloc0(sizeof(*buffer));
+
+    if (!buffer) {
+        YAGL_LOG_ERROR("DRI3 buffer object allocation failure");
+        return NULL;
+    }
+
+    fence_fd = xshmfence_alloc_shm();
+
+    if (fence_fd < 0) {
+        YAGL_LOG_ERROR("DRI3 Fence object allocation failure %s",
+                       strerror(errno));
+        goto err_alloc_fence;
+    }
+
+    shm_fence = xshmfence_map_shm(fence_fd);
+
+    if (shm_fence == NULL) {
+        YAGL_LOG_ERROR("DRI3 Fence object map failure %s",
+                       strerror(errno));
+        goto err_map_shm;
+    }
+
+    xcb_dri3_fence_from_fd(c,
+                           pixmap,
+                           (sync_fence = xcb_generate_id(c)),
+                           false,
+                           fence_fd);
+
+    /* Get an FD for the pixmap object
+     */
+    bp_cookie = xcb_dri3_buffer_from_pixmap(c, pixmap);
+    bp_reply = xcb_dri3_buffer_from_pixmap_reply(c, bp_cookie, NULL);
+
+    if (!bp_reply) {
+        YAGL_LOG_ERROR("DRI3 buffer_from_pixmap failed");
+        goto err_get_fd;
+    }
+
+    fds = xcb_dri3_buffer_from_pixmap_reply_fds(c, bp_reply);
+
+    /* Import exported FD */
+    ret = vigs_drm_prime_import_fd(drawable->base.dpy->drm_dev,
+                                   fds[0],
+                                   &sfc);
+
+    if (ret) {
+        YAGL_LOG_ERROR("DRI3 fd import failure %s", strerror(errno));
+        goto err_import;
+    }
+
+    close(fds[0]);
+
+    buffer->pixmap = pixmap;
+    buffer->own_pixmap = false;
+    buffer->sync_fence = sync_fence;
+    buffer->shm_fence = shm_fence;
+    buffer->width = bp_reply->width;
+    buffer->height = bp_reply->height;
+    buffer->pitch = bp_reply->stride;
+    buffer->buffer_type = buffer_type;
+    buffer->sfc = sfc;
+
+    drawable->buffers[buf_id] = buffer;
+
+    return buffer;
+
+err_import:
+    close(fds[0]);
+
+err_get_fd:
+    /* nothing to do here */
+
+err_map_shm:
+    close(fence_fd);
+
+err_alloc_fence:
+    yagl_free(buffer);
+
+    return NULL;
+}
+
+/** yagl_dri3_find_back
+ *
+ * Find an idle back buffer. If there isn't one, then
+ * wait for a present idle notify event from the X server
+ */
+static int yagl_dri3_find_back(xcb_connection_t *c,
+                               struct yagl_dri3_drawable *drawable)
+{
+   int  b;
+   xcb_generic_event_t *ev;
+   xcb_present_generic_event_t *ge;
+
+   for (;;) {
+       for (b = 0; b < drawable->num_back; b++) {
+           int id = DRI3_BACK_ID((b + drawable->cur_back) % drawable->num_back);
+           struct yagl_dri3_buffer *buffer = drawable->buffers[id];
+
+           if (!buffer || !buffer->busy) {
+               drawable->cur_back = id;
+               return id;
+           }
+       }
+
+       xcb_flush(c);
+       ev = xcb_wait_for_special_event(c, drawable->special_event);
+
+       if (!ev) {
+          return -1;
+       }
+
+       ge = (void *)ev;
+       yagl_dri3_handle_present_event(drawable, ge);
+   }
+}
+
+/** yagl_dri3_get_buffer
+ *
+ * Find a front or back buffer, allocating new ones as necessary
+ */
+static struct yagl_dri3_buffer *yagl_dri3_get_buffer(struct yagl_dri3_drawable *drawable,
+                                                     unsigned int format,
+                                                     enum yagl_dri3_buffer_type buffer_type)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->base.dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    struct yagl_dri3_buffer *buffer;
+    int buf_id;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_get_buffer);
+
+    if (buffer_type == yagl_dri3_buffer_back) {
+        buf_id = yagl_dri3_find_back(c, drawable);
+
+        if (buf_id < 0) {
+            return NULL;
+        }
+    } else {
+        buf_id = DRI3_FRONT_ID;
+    }
+
+    buffer = drawable->buffers[buf_id];
+
+    if (!buffer ||
+        buffer->width != drawable->width ||
+        buffer->height != drawable->height) {
+        struct yagl_dri3_buffer *new_buffer = yagl_dri3_alloc_render_buffer(drawable,
+                                                                            format,
+                                                                            drawable->width,
+                                                                            drawable->height,
+                                                                            drawable->depth);
+
+        if (!new_buffer) {
+            YAGL_LOG_ERROR("DRI3 buffer object allocation failure");
+            return NULL;
+        }
+
+        /* When resizing, copy the contents of the old buffer, waiting for that
+         * copy to complete using our fences before proceeding
+         */
+        switch (buffer_type) {
+        case yagl_dri3_buffer_back:
+            if (buffer) {
+                yagl_dri3_fence_reset(c, new_buffer);
+                yagl_dri3_fence_await(c, buffer);
+                yagl_dri3_copy_area(c,
+                                    buffer->pixmap,
+                                    new_buffer->pixmap,
+                                    yagl_dri3_drawable_gc(drawable),
+                                    0,
+                                    0,
+                                    0,
+                                    0,
+                                    drawable->width,
+                                    drawable->height);
+                yagl_dri3_fence_trigger(c, new_buffer);
+                yagl_dri3_free_render_buffer(drawable, buffer);
+            }
+            break;
+        case yagl_dri3_buffer_front:
+            yagl_dri3_fence_reset(c, new_buffer);
+            yagl_dri3_copy_area(c,
+                                YAGL_X11_DRAWABLE(drawable->base.os_drawable),
+                                new_buffer->pixmap,
+                                yagl_dri3_drawable_gc(drawable),
+                                0,
+                                0,
+                                0,
+                                0,
+                                drawable->width,
+                                drawable->height);
+            yagl_dri3_fence_trigger(c, new_buffer);
+            break;
+        }
+
+
+        buffer = new_buffer;
+        buffer->buffer_type = buffer_type;
+        drawable->buffers[buf_id] = buffer;
+    }
+
+    yagl_dri3_fence_await(c, buffer);
+
+    return buffer;
+}
+
+static int yagl_dri3_drawable_get_buffer(struct yagl_native_drawable *drawable,
+                                         yagl_native_attachment attachment,
+                                         uint32_t *buffer_name,
+                                         struct vigs_drm_surface **buffer_sfc)
+{
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+    struct yagl_dri3_buffer *buffer;
+    vigs_drm_surface_format format;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_get_buffer);
+
+    YAGL_LOG_DEBUG("enter: attachment = %d", attachment);
+
+    if (!yagl_dri3_update_drawable(dri3_drawable)) {
+        YAGL_LOG_ERROR("DRI3 drawable update failure");
+        return 0;
+    }
+
+    switch (dri3_drawable->depth) {
+    case 24:
+        format = vigs_drm_surface_bgrx8888;
+        break;
+    case 32:
+        format = vigs_drm_surface_bgra8888;
+        break;
+    default:
+        YAGL_LOG_ERROR("DRI3 bad drawable depth %d", dri3_drawable->depth);
+        return 0;
+    }
+
+    switch (attachment) {
+    case yagl_native_attachment_front:
+        buffer = yagl_dri3_get_pixmap_buffer(dri3_drawable,
+                                             format,
+                                             yagl_dri3_buffer_front);
+        break;
+    case yagl_native_attachment_back:
+        buffer = yagl_dri3_get_buffer(dri3_drawable,
+                                      format,
+                                      yagl_dri3_buffer_back);
+        break;
+    default:
+        YAGL_LOG_ERROR("DRI3 bad attachment %u", attachment);
+        return 0;
+    }
+
+    if (!buffer) {
+        YAGL_LOG_ERROR("DRI3 get_buffer failed for attachement %d", attachment);
+        return 0;
+    }
+
+    vigs_drm_gem_ref(&buffer->sfc->gem);
+    *buffer_sfc = buffer->sfc;
+
+    return 1;
+}
+
+static int yagl_dri3_drawable_get_buffer_age(struct yagl_native_drawable *drawable)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+    int back_id = DRI3_BACK_ID(yagl_dri3_find_back(c, dri3_drawable));
+    struct yagl_dri3_buffer *back = dri3_drawable->buffers[back_id];
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_get_buffer_age);
+
+    YAGL_LOG_DEBUG("enter");
+
+    if (back_id < 0 || !back) {
+        return 0;
+    }
+
+    if (back->last_swap != 0) {
+        return dri3_drawable->send_sbc - back->last_swap + 1;
+    } else {
+        return 0;
+    }
+}
+
+static void yagl_dri3_drawable_swap_buffers(struct yagl_native_drawable *drawable)
+{
+    Display *x_dpy = YAGL_X11_DPY(drawable->dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+    struct yagl_dri3_buffer *back = yagl_dri3_back_buffer(dri3_drawable);
+    int64_t target_msc = 0;
+    int64_t divisor = 0;
+    int64_t remainder = 0;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_swap_buffers);
+
+    yagl_dri3_flush_present_events(dri3_drawable);
+
+    if (back && !dri3_drawable->is_pixmap) {
+        yagl_dri3_fence_reset(c, back);
+
+        ++dri3_drawable->send_sbc;
+
+        target_msc = dri3_drawable->msc + dri3_drawable->swap_interval *
+                     (dri3_drawable->send_sbc - dri3_drawable->recv_sbc);
+
+        YAGL_LOG_DEBUG("msc = %llu, swap_interval = %d, "
+                       "send_sbc = %llu, recv_sbc = %llu, "
+                       "target_msc = %llu",
+                       dri3_drawable->msc,
+                       dri3_drawable->swap_interval,
+                       dri3_drawable->send_sbc,
+                       dri3_drawable->recv_sbc,
+                       target_msc);
+
+        back->busy = 1;
+        back->last_swap = dri3_drawable->send_sbc;
+
+        xcb_present_pixmap(c,
+                           YAGL_X11_DRAWABLE(drawable->os_drawable), /* dst*/
+                           back->pixmap, /* src */
+                           (uint32_t)dri3_drawable->send_sbc, /* serial */
+                           0, /* valid */
+                           0, /* update */
+                           0, /* x_off */
+                           0, /* y_off */
+                           None, /* target_crtc */
+                           None, /* wait_fence */
+                           back->sync_fence, /* idle_fence */
+                           XCB_PRESENT_OPTION_NONE, /* options */
+                           target_msc, /* target_msc */
+                           divisor, /* divisor */
+                           remainder, /* remainder */
+                           0, /* notifies_len */
+                           NULL /* notifies */);
+
+        xcb_flush(c);
+
+        drawable->stamp++;
+    }
+}
+
+static void yagl_dri3_drawable_wait(struct yagl_native_drawable *drawable,
+                                    uint32_t width,
+                                    uint32_t height)
+{
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+    struct yagl_dri3_buffer *front;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_wait);
+
+    YAGL_LOG_DEBUG("enter");
+
+    if (!dri3_drawable->is_pixmap) {
+        return;
+    }
+
+    front = yagl_dri3_front_buffer(dri3_drawable);
+
+    yagl_dri3_copy_drawable(dri3_drawable,
+                            front->pixmap,
+                            YAGL_X11_DRAWABLE(drawable->os_drawable));
+}
+
+static void yagl_dri3_drawable_copy_to_pixmap(struct yagl_native_drawable *drawable,
+                                              yagl_os_pixmap os_pixmap,
+                                              uint32_t from_x,
+                                              uint32_t from_y,
+                                              uint32_t to_x,
+                                              uint32_t to_y,
+                                              uint32_t width,
+                                              uint32_t height)
+{
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+    struct yagl_dri3_buffer *front = yagl_dri3_front_buffer(dri3_drawable);
+    Display *x_dpy = YAGL_X11_DPY(drawable->dpy->os_dpy);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    xcb_gcontext_t gc;
+    uint32_t v = 0;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_copy_to_pixmap);
+
+    YAGL_LOG_DEBUG("enter");
+
+    xcb_create_gc(c,
+                  (gc = xcb_generate_id(c)),
+                  YAGL_X11_DRAWABLE(os_pixmap),
+                  XCB_GC_GRAPHICS_EXPOSURES,
+                  &v);
+
+    yagl_dri3_fence_reset(c, front);
+    yagl_dri3_copy_area(c,
+                        YAGL_X11_DRAWABLE(drawable->os_drawable),
+                        YAGL_X11_DRAWABLE(os_pixmap),
+                        gc,
+                        from_x,
+                        from_y,
+                        to_x,
+                        to_y,
+                        width,
+                        height);
+    yagl_dri3_fence_trigger(c, front);
+    yagl_dri3_fence_await(c, front);
+
+    xcb_free_gc(c, gc);
+}
+
+static void yagl_dri3_drawable_set_swap_interval(struct yagl_native_drawable *drawable,
+                                                 int interval)
+{
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_set_swap_interval);
+
+    YAGL_LOG_DEBUG("is_pixmap = %d, interval = %d",
+                   dri3_drawable->is_pixmap,
+                   interval);
+
+    if (dri3_drawable->is_pixmap) {
+        return;
+    }
+
+    dri3_drawable->swap_interval = interval;
+    yagl_dri3_update_num_back(dri3_drawable);
+}
+
+static void yagl_dri3_drawable_get_geometry(struct yagl_native_drawable *drawable,
+                                            uint32_t *width,
+                                            uint32_t *height,
+                                            uint32_t *depth)
+{
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_get_geometry);
+
+    YAGL_LOG_DEBUG("enter");
+
+    *width = dri3_drawable->width;
+    *height = dri3_drawable->height;
+    *depth = dri3_drawable->depth;
+}
+
+static struct yagl_native_image *yagl_dri3_drawable_get_image(struct yagl_native_drawable *drawable,
+                                                              uint32_t width,
+                                                              uint32_t height)
+{
+    return NULL;
+}
+
+static void yagl_dri3_drawable_destroy(struct yagl_native_drawable *drawable)
+{
+    struct yagl_dri3_drawable *dri3_drawable = (struct yagl_dri3_drawable *)drawable;
+    Display *x_dpy = YAGL_X11_DPY(drawable->dpy->os_dpy);
+    Drawable x_drawable = YAGL_X11_DRAWABLE(drawable->os_drawable);
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    int i;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_destroy);
+
+    YAGL_LOG_DEBUG("enter");
+
+    for (i = 0; i < DRI3_NUM_BUFFERS; i++) {
+        if (dri3_drawable->buffers[i]) {
+            yagl_dri3_free_render_buffer(dri3_drawable,
+                                         dri3_drawable->buffers[i]);
+        }
+    }
+
+    if (dri3_drawable->special_event) {
+        xcb_unregister_for_special_event(c, dri3_drawable->special_event);
+    }
+
+    if (dri3_drawable->gc) {
+        xcb_free_gc(c, dri3_drawable->gc);
+    }
+
+    if (dri3_drawable->own_drawable) {
+        if (dri3_drawable->is_pixmap) {
+            xcb_free_pixmap(c, x_drawable);
+        } else {
+            xcb_destroy_window(c, x_drawable);
+        }
+    }
+
+    yagl_native_drawable_cleanup(drawable);
+
+    yagl_free(dri3_drawable);
+}
+
+struct yagl_native_drawable *yagl_dri3_drawable_create(struct yagl_native_display *dpy,
+                                                       yagl_os_drawable os_drawable,
+                                                       int own_drawable,
+                                                       int is_pixmap)
+{
+    struct yagl_dri3_drawable *drawable;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_drawable_create);
+
+    drawable = yagl_malloc0(sizeof(*drawable));
+
+    if (!drawable) {
+        YAGL_LOG_ERROR("DRI3 Drawable object allocation failure %s",
+                       strerror(errno));
+        return NULL;
+    }
+
+    yagl_native_drawable_init(&drawable->base,
+                              dpy,
+                              os_drawable);
+
+    drawable->base.get_buffer = &yagl_dri3_drawable_get_buffer;
+    drawable->base.get_buffer_age = &yagl_dri3_drawable_get_buffer_age;
+    drawable->base.swap_buffers = &yagl_dri3_drawable_swap_buffers;
+    drawable->base.wait = &yagl_dri3_drawable_wait;
+    drawable->base.copy_to_pixmap = &yagl_dri3_drawable_copy_to_pixmap;
+    drawable->base.set_swap_interval = &yagl_dri3_drawable_set_swap_interval;
+    drawable->base.get_geometry = &yagl_dri3_drawable_get_geometry;
+    drawable->base.get_image = &yagl_dri3_drawable_get_image;
+    drawable->base.destroy = &yagl_dri3_drawable_destroy;
+
+    drawable->swap_interval = 1; /* default */
+    drawable->own_drawable = own_drawable;
+    drawable->is_pixmap = is_pixmap;
+
+    yagl_dri3_update_num_back(drawable);
+
+    YAGL_LOG_DEBUG("os_drawable = %p, is_pixmap = %d, own_drawable = %d",
+                   (void *)os_drawable,
+                   is_pixmap,
+                   own_drawable);
+
+    return &drawable->base;
+}
+
+static int yagl_dri3_display_check(Display *x_dpy)
+{
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    xcb_dri3_query_version_cookie_t dri3_cookie;
+    xcb_dri3_query_version_reply_t *dri3_reply;
+    xcb_present_query_version_cookie_t present_cookie;
+    xcb_present_query_version_reply_t *present_reply;
+    xcb_generic_error_t *error;
+    const xcb_query_extension_reply_t *extension;
+
+    YAGL_LOG_FUNC_SET(yagl_dri3_display_check);
+
+    xcb_prefetch_extension_data(c, &xcb_dri3_id);
+    xcb_prefetch_extension_data(c, &xcb_present_id);
+
+    extension = xcb_get_extension_data(c, &xcb_dri3_id);
+
+    if (!(extension && extension->present)) {
+        YAGL_LOG_DEBUG("dri3 extension not supported");
+        return 0;
+    }
+
+    extension = xcb_get_extension_data(c, &xcb_present_id);
+
+    if (!(extension && extension->present)) {
+        YAGL_LOG_DEBUG("present extension not supported");
+        return 0;
+    }
+
+    dri3_cookie = xcb_dri3_query_version(c,
+                                         XCB_DRI3_MAJOR_VERSION,
+                                         XCB_DRI3_MINOR_VERSION);
+
+
+    present_cookie = xcb_present_query_version(c,
+                                               XCB_PRESENT_MAJOR_VERSION,
+                                               XCB_PRESENT_MINOR_VERSION);
+
+    dri3_reply = xcb_dri3_query_version_reply(c, dri3_cookie, &error);
+
+    if (!dri3_reply) {
+        YAGL_LOG_DEBUG("dri3: version query failed");
+        free(error);
+        return 0;
+    }
+
+    YAGL_LOG_DEBUG("dri3: major = %d, minor = %d",
+                   dri3_reply->major_version,
+                   dri3_reply->minor_version);
+
+    free(dri3_reply);
+
+    present_reply = xcb_present_query_version_reply(c, present_cookie, &error);
+
+    if (!present_reply) {
+        YAGL_LOG_DEBUG("present: version query failed");
+        free(error);
+        return 0;
+    }
+
+    YAGL_LOG_DEBUG("present: major = %d, minor = %d",
+                   present_reply->major_version,
+                   present_reply->minor_version);
+
+    free(present_reply);
+
+    return 1;
+}
+
+int yagl_dri3_display_init(Display *x_dpy, char **dri_device)
+{
+    xcb_dri3_open_cookie_t cookie;
+    xcb_dri3_open_reply_t *reply;
+    xcb_connection_t *c = XGetXCBConnection(x_dpy);
+    int fd;
+
+    YAGL_LOG_FUNC_SET(yagl_x11_display_dri3_init);
+
+    if (!yagl_dri3_display_check(x_dpy)) {
+        YAGL_LOG_ERROR("Error: yagl_dri3_display_check failed\n");
+        return -1;
+    }
+
+    cookie = xcb_dri3_open(c, RootWindow(x_dpy, DefaultScreen(x_dpy)), None);
+
+    reply = xcb_dri3_open_reply(c, cookie, NULL);
+
+    if (!reply) {
+        YAGL_LOG_ERROR("Error: xcb_dri3_open_reply failed\n");
+        return -1;
+    }
+
+    if (reply->nfd != 1) {
+        YAGL_LOG_ERROR("Error: reply->nfd != 1 (%d)\n", reply->nfd);
+        free(reply);
+        return -1;
+    }
+
+    fd = xcb_dri3_open_reply_fds(c, reply)[0];
+    fcntl(fd, F_SETFD, FD_CLOEXEC);
+    *dri_device = drmGetDeviceNameFromFd(fd);
+
+    YAGL_LOG_DEBUG("dri3 display init: fd = %d, dri_device = %s",
+                   fd,
+                   *dri_device);
+
+    return fd;
+}
diff --git a/EGL/x11/yagl_dri3.h b/EGL/x11/yagl_dri3.h
new file mode 100644 (file)
index 0000000..2bb577b
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef _YAGL_DRI3_H_
+#define _YAGL_DRI3_H_
+
+#include <xcb/xcb.h>
+#include <xcb/dri3.h>
+#include <xcb/present.h>
+#include <xcb/sync.h>
+#include "yagl_native_drawable.h"
+
+enum yagl_dri3_buffer_type {
+    yagl_dri3_buffer_back = 0,
+    yagl_dri3_buffer_front = 1
+};
+
+struct vigs_drm_surface;
+
+struct yagl_dri3_buffer {
+    /* Pixmap ID */
+    uint32_t pixmap;
+
+    /* Buffer type: back / front */
+    enum yagl_dri3_buffer_type buffer_type;
+
+    /* Backing storage */
+    struct vigs_drm_surface *sfc;
+
+    /* Synchronization between the client and X server is done using an
+     * xshmfence that is mapped into an X server SyncFence. This lets the
+     * client check whether the X server is done using a buffer with a simple
+     * xshmfence call, rather than going to read X events from the wire.
+     *
+     * However, we can only wait for one xshmfence to be triggered at a time,
+     * so we need to know *which* buffer is going to be idle next. We do that
+     * by waiting for a PresentIdleNotify event. When that event arrives, the
+     * 'busy' flag gets cleared and the client knows that the fence has been
+     * triggered, and that the wait call will not block.
+     */
+
+    /* XID of X SyncFence object */
+    uint32_t sync_fence;
+
+    /* Pointer to xshmfence object */
+    struct xshmfence *shm_fence;
+
+    /* Set on swap, cleared on IdleNotify */
+    int busy;
+
+    /* We allocated the pixmap ID, free on destroy */
+    int own_pixmap;
+
+    uint32_t pitch;
+    uint32_t width, height;
+    uint64_t last_swap;
+};
+
+#define DRI3_MAX_BACK 4
+#define DRI3_BACK_ID(i) (i)
+#define DRI3_FRONT_ID (DRI3_MAX_BACK)
+#define DRI3_NUM_BUFFERS (1 + DRI3_MAX_BACK)
+
+struct yagl_dri3_drawable {
+    struct yagl_native_drawable base;
+
+    int width, height, depth;
+    int swap_interval;
+    uint8_t have_back;
+    uint8_t own_drawable;
+    uint8_t is_pixmap;
+    uint8_t flipping;
+
+    /* Present extension capabilities */
+    uint32_t present_capabilities;
+
+    /* SBC numbers are tracked by using the serial numbers
+     * in the present request and complete events */
+    uint64_t send_sbc;
+    uint64_t recv_sbc;
+
+    /* Last received UST/MSC values for pixmap present complete */
+    uint64_t ust, msc;
+
+    /* Last received UST/MSC values from present notify msc event */
+    uint64_t notify_ust, notify_msc;
+
+    /* Serial numbers for tracking wait_for_msc events */
+    uint32_t send_msc_serial;
+    uint32_t recv_msc_serial;
+
+    struct yagl_dri3_buffer *buffers[DRI3_NUM_BUFFERS];
+    int cur_back;
+    int num_back;
+
+    xcb_present_event_t eid;
+    xcb_gcontext_t gc;
+    xcb_special_event_t *special_event;
+};
+
+int yagl_dri3_display_init(Display *x_dpy, char **dri_device);
+
+struct yagl_native_drawable *yagl_dri3_drawable_create(struct yagl_native_display *dpy,
+                                                       yagl_os_drawable os_drawable,
+                                                       int own_drawable,
+                                                       int is_pixmap);
+
+GC yagl_dri3_drawable_get_gc(struct yagl_native_drawable *drawable);
+
+#endif /* _YAGL_DRI3_H_ */
index 87016e1..5d6ad98 100644 (file)
 #include "yagl_x11_display.h"
 #include "yagl_x11_drawable.h"
 #include "yagl_x11_image.h"
+#include "yagl_native_platform.h"
 #include "yagl_log.h"
 #include "yagl_malloc.h"
 #include "yagl_dri2.h"
+#include "yagl_dri3.h"
 #include "vigs.h"
 #include <X11/Xutil.h>
 #include <X11/extensions/XShm.h>
@@ -137,23 +139,32 @@ out:
 static int yagl_x11_display_authenticate(struct yagl_native_display *dpy,
                                          uint32_t id)
 {
+    struct yagl_x11_display *x11_dpy = (struct yagl_x11_display*)dpy;
     Display *x_dpy = YAGL_X11_DPY(dpy->os_dpy);
 
-    return yagl_x11_display_dri2_authenticate(x_dpy, id);
+    if (!x11_dpy->dri3_supported) {
+        return yagl_x11_display_dri2_authenticate(x_dpy, id);
+    }
+
+    return 1;
 }
 
 static struct yagl_native_drawable
     *yagl_x11_display_wrap_window(struct yagl_native_display *dpy,
                                   yagl_os_window os_window)
 {
-    return yagl_x11_drawable_create(dpy, os_window, 0, 0);
+    struct yagl_x11_display *x11_dpy = (struct yagl_x11_display*)dpy;
+
+    return x11_dpy->create_drawable(dpy, os_window, 0, 0);
 }
 
 static struct yagl_native_drawable
     *yagl_x11_display_wrap_pixmap(struct yagl_native_display *dpy,
                                   yagl_os_pixmap os_pixmap)
 {
-    return yagl_x11_drawable_create(dpy, os_pixmap, 0, 1);
+    struct yagl_x11_display *x11_dpy = (struct yagl_x11_display*)dpy;
+
+    return x11_dpy->create_drawable(dpy, os_pixmap, 0, 1);
 }
 
 static struct yagl_native_drawable
@@ -162,6 +173,7 @@ static struct yagl_native_drawable
                                     uint32_t height,
                                     uint32_t depth)
 {
+    struct yagl_x11_display *x11_dpy = (struct yagl_x11_display*)dpy;
     struct yagl_native_drawable *drawable;
     Display *x_dpy = YAGL_X11_DPY(dpy->os_dpy);
     Pixmap x_pixmap = XCreatePixmap(x_dpy,
@@ -172,7 +184,7 @@ static struct yagl_native_drawable
         return NULL;
     }
 
-    drawable = yagl_x11_drawable_create(dpy, (yagl_os_pixmap)x_pixmap, 1, 1);
+    drawable = x11_dpy->create_drawable(dpy, (yagl_os_pixmap)x_pixmap, 1, 1);
 
     if (!drawable) {
         XFreePixmap(x_dpy, x_pixmap);
@@ -266,12 +278,24 @@ struct yagl_native_display *yagl_x11_display_create(struct yagl_native_platform
                    xminor,
                    pixmaps);
 
+    dpy->create_drawable = &yagl_x11_drawable_create;
+
     if (enable_drm) {
-        int drm_fd = yagl_x11_display_dri2_init(x_dpy, &dri_device);
+        int drm_fd = yagl_dri3_display_init(x_dpy, &dri_device);
 
         if (drm_fd < 0) {
-            yagl_free(dpy);
-            return NULL;
+            YAGL_LOG_DEBUG("DRI3 init failed. Falling back to DRI2...");
+
+            drm_fd = yagl_x11_display_dri2_init(x_dpy, &dri_device);
+
+            if (drm_fd < 0) {
+                yagl_free(dpy);
+                return NULL;
+            }
+        } else {
+            dpy->create_drawable = &yagl_dri3_drawable_create;
+            dpy->dri3_supported = 1;
+            platform->buffer_age_supported = 1;
         }
 
         ret = vigs_drm_device_create(drm_fd, &drm_dev);
index af79e90..592c5f7 100644 (file)
@@ -48,6 +48,13 @@ struct yagl_x11_display
     int xshm_images_supported;
 
     int xshm_pixmaps_supported;
+
+    int dri3_supported;
+
+    struct yagl_native_drawable *(*create_drawable)(struct yagl_native_display */*dpy*/,
+                                                    yagl_os_drawable /*os_drawable*/,
+                                                    int /*own_drawable*/,
+                                                    int /*is_pixmap*/);
 };
 
 struct yagl_native_display *yagl_x11_display_create(struct yagl_native_platform *platform,
index 3804820..c845109 100644 (file)
@@ -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,15 @@ 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_image *(*create_image_tizen_sfc)(struct yagl_display */*dpy*/,
+                                                 EGLClientBuffer /*buffer*/,
+                                                 struct yagl_client_interface */*iface*/);
+
     struct yagl_fence *(*create_fence)(struct yagl_display */*dpy*/);
 
     void (*destroy)(struct yagl_backend */*backend*/);
index 775d1d6..9a9ef7b 100644 (file)
 
 #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_TIZEN_EXTENSIONS "EGL_TIZEN_image_native_surface "
+
 #define YAGL_EGL_BUFFER_AGE_EXTENSIONS "EGL_EXT_buffer_age "
 
 #define YAGL_EGL_FENCE_EXTENSIONS "EGL_KHR_fence_sync "
@@ -306,6 +310,10 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy)
             len += strlen(YAGL_EGL_FENCE_EXTENSIONS);
         }
 
+        len += strlen(YAGL_EGL_GL_TEXTURE_EXTENSIONS);
+
+        len += strlen(YAGL_EGL_TIZEN_EXTENSIONS);
+
         dpy->extensions = yagl_malloc(len + 1);
 
         strcpy(dpy->extensions, YAGL_EGL_BASE_EXTENSIONS);
@@ -325,6 +333,10 @@ 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);
+
+        strcat(dpy->extensions, YAGL_EGL_TIZEN_EXTENSIONS);
     }
 
     pthread_mutex_unlock(&dpy->mutex);
index 00da0d8..138488d 100644 (file)
@@ -1396,6 +1396,8 @@ YAGL_API EGLBoolean eglQueryContext(EGLDisplay dpy_,
         goto out;
     }
 
+    res = EGL_TRUE;
+
     switch (attribute) {
     case EGL_CONTEXT_CLIENT_TYPE:
         switch (ctx->client_ctx->client_api) {
@@ -1628,8 +1630,12 @@ out:
     return res;
 }
 
+#ifndef EGL_NATIVE_SURFACE_TIZEN
+#define EGL_NATIVE_SURFACE_TIZEN 0x32A1
+#endif
+
 YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_,
-                                       EGLContext ctx,
+                                       EGLContext ctx_,
                                        EGLenum target,
                                        EGLClientBuffer buffer,
                                        const EGLint *attrib_list)
@@ -1637,6 +1643,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;
@@ -1644,7 +1651,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);
 
@@ -1732,6 +1739,60 @@ 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;
+    case EGL_NATIVE_SURFACE_TIZEN:
+        if (attrib_list) {
+            while (attrib_list[i] != EGL_NONE) {
+                switch (attrib_list[i]) {
+                case EGL_IMAGE_PRESERVED_KHR:
+                    break;
+                default:
+                    YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
+                    goto out;
+                }
+
+                i += 2;
+            }
+        }
+
+        image = yagl_get_backend()->create_image_tizen_sfc(dpy,
+                                                           buffer,
+                                                           iface);
+
+        if (!image) {
+            goto out;
+        }
+
+        break;
     default:
         YAGL_SET_ERR(EGL_BAD_PARAMETER);
         goto out;
@@ -1747,6 +1808,8 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_,
 out:
     yagl_image_release(image);
 
+    yagl_context_release(ctx);
+
     YAGL_LOG_FUNC_EXIT("%p", ret);
 
     return ret;
index 90fabea..0bdbaf3 100644 (file)
@@ -12,7 +12,7 @@ EGLBoolean eglReleaseThread(EGLint &error)
 EGLBoolean eglSurfaceAttrib(yagl_host_handle dpy, yagl_host_handle surface, EGLint attribute, EGLint value, EGLint &error)
 yagl_host_handle eglCreateContext(yagl_host_handle dpy, yagl_host_handle config, yagl_host_handle share_context, const EGLint *attrib_list, EGLint &error)
 EGLBoolean eglDestroyContext(yagl_host_handle dpy, yagl_host_handle ctx, EGLint &error)
-void eglMakeCurrent(yagl_host_handle dpy, yagl_host_handle draw, yagl_host_handle read, yagl_host_handle ctx)
+@void eglMakeCurrent(yagl_host_handle dpy, yagl_host_handle draw, yagl_host_handle read, yagl_host_handle ctx)
 EGLBoolean eglQueryContext(yagl_host_handle dpy, yagl_host_handle ctx, EGLint attribute, EGLint &value, EGLint &error)
 @void eglSwapBuffers(yagl_host_handle dpy, yagl_host_handle surface)
 @void eglCopyBuffers(yagl_host_handle dpy, yagl_host_handle surface)
index 2d96afc..096dca9 100644 (file)
@@ -82,11 +82,7 @@ void *yagl_get_gles1_sym(const char *name)
 void *yagl_get_gles2_sym(const char *name)
 {
     void *handle;
-    void *sym = dlsym(NULL, name);
-
-    if (sym) {
-        return sym;
-    }
+    void *sym = NULL;
 
     handle = dlopen("libGLESv2.so.1", RTLD_NOW|RTLD_GLOBAL);
     if (!handle) {
@@ -94,10 +90,14 @@ void *yagl_get_gles2_sym(const char *name)
     }
 
     if (handle) {
-        return dlsym(handle, name);
+        sym = dlsym(handle, name);
     }
 
-    return NULL;
+    if (!sym) {
+        sym = dlsym(NULL, name);
+    }
+
+    return sym;
 }
 
 static void yagl_egl_state_free(void* ptr)
index 8070c46..766748a 100644 (file)
@@ -265,6 +265,7 @@ void yagl_host_eglMakeCurrent(yagl_host_handle dpy, yagl_host_handle draw, yagl_
     yagl_transport_put_out_yagl_host_handle(t, read);
     yagl_transport_put_out_yagl_host_handle(t, ctx);
     yagl_transport_end(t);
+    yagl_transport_flush(t, NULL);
 }
 
 /*
index ee0db2f..5cbb012 100644 (file)
@@ -38,6 +38,7 @@
 #include "wayland-drm.h"
 #endif
 #include "vigs.h"
+#include "EGL/eglext.h"
 #include "EGL/eglmesaext.h"
 #include <string.h>
 #include <stdlib.h>
index 4bb21fa..5adadf0 100644 (file)
@@ -134,6 +134,23 @@ 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_image
+    *yagl_offscreen_create_image_tizen_sfc(struct yagl_display *dpy,
+                                           EGLClientBuffer buffer,
+                                           struct yagl_client_interface *iface)
+{
+    return NULL;
+}
+
 static struct yagl_fence
     *yagl_offscreen_create_fence(struct yagl_display *dpy)
 {
@@ -157,6 +174,8 @@ 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_image_tizen_sfc = &yagl_offscreen_create_image_tizen_sfc;
     backend->create_fence = &yagl_offscreen_create_fence;
     backend->destroy = &yagl_offscreen_destroy;
     backend->y_inverted = 1;
index 8fd1f38..7ad8d06 100644 (file)
@@ -37,6 +37,8 @@
 #ifdef YAGL_PLATFORM_WAYLAND
 #include "yagl_onscreen_image_wl_buffer.h"
 #endif
+#include "yagl_onscreen_image_gl_texture_2d.h"
+#include "yagl_onscreen_image_tizen_sfc.h"
 #include "yagl_onscreen_fence.h"
 #include "yagl_backend.h"
 #include "yagl_malloc.h"
@@ -147,6 +149,29 @@ 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_image
+    *yagl_onscreen_create_image_tizen_sfc(struct yagl_display *dpy,
+                                          EGLClientBuffer buffer,
+                                          struct yagl_client_interface *iface)
+{
+    struct yagl_onscreen_image_tizen_sfc *image =
+        yagl_onscreen_image_tizen_sfc_create(dpy, buffer, iface);
+
+    return image ? &image->base: NULL;
+}
+
 static struct yagl_fence
     *yagl_onscreen_create_fence(struct yagl_display *dpy)
 {
@@ -172,6 +197,8 @@ 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_image_tizen_sfc = &yagl_onscreen_create_image_tizen_sfc;
     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 (file)
index 0000000..340b5f1
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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_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;
+
+    image = yagl_malloc0(sizeof(*image));
+
+    client_image = iface->wrap_texture(iface,
+                                       ctx->client_ctx,
+                                       texture);
+
+    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;
+
+    return image;
+
+fail:
+    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 (file)
index 0000000..6e43b37
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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_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/EGL/yagl_onscreen_image_tizen_sfc.c b/EGL/yagl_onscreen_image_tizen_sfc.c
new file mode 100644 (file)
index 0000000..4eaab32
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * 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_tizen_sfc.h"
+#include "yagl_display.h"
+#include "yagl_log.h"
+#include "yagl_malloc.h"
+#include "yagl_host_egl_calls.h"
+#include "yagl_egl_state.h"
+#include "yagl_state.h"
+#include "yagl_client_interface.h"
+#include "yagl_client_image.h"
+#include "vigs.h"
+#include <tbm_bufmgr.h>
+#include <tbm_bufmgr_backend.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+static void yagl_onscreen_image_tizen_sfc_update(struct yagl_image *image)
+{
+}
+
+static void yagl_onscreen_image_tizen_sfc_destroy(struct yagl_ref *ref)
+{
+    struct yagl_onscreen_image_tizen_sfc *image = (struct yagl_onscreen_image_tizen_sfc *)ref;
+
+    vigs_drm_gem_unref(&image->drm_sfc->gem);
+
+    yagl_image_cleanup(&image->base);
+
+    yagl_free(image);
+}
+
+
+struct yagl_onscreen_image_tizen_sfc
+    *yagl_onscreen_image_tizen_sfc_create(struct yagl_display *dpy,
+                                          EGLClientBuffer buffer,
+                                          struct yagl_client_interface *iface)
+{
+    EGLint error = 0;
+    yagl_object_name tex_global_name = yagl_get_global_name();
+    struct yagl_client_image *client_image;
+    struct yagl_onscreen_image_tizen_sfc *image;
+    struct vigs_drm_surface *drm_sfc;
+    tbm_surface_h sfc;
+    tbm_bo bo;
+
+    image = yagl_malloc0(sizeof(*image));
+
+    sfc = (tbm_surface_h)buffer;
+    bo = tbm_surface_internal_get_bo(sfc, 0);
+    drm_sfc = bo ? tbm_backend_get_bo_priv(bo) : NULL;
+
+    if (!drm_sfc || (tbm_surface_internal_get_num_bos(sfc) != 1)) {
+        yagl_set_error(EGL_BAD_PARAMETER);
+        goto fail;
+    }
+
+    vigs_drm_gem_ref(&drm_sfc->gem);
+
+    if (!yagl_host_eglCreateImageYAGL(tex_global_name,
+                                      dpy->host_dpy,
+                                      drm_sfc->id,
+                                      &error)) {
+        yagl_set_error(error);
+        goto fail;
+    }
+
+    client_image = iface->create_image(iface, tex_global_name);
+
+    yagl_image_init(&image->base,
+                    &yagl_onscreen_image_tizen_sfc_destroy,
+                    dpy,
+                    (EGLImageKHR)drm_sfc->gem.name,
+                    client_image);
+
+    yagl_client_image_release(client_image);
+
+    image->base.update = &yagl_onscreen_image_tizen_sfc_update;
+    image->drm_sfc = drm_sfc;
+
+    return image;
+
+fail:
+    if (drm_sfc) {
+        vigs_drm_gem_unref(&drm_sfc->gem);
+    }
+
+    yagl_free(image);
+
+    return NULL;
+}
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.h b/EGL/yagl_onscreen_image_tizen_sfc.h
new file mode 100644 (file)
index 0000000..d07eb69
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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_TIZEN_SFC_H_
+#define _YAGL_ONSCREEN_IMAGE_TIZEN_SFC_H_
+
+#include "yagl_image.h"
+#include "EGL/egl.h"
+
+struct yagl_client_interface;
+struct vigs_drm_surface;
+
+struct yagl_onscreen_image_tizen_sfc
+{
+    struct yagl_image base;
+
+    struct vigs_drm_surface *drm_sfc;
+};
+
+struct yagl_onscreen_image_tizen_sfc
+    *yagl_onscreen_image_tizen_sfc_create(struct yagl_display *dpy,
+                                          EGLClientBuffer buffer,
+                                          struct yagl_client_interface *iface);
+
+#endif
index 7a8be78..f25a103 100644 (file)
@@ -2243,6 +2243,11 @@ YAGL_API void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLs
         goto out;
     }
 
+    if (squashed_target == GL_TEXTURE_CUBE_MAP && width != height) {
+        YAGL_SET_ERR(GL_INVALID_VALUE);
+        goto out;
+    }
+
     tex_target_state =
         yagl_gles_context_get_active_texture_target_state(ctx, texture_target);
 
index 294bf87..ce21c1f 100644 (file)
@@ -181,7 +181,7 @@ void glGetTransformFeedbackVaryings(GLuint program, GLsizei *sizes, GLenum *type
 void glGenQueries(const GLuint *ids)
 void glBeginQuery(GLenum target, GLuint id)
 void glEndQuery(GLenum target)
-GLboolean glGetQueryObjectuiv(GLuint id, GLuint &result)
+GLboolean glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint &result)
 # Samplers
 void glGenSamplers(const GLuint *samplers)
 void glBindSampler(GLuint unit, GLuint sampler)
index bdd81a0..7139f36 100644 (file)
@@ -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,11 @@ 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->texture_obj) {
+        yagl_gles_texture_release(image->texture_obj);
+    } else {
+        yagl_host_glDeleteObjects(&image->tex_global_name, 1);
+    }
 
     yagl_client_image_cleanup(&image->base);
 
@@ -78,6 +85,37 @@ struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name)
     return image;
 }
 
+struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx,
+                                                 yagl_object_name tex_local_name)
+{
+    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->texture_obj = texture_obj;
+
+    return image;
+
+fail:
+    yagl_gles_texture_release(texture_obj);
+
+    return NULL;
+}
+
 void yagl_gles_image_acquire(struct yagl_gles_image *image)
 {
     if (image) {
index ece73a3..83436f4 100644 (file)
 #include "yagl_types.h"
 #include "yagl_client_image.h"
 
+struct yagl_gles_texture;
+struct yagl_client_context;
+
 struct yagl_gles_image
 {
     struct yagl_client_image base;
 
     yagl_object_name tex_global_name;
+
+    /*
+     * Non-NULL if the image wraps this texture object
+     */
+    struct yagl_gles_texture *texture_obj;
 };
 
 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);
+
 /*
  * Passing NULL won't hurt, this is for convenience.
  */
index 28e5197..de6eb38 100644 (file)
@@ -406,7 +406,7 @@ static void yagl_convert_bgra_hf_luminance_alpha_hf(const GLvoid *src,
 }
 
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA, GL_UNSIGNED_BYTE, 1);
-YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_ALPHA, GL_ALPHA, GL_FLOAT, GL_ALPHA, GL_FLOAT, 4);
+YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_ALPHA, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_ARB, GL_FLOAT, 4);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA, GL_HALF_FLOAT, 2);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA, GL_HALF_FLOAT, 2);
 
@@ -452,25 +452,25 @@ YAGL_PIXEL_FORMAT_IMPL_END()
 
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, GL_UNSIGNED_BYTE, 3);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2);
-YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGB, GL_RGB, GL_FLOAT, GL_RGB, GL_FLOAT, 12);
+YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGB, GL_RGB, GL_FLOAT, GL_RGB32F, GL_FLOAT, 12);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGB, GL_RGB, GL_HALF_FLOAT, GL_RGB, GL_HALF_FLOAT, 6);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGB, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB, GL_HALF_FLOAT, 6);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, GL_UNSIGNED_BYTE, 4);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2);
-YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_FLOAT, GL_RGBA, GL_FLOAT, 16);
+YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_FLOAT, GL_RGBA32F, GL_FLOAT, 16);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_HALF_FLOAT, GL_RGBA, GL_HALF_FLOAT, 8);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_RGBA, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA, GL_HALF_FLOAT, 8);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, GL_UNSIGNED_BYTE, 4);
-YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_BGRA, GL_BGRA, GL_FLOAT, GL_RGBA, GL_FLOAT, 16);
+YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_BGRA, GL_BGRA, GL_FLOAT, GL_RGBA32F, GL_FLOAT, 16);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_BGRA, GL_BGRA, GL_HALF_FLOAT, GL_RGBA, GL_HALF_FLOAT, 8);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles, GL_BGRA, GL_BGRA, GL_HALF_FLOAT_OES, GL_RGBA, GL_HALF_FLOAT, 8);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 1);
-YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE, GL_FLOAT, 4);
+YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_ARB, GL_FLOAT, 4);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE, GL_HALF_FLOAT, 2);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE, GL_HALF_FLOAT, 2);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 2);
-YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA, GL_FLOAT, 8);
+YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_ARB, GL_FLOAT, 8);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, 4);
 YAGL_PIXEL_FORMAT_IMPL_NOCONV(gles_gl2, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, 4);
 
index 2329760..0e606ab 100644 (file)
@@ -2538,13 +2538,14 @@ void yagl_host_glEndQuery(GLenum target)
 /*
  * glGetQueryObjectuiv wrapper. id = 173
  */
-GLboolean yagl_host_glGetQueryObjectuiv(GLuint id, GLuint *result)
+GLboolean yagl_host_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *result)
 {
     struct yagl_transport *t = yagl_get_transport();
     GLboolean retval = 0;
 
-    yagl_transport_begin(t, yagl_api_id_gles, 173, 5 * 8, 5 * 8);
+    yagl_transport_begin(t, yagl_api_id_gles, 173, 6 * 8, 6 * 8);
     yagl_transport_put_out_GLuint(t, id);
+    yagl_transport_put_out_GLenum(t, pname);
     yagl_transport_put_in_GLuint(t, result);
     yagl_transport_put_in_GLboolean(t, &retval);
     yagl_transport_end(t);
index f2b876e..7d8ff00 100644 (file)
@@ -870,7 +870,7 @@ void yagl_host_glEndQuery(GLenum target);
 /*
  * glGetQueryObjectuiv wrapper. id = 173
  */
-GLboolean yagl_host_glGetQueryObjectuiv(GLuint id, GLuint *result);
+GLboolean yagl_host_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *result);
 
 /*
  * glGenSamplers wrapper. id = 174
index 93e3a00..b8bcdfb 100644 (file)
@@ -52,6 +52,14 @@ 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)
+{
+    return &yagl_gles_image_wrap_tex(ctx,tex_local_name)->base;
+}
+
 static void yagl_gles1_release_tex_image(struct yagl_client_interface *iface,
                                          void *cookie)
 {
@@ -64,5 +72,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
 };
index 67ce9f0..6d4bb24 100644 (file)
@@ -2064,6 +2064,11 @@ YAGL_API void glUseProgram(GLuint program)
             YAGL_SET_ERR(GL_INVALID_OPERATION);
             goto out;
         }
+
+        if (!program_obj->linked) {
+            YAGL_SET_ERR(GL_INVALID_OPERATION);
+            goto out;
+        }
     }
 
     if (!ctx->pre_use_program(ctx, program_obj)) {
index 39d902f..515d5f2 100644 (file)
@@ -574,7 +574,7 @@ void yagl_gles2_context_pre_draw(struct yagl_gles2_context *ctx,
      */
 
     if (mode == GL_POINTS) {
-        if (yagl_get_host_gl_version() <= yagl_gl_2) {
+        if (yagl_get_host_gl_version() <= yagl_gl_3_2) {
             yagl_host_glEnable(GL_POINT_SPRITE);
         }
         yagl_host_glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
@@ -587,7 +587,7 @@ void yagl_gles2_context_post_draw(struct yagl_gles2_context *ctx,
 {
     if (mode == GL_POINTS) {
         yagl_host_glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
-        if (yagl_get_host_gl_version() <= yagl_gl_2) {
+        if (yagl_get_host_gl_version() <= yagl_gl_3_2) {
             yagl_host_glDisable(GL_POINT_SPRITE);
         }
     }
index be48b1f..ab17f7a 100644 (file)
@@ -60,6 +60,14 @@ 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)
+{
+    return &yagl_gles_image_wrap_tex(ctx, tex_local_name)->base;
+}
+
 static void yagl_gles2_release_tex_image(struct yagl_client_interface *iface,
                                          void *cookie)
 {
@@ -72,5 +80,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
 };
index 3609955..e5dd335 100644 (file)
@@ -327,7 +327,7 @@ void yagl_gles2_program_link(struct yagl_gles2_program *program)
                             sizeof(params)/sizeof(params[0]),
                             NULL);
 
-    program->linked = 1;
+    program->linked = params[0];
 
     program->link_status = params[0];
     program->info_log_length = params[1];
index cf87e62..39fb898 100644 (file)
 #include "yagl_state.h"
 #include "yagl_host_gles_calls.h"
 
-static void yagl_gles3_query_update_result(struct yagl_gles3_query *query)
+static void yagl_gles3_query_update_result(struct yagl_gles3_query *query, GLenum pname)
 {
     if (!query->result_available) {
         query->result_available =
-            yagl_host_glGetQueryObjectuiv(query->global_name, &query->result);
+            yagl_host_glGetQueryObjectuiv(query->global_name, pname, &query->result);
     }
 }
 
@@ -106,14 +106,14 @@ void yagl_gles3_query_end(struct yagl_gles3_query *query,
 
 int yagl_gles3_query_is_result_available(struct yagl_gles3_query *query)
 {
-    yagl_gles3_query_update_result(query);
+    yagl_gles3_query_update_result(query, GL_QUERY_RESULT_AVAILABLE);
 
     return query->result_available;
 }
 
 GLuint yagl_gles3_query_get_result(struct yagl_gles3_query *query)
 {
-    yagl_gles3_query_update_result(query);
+    yagl_gles3_query_update_result(query, GL_QUERY_RESULT);
 
     return query->result;
 }
index 99ea342..0d514e4 100644 (file)
@@ -1,11 +1,12 @@
-/* -*- mode: c; tab-width: 8; -*- */
-/* vi: set sw=4 ts=8: */
-/* Reference version of egl.h for EGL 1.4.
- * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
- */
+#ifndef __egl_h_
+#define __egl_h_ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
-** Copyright (c) 2007-2009 The Khronos Group Inc.
+** Copyright (c) 2013-2014 The Khronos Group Inc.
 **
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 */
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+**   http://www.opengl.org/registry/
+**
+** Khronos $Revision: 31039 $ on $Date: 2015-05-04 17:01:57 -0700 (Mon, 04 May 2015) $
+*/
 
-#ifndef __egl_h_
-#define __egl_h_
-
-/* All platform-dependent types and macro boilerplate (such as EGLAPI
- * and EGLAPIENTRY) should go in eglplatform.h.
- */
 #include <EGL/eglplatform.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* Generated on date 20150504 */
+
+/* Generated C header for:
+ * API: egl
+ * Versions considered: .*
+ * Versions emitted: .*
+ * Default extensions included: None
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
 
-/* EGL Types */
-/* EGLint is defined in eglplatform.h */
+#ifndef EGL_VERSION_1_0
+#define EGL_VERSION_1_0 1
 typedef unsigned int EGLBoolean;
-typedef unsigned int EGLenum;
-typedef void *EGLConfig;
-typedef void *EGLContext;
 typedef void *EGLDisplay;
+#include <KHR/khrplatform.h>
+#include <EGL/eglplatform.h>
+typedef void *EGLConfig;
 typedef void *EGLSurface;
-typedef void *EGLClientBuffer;
-
-/* EGL Versioning */
-#define EGL_VERSION_1_0                        1
-#define EGL_VERSION_1_1                        1
-#define EGL_VERSION_1_2                        1
-#define EGL_VERSION_1_3                        1
-#define EGL_VERSION_1_4                        1
-
-/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
- * enums are assigned unique values starting at 0x3000.
- */
-
-/* EGL aliases */
-#define EGL_FALSE                      0
-#define EGL_TRUE                       1
-
-/* Out-of-band handle values */
-#define EGL_DEFAULT_DISPLAY            ((EGLNativeDisplayType)0)
-#define EGL_NO_CONTEXT                 ((EGLContext)0)
-#define EGL_NO_DISPLAY                 ((EGLDisplay)0)
-#define EGL_NO_SURFACE                 ((EGLSurface)0)
-
-/* Out-of-band attribute value */
-#define EGL_DONT_CARE                  ((EGLint)-1)
-
-/* Errors / GetError return values */
-#define EGL_SUCCESS                    0x3000
-#define EGL_NOT_INITIALIZED            0x3001
-#define EGL_BAD_ACCESS                 0x3002
-#define EGL_BAD_ALLOC                  0x3003
-#define EGL_BAD_ATTRIBUTE              0x3004
-#define EGL_BAD_CONFIG                 0x3005
-#define EGL_BAD_CONTEXT                        0x3006
-#define EGL_BAD_CURRENT_SURFACE                0x3007
-#define EGL_BAD_DISPLAY                        0x3008
-#define EGL_BAD_MATCH                  0x3009
-#define EGL_BAD_NATIVE_PIXMAP          0x300A
-#define EGL_BAD_NATIVE_WINDOW          0x300B
-#define EGL_BAD_PARAMETER              0x300C
-#define EGL_BAD_SURFACE                        0x300D
-#define EGL_CONTEXT_LOST               0x300E  /* EGL 1.1 - IMG_power_management */
-
-/* Reserved 0x300F-0x301F for additional errors */
-
-/* Config attributes */
-#define EGL_BUFFER_SIZE                        0x3020
-#define EGL_ALPHA_SIZE                 0x3021
-#define EGL_BLUE_SIZE                  0x3022
-#define EGL_GREEN_SIZE                 0x3023
-#define EGL_RED_SIZE                   0x3024
-#define EGL_DEPTH_SIZE                 0x3025
-#define EGL_STENCIL_SIZE               0x3026
-#define EGL_CONFIG_CAVEAT              0x3027
-#define EGL_CONFIG_ID                  0x3028
-#define EGL_LEVEL                      0x3029
-#define EGL_MAX_PBUFFER_HEIGHT         0x302A
-#define EGL_MAX_PBUFFER_PIXELS         0x302B
-#define EGL_MAX_PBUFFER_WIDTH          0x302C
-#define EGL_NATIVE_RENDERABLE          0x302D
-#define EGL_NATIVE_VISUAL_ID           0x302E
-#define EGL_NATIVE_VISUAL_TYPE         0x302F
-#define EGL_SAMPLES                    0x3031
-#define EGL_SAMPLE_BUFFERS             0x3032
-#define EGL_SURFACE_TYPE               0x3033
-#define EGL_TRANSPARENT_TYPE           0x3034
-#define EGL_TRANSPARENT_BLUE_VALUE     0x3035
-#define EGL_TRANSPARENT_GREEN_VALUE    0x3036
-#define EGL_TRANSPARENT_RED_VALUE      0x3037
-#define EGL_NONE                       0x3038  /* Attrib list terminator */
-#define EGL_BIND_TO_TEXTURE_RGB                0x3039
-#define EGL_BIND_TO_TEXTURE_RGBA       0x303A
-#define EGL_MIN_SWAP_INTERVAL          0x303B
-#define EGL_MAX_SWAP_INTERVAL          0x303C
-#define EGL_LUMINANCE_SIZE             0x303D
-#define EGL_ALPHA_MASK_SIZE            0x303E
-#define EGL_COLOR_BUFFER_TYPE          0x303F
-#define EGL_RENDERABLE_TYPE            0x3040
-#define EGL_MATCH_NATIVE_PIXMAP                0x3041  /* Pseudo-attribute (not queryable) */
-#define EGL_CONFORMANT                 0x3042
-
-/* Reserved 0x3041-0x304F for additional config attributes */
-
-/* Config attribute values */
-#define EGL_SLOW_CONFIG                        0x3050  /* EGL_CONFIG_CAVEAT value */
-#define EGL_NON_CONFORMANT_CONFIG      0x3051  /* EGL_CONFIG_CAVEAT value */
-#define EGL_TRANSPARENT_RGB            0x3052  /* EGL_TRANSPARENT_TYPE value */
-#define EGL_RGB_BUFFER                 0x308E  /* EGL_COLOR_BUFFER_TYPE value */
-#define EGL_LUMINANCE_BUFFER           0x308F  /* EGL_COLOR_BUFFER_TYPE value */
-
-/* More config attribute values, for EGL_TEXTURE_FORMAT */
-#define EGL_NO_TEXTURE                 0x305C
-#define EGL_TEXTURE_RGB                        0x305D
-#define EGL_TEXTURE_RGBA               0x305E
-#define EGL_TEXTURE_2D                 0x305F
-
-/* Config attribute mask bits */
-#define EGL_PBUFFER_BIT                        0x0001  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_PIXMAP_BIT                 0x0002  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_WINDOW_BIT                 0x0004  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_VG_COLORSPACE_LINEAR_BIT   0x0020  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_VG_ALPHA_FORMAT_PRE_BIT    0x0040  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
-#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
-
-#define EGL_OPENGL_ES_BIT              0x0001  /* EGL_RENDERABLE_TYPE mask bits */
-#define EGL_OPENVG_BIT                 0x0002  /* EGL_RENDERABLE_TYPE mask bits */
-#define EGL_OPENGL_ES2_BIT             0x0004  /* EGL_RENDERABLE_TYPE mask bits */
-#define EGL_OPENGL_BIT                 0x0008  /* EGL_RENDERABLE_TYPE mask bits */
-
-/* QueryString targets */
-#define EGL_VENDOR                     0x3053
-#define EGL_VERSION                    0x3054
-#define EGL_EXTENSIONS                 0x3055
-#define EGL_CLIENT_APIS                        0x308D
-
-/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
-#define EGL_HEIGHT                     0x3056
-#define EGL_WIDTH                      0x3057
-#define EGL_LARGEST_PBUFFER            0x3058
-#define EGL_TEXTURE_FORMAT             0x3080
-#define EGL_TEXTURE_TARGET             0x3081
-#define EGL_MIPMAP_TEXTURE             0x3082
-#define EGL_MIPMAP_LEVEL               0x3083
-#define EGL_RENDER_BUFFER              0x3086
-#define EGL_VG_COLORSPACE              0x3087
-#define EGL_VG_ALPHA_FORMAT            0x3088
-#define EGL_HORIZONTAL_RESOLUTION      0x3090
-#define EGL_VERTICAL_RESOLUTION                0x3091
-#define EGL_PIXEL_ASPECT_RATIO         0x3092
-#define EGL_SWAP_BEHAVIOR              0x3093
-#define EGL_MULTISAMPLE_RESOLVE                0x3099
-
-/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
-#define EGL_BACK_BUFFER                        0x3084
-#define EGL_SINGLE_BUFFER              0x3085
-
-/* OpenVG color spaces */
-#define EGL_VG_COLORSPACE_sRGB         0x3089  /* EGL_VG_COLORSPACE value */
-#define EGL_VG_COLORSPACE_LINEAR       0x308A  /* EGL_VG_COLORSPACE value */
-
-/* OpenVG alpha formats */
-#define EGL_VG_ALPHA_FORMAT_NONPRE     0x308B  /* EGL_ALPHA_FORMAT value */
-#define EGL_VG_ALPHA_FORMAT_PRE                0x308C  /* EGL_ALPHA_FORMAT value */
-
-/* Constant scale factor by which fractional display resolutions &
- * aspect ratio are scaled when queried as integer values.
- */
-#define EGL_DISPLAY_SCALING            10000
-
-/* Unknown display resolution/aspect ratio */
-#define EGL_UNKNOWN                    ((EGLint)-1)
-
-/* Back buffer swap behaviors */
-#define EGL_BUFFER_PRESERVED           0x3094  /* EGL_SWAP_BEHAVIOR value */
-#define EGL_BUFFER_DESTROYED           0x3095  /* EGL_SWAP_BEHAVIOR value */
-
-/* CreatePbufferFromClientBuffer buffer types */
-#define EGL_OPENVG_IMAGE               0x3096
-
-/* QueryContext targets */
-#define EGL_CONTEXT_CLIENT_TYPE                0x3097
-
-/* CreateContext attributes */
-#define EGL_CONTEXT_CLIENT_VERSION     0x3098
-
-/* Multisample resolution behaviors */
-#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
-#define EGL_MULTISAMPLE_RESOLVE_BOX    0x309B  /* EGL_MULTISAMPLE_RESOLVE value */
-
-/* BindAPI/QueryAPI targets */
-#define EGL_OPENGL_ES_API              0x30A0
-#define EGL_OPENVG_API                 0x30A1
-#define EGL_OPENGL_API                 0x30A2
-
-/* GetCurrentSurface targets */
-#define EGL_DRAW                       0x3059
-#define EGL_READ                       0x305A
-
-/* WaitNative engines */
-#define EGL_CORE_NATIVE_ENGINE         0x305B
-
-/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
-#define EGL_COLORSPACE                 EGL_VG_COLORSPACE
-#define EGL_ALPHA_FORMAT               EGL_VG_ALPHA_FORMAT
-#define EGL_COLORSPACE_sRGB            EGL_VG_COLORSPACE_sRGB
-#define EGL_COLORSPACE_LINEAR          EGL_VG_COLORSPACE_LINEAR
-#define EGL_ALPHA_FORMAT_NONPRE                EGL_VG_ALPHA_FORMAT_NONPRE
-#define EGL_ALPHA_FORMAT_PRE           EGL_VG_ALPHA_FORMAT_PRE
-
-/* EGL extensions must request enum blocks from the Khronos
- * API Registrar, who maintains the enumerant registry. Submit
- * a bug in Khronos Bugzilla against task "Registry".
- */
-
-
-
-/* EGL Functions */
-
-EGLAPI EGLint EGLAPIENTRY eglGetError(void);
-
-EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
-EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
-EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
-
-EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
-                        EGLint config_size, EGLint *num_config);
-EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
-                          EGLConfig *configs, EGLint config_size,
-                          EGLint *num_config);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
-                             EGLint attribute, EGLint *value);
-
-EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
-                                 EGLNativeWindowType win,
-                                 const EGLint *attrib_list);
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
-                                  const EGLint *attrib_list);
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
-                                 EGLNativePixmapType pixmap,
-                                 const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
-EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
-                          EGLint attribute, EGLint *value);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
-EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
-
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
-             EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
-             EGLConfig config, const EGLint *attrib_list);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
-                           EGLint attribute, EGLint value);
-EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-
-
-EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
-
-
-EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
-                           EGLContext share_context,
-                           const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
-EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
-                         EGLSurface read, EGLContext ctx);
-
-EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
-EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
-EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
-                          EGLint attribute, EGLint *value);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
-EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
-EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
-EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
-                         EGLNativePixmapType target);
-
-/* This is a generic function pointer type, whose name indicates it must
- * be cast to the proper type *and calling convention* before use.
- */
+typedef void *EGLContext;
 typedef void (*__eglMustCastToProperFunctionPointerType)(void);
-
-/* Now, define eglGetProcAddress using the generic function ptr. type */
-EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
-       eglGetProcAddress(const char *procname);
+#define EGL_ALPHA_SIZE                    0x3021
+#define EGL_BAD_ACCESS                    0x3002
+#define EGL_BAD_ALLOC                     0x3003
+#define EGL_BAD_ATTRIBUTE                 0x3004
+#define EGL_BAD_CONFIG                    0x3005
+#define EGL_BAD_CONTEXT                   0x3006
+#define EGL_BAD_CURRENT_SURFACE           0x3007
+#define EGL_BAD_DISPLAY                   0x3008
+#define EGL_BAD_MATCH                     0x3009
+#define EGL_BAD_NATIVE_PIXMAP             0x300A
+#define EGL_BAD_NATIVE_WINDOW             0x300B
+#define EGL_BAD_PARAMETER                 0x300C
+#define EGL_BAD_SURFACE                   0x300D
+#define EGL_BLUE_SIZE                     0x3022
+#define EGL_BUFFER_SIZE                   0x3020
+#define EGL_CONFIG_CAVEAT                 0x3027
+#define EGL_CONFIG_ID                     0x3028
+#define EGL_CORE_NATIVE_ENGINE            0x305B
+#define EGL_DEPTH_SIZE                    0x3025
+#define EGL_DONT_CARE                     ((EGLint)-1)
+#define EGL_DRAW                          0x3059
+#define EGL_EXTENSIONS                    0x3055
+#define EGL_FALSE                         0
+#define EGL_GREEN_SIZE                    0x3023
+#define EGL_HEIGHT                        0x3056
+#define EGL_LARGEST_PBUFFER               0x3058
+#define EGL_LEVEL                         0x3029
+#define EGL_MAX_PBUFFER_HEIGHT            0x302A
+#define EGL_MAX_PBUFFER_PIXELS            0x302B
+#define EGL_MAX_PBUFFER_WIDTH             0x302C
+#define EGL_NATIVE_RENDERABLE             0x302D
+#define EGL_NATIVE_VISUAL_ID              0x302E
+#define EGL_NATIVE_VISUAL_TYPE            0x302F
+#define EGL_NONE                          0x3038
+#define EGL_NON_CONFORMANT_CONFIG         0x3051
+#define EGL_NOT_INITIALIZED               0x3001
+#define EGL_NO_CONTEXT                    ((EGLContext)0)
+#define EGL_NO_DISPLAY                    ((EGLDisplay)0)
+#define EGL_NO_SURFACE                    ((EGLSurface)0)
+#define EGL_PBUFFER_BIT                   0x0001
+#define EGL_PIXMAP_BIT                    0x0002
+#define EGL_READ                          0x305A
+#define EGL_RED_SIZE                      0x3024
+#define EGL_SAMPLES                       0x3031
+#define EGL_SAMPLE_BUFFERS                0x3032
+#define EGL_SLOW_CONFIG                   0x3050
+#define EGL_STENCIL_SIZE                  0x3026
+#define EGL_SUCCESS                       0x3000
+#define EGL_SURFACE_TYPE                  0x3033
+#define EGL_TRANSPARENT_BLUE_VALUE        0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE       0x3036
+#define EGL_TRANSPARENT_RED_VALUE         0x3037
+#define EGL_TRANSPARENT_RGB               0x3052
+#define EGL_TRANSPARENT_TYPE              0x3034
+#define EGL_TRUE                          1
+#define EGL_VENDOR                        0x3053
+#define EGL_VERSION                       0x3054
+#define EGL_WIDTH                         0x3057
+#define EGL_WINDOW_BIT                    0x0004
+EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
+EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void);
+EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw);
+EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id);
+EGLAPI EGLint EGLAPIENTRY eglGetError (void);
+EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
+EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
+EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy);
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void);
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine);
+#endif /* EGL_VERSION_1_0 */
+
+#ifndef EGL_VERSION_1_1
+#define EGL_VERSION_1_1 1
+#define EGL_BACK_BUFFER                   0x3084
+#define EGL_BIND_TO_TEXTURE_RGB           0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA          0x303A
+#define EGL_CONTEXT_LOST                  0x300E
+#define EGL_MIN_SWAP_INTERVAL             0x303B
+#define EGL_MAX_SWAP_INTERVAL             0x303C
+#define EGL_MIPMAP_TEXTURE                0x3082
+#define EGL_MIPMAP_LEVEL                  0x3083
+#define EGL_NO_TEXTURE                    0x305C
+#define EGL_TEXTURE_2D                    0x305F
+#define EGL_TEXTURE_FORMAT                0x3080
+#define EGL_TEXTURE_RGB                   0x305D
+#define EGL_TEXTURE_RGBA                  0x305E
+#define EGL_TEXTURE_TARGET                0x3081
+EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval);
+#endif /* EGL_VERSION_1_1 */
+
+#ifndef EGL_VERSION_1_2
+#define EGL_VERSION_1_2 1
+typedef unsigned int EGLenum;
+typedef void *EGLClientBuffer;
+#define EGL_ALPHA_FORMAT                  0x3088
+#define EGL_ALPHA_FORMAT_NONPRE           0x308B
+#define EGL_ALPHA_FORMAT_PRE              0x308C
+#define EGL_ALPHA_MASK_SIZE               0x303E
+#define EGL_BUFFER_PRESERVED              0x3094
+#define EGL_BUFFER_DESTROYED              0x3095
+#define EGL_CLIENT_APIS                   0x308D
+#define EGL_COLORSPACE                    0x3087
+#define EGL_COLORSPACE_sRGB               0x3089
+#define EGL_COLORSPACE_LINEAR             0x308A
+#define EGL_COLOR_BUFFER_TYPE             0x303F
+#define EGL_CONTEXT_CLIENT_TYPE           0x3097
+#define EGL_DISPLAY_SCALING               10000
+#define EGL_HORIZONTAL_RESOLUTION         0x3090
+#define EGL_LUMINANCE_BUFFER              0x308F
+#define EGL_LUMINANCE_SIZE                0x303D
+#define EGL_OPENGL_ES_BIT                 0x0001
+#define EGL_OPENVG_BIT                    0x0002
+#define EGL_OPENGL_ES_API                 0x30A0
+#define EGL_OPENVG_API                    0x30A1
+#define EGL_OPENVG_IMAGE                  0x3096
+#define EGL_PIXEL_ASPECT_RATIO            0x3092
+#define EGL_RENDERABLE_TYPE               0x3040
+#define EGL_RENDER_BUFFER                 0x3086
+#define EGL_RGB_BUFFER                    0x308E
+#define EGL_SINGLE_BUFFER                 0x3085
+#define EGL_SWAP_BEHAVIOR                 0x3093
+#define EGL_UNKNOWN                       ((EGLint)-1)
+#define EGL_VERTICAL_RESOLUTION           0x3091
+EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api);
+EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void);
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
+#endif /* EGL_VERSION_1_2 */
+
+#ifndef EGL_VERSION_1_3
+#define EGL_VERSION_1_3 1
+#define EGL_CONFORMANT                    0x3042
+#define EGL_CONTEXT_CLIENT_VERSION        0x3098
+#define EGL_MATCH_NATIVE_PIXMAP           0x3041
+#define EGL_OPENGL_ES2_BIT                0x0004
+#define EGL_VG_ALPHA_FORMAT               0x3088
+#define EGL_VG_ALPHA_FORMAT_NONPRE        0x308B
+#define EGL_VG_ALPHA_FORMAT_PRE           0x308C
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT       0x0040
+#define EGL_VG_COLORSPACE                 0x3087
+#define EGL_VG_COLORSPACE_sRGB            0x3089
+#define EGL_VG_COLORSPACE_LINEAR          0x308A
+#define EGL_VG_COLORSPACE_LINEAR_BIT      0x0020
+#endif /* EGL_VERSION_1_3 */
+
+#ifndef EGL_VERSION_1_4
+#define EGL_VERSION_1_4 1
+#define EGL_DEFAULT_DISPLAY               ((EGLNativeDisplayType)0)
+#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT   0x0200
+#define EGL_MULTISAMPLE_RESOLVE           0x3099
+#define EGL_MULTISAMPLE_RESOLVE_DEFAULT   0x309A
+#define EGL_MULTISAMPLE_RESOLVE_BOX       0x309B
+#define EGL_OPENGL_API                    0x30A2
+#define EGL_OPENGL_BIT                    0x0008
+#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT   0x0400
+EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void);
+#endif /* EGL_VERSION_1_4 */
+
+#ifndef EGL_VERSION_1_5
+#define EGL_VERSION_1_5 1
+typedef void *EGLSync;
+typedef intptr_t EGLAttrib;
+typedef khronos_utime_nanoseconds_t EGLTime;
+typedef void *EGLImage;
+#define EGL_CONTEXT_MAJOR_VERSION         0x3098
+#define EGL_CONTEXT_MINOR_VERSION         0x30FB
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK   0x30FD
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
+#define EGL_NO_RESET_NOTIFICATION         0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET         0x31BF
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define EGL_CONTEXT_OPENGL_DEBUG          0x31B0
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS  0x31B2
+#define EGL_OPENGL_ES3_BIT                0x00000040
+#define EGL_CL_EVENT_HANDLE               0x309C
+#define EGL_SYNC_CL_EVENT                 0x30FE
+#define EGL_SYNC_CL_EVENT_COMPLETE        0x30FF
+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE  0x30F0
+#define EGL_SYNC_TYPE                     0x30F7
+#define EGL_SYNC_STATUS                   0x30F1
+#define EGL_SYNC_CONDITION                0x30F8
+#define EGL_SIGNALED                      0x30F2
+#define EGL_UNSIGNALED                    0x30F3
+#define EGL_SYNC_FLUSH_COMMANDS_BIT       0x0001
+#define EGL_FOREVER                       0xFFFFFFFFFFFFFFFFull
+#define EGL_TIMEOUT_EXPIRED               0x30F5
+#define EGL_CONDITION_SATISFIED           0x30F6
+#define EGL_NO_SYNC                       ((EGLSync)0)
+#define EGL_SYNC_FENCE                    0x30F9
+#define EGL_GL_COLORSPACE                 0x309D
+#define EGL_GL_COLORSPACE_SRGB            0x3089
+#define EGL_GL_COLORSPACE_LINEAR          0x308A
+#define EGL_GL_RENDERBUFFER               0x30B9
+#define EGL_GL_TEXTURE_2D                 0x30B1
+#define EGL_GL_TEXTURE_LEVEL              0x30BC
+#define EGL_GL_TEXTURE_3D                 0x30B2
+#define EGL_GL_TEXTURE_ZOFFSET            0x30BD
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
+#define EGL_IMAGE_PRESERVED               0x30D2
+#define EGL_NO_IMAGE                      ((EGLImage)0)
+EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
+EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image);
+EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags);
+#endif /* EGL_VERSION_1_5 */
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* __egl_h_ */
+#endif
index a392b31..9c1b6c9 100644 (file)
@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 /*
-** Copyright (c) 2013 The Khronos Group Inc.
+** Copyright (c) 2013-2014 The Khronos Group Inc.
 **
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -33,12 +33,12 @@ extern "C" {
 ** used to make the header, and the header can be found at
 **   http://www.opengl.org/registry/
 **
-** Khronos $Revision: 23535 $ on $Date: 2013-10-16 10:29:40 -0700 (Wed, 16 Oct 2013) $
+** Khronos $Revision: 31127 $ on $Date: 2015-05-08 14:52:02 -0700 (Fri, 08 May 2015) $
 */
 
 #include <EGL/eglplatform.h>
 
-#define EGL_EGLEXT_VERSION 20131016
+#define EGL_EGLEXT_VERSION 20150508
 
 /* Generated C header for:
  * API: egl
@@ -56,6 +56,16 @@ extern "C" {
 #define EGL_SYNC_CL_EVENT_COMPLETE_KHR    0x30FF
 #endif /* EGL_KHR_cl_event */
 
+#ifndef EGL_KHR_cl_event2
+#define EGL_KHR_cl_event2 1
+typedef void *EGLSyncKHR;
+typedef intptr_t EGLAttribKHR;
+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list);
+#endif
+#endif /* EGL_KHR_cl_event2 */
+
 #ifndef EGL_KHR_client_get_all_proc_addresses
 #define EGL_KHR_client_get_all_proc_addresses 1
 #endif /* EGL_KHR_client_get_all_proc_addresses */
@@ -84,12 +94,28 @@ extern "C" {
 #define EGL_OPENGL_ES3_BIT_KHR            0x00000040
 #endif /* EGL_KHR_create_context */
 
+#ifndef EGL_KHR_create_context_no_error
+#define EGL_KHR_create_context_no_error 1
+#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR   0x31B3
+#endif /* EGL_KHR_create_context_no_error */
+
 #ifndef EGL_KHR_fence_sync
 #define EGL_KHR_fence_sync 1
+typedef khronos_utime_nanoseconds_t EGLTimeKHR;
 #ifdef KHRONOS_SUPPORT_INT64
 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
 #define EGL_SYNC_CONDITION_KHR            0x30F8
 #define EGL_SYNC_FENCE_KHR                0x30F9
+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
+typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
+#endif
 #endif /* KHRONOS_SUPPORT_INT64 */
 #endif /* EGL_KHR_fence_sync */
 
@@ -97,6 +123,13 @@ extern "C" {
 #define EGL_KHR_get_all_proc_addresses 1
 #endif /* EGL_KHR_get_all_proc_addresses */
 
+#ifndef EGL_KHR_gl_colorspace
+#define EGL_KHR_gl_colorspace 1
+#define EGL_GL_COLORSPACE_KHR             0x309D
+#define EGL_GL_COLORSPACE_SRGB_KHR        0x3089
+#define EGL_GL_COLORSPACE_LINEAR_KHR      0x308A
+#endif /* EGL_KHR_gl_colorspace */
+
 #ifndef EGL_KHR_gl_renderbuffer_image
 #define EGL_KHR_gl_renderbuffer_image 1
 #define EGL_GL_RENDERBUFFER_KHR           0x30B9
@@ -169,11 +202,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR im
 #define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD
 #define EGL_LOWER_LEFT_KHR                0x30CE
 #define EGL_UPPER_LEFT_KHR                0x30CF
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface);
 #ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface);
 #endif
 #endif /* EGL_KHR_lock_surface */
 
@@ -182,10 +215,46 @@ EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurfac
 #define EGL_BITMAP_PIXEL_SIZE_KHR         0x3110
 #endif /* EGL_KHR_lock_surface2 */
 
+#ifndef EGL_KHR_lock_surface3
+#define EGL_KHR_lock_surface3 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value);
+#endif
+#endif /* EGL_KHR_lock_surface3 */
+
+#ifndef EGL_KHR_partial_update
+#define EGL_KHR_partial_update 1
+#define EGL_BUFFER_AGE_KHR                0x313D
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#endif
+#endif /* EGL_KHR_partial_update */
+
+#ifndef EGL_KHR_platform_android
+#define EGL_KHR_platform_android 1
+#define EGL_PLATFORM_ANDROID_KHR          0x3141
+#endif /* EGL_KHR_platform_android */
+
+#ifndef EGL_KHR_platform_gbm
+#define EGL_KHR_platform_gbm 1
+#define EGL_PLATFORM_GBM_KHR              0x31D7
+#endif /* EGL_KHR_platform_gbm */
+
+#ifndef EGL_KHR_platform_wayland
+#define EGL_KHR_platform_wayland 1
+#define EGL_PLATFORM_WAYLAND_KHR          0x31D8
+#endif /* EGL_KHR_platform_wayland */
+
+#ifndef EGL_KHR_platform_x11
+#define EGL_KHR_platform_x11 1
+#define EGL_PLATFORM_X11_KHR              0x31D5
+#define EGL_PLATFORM_X11_SCREEN_KHR       0x31D6
+#endif /* EGL_KHR_platform_x11 */
+
 #ifndef EGL_KHR_reusable_sync
 #define EGL_KHR_reusable_sync 1
-typedef void *EGLSyncKHR;
-typedef khronos_utime_nanoseconds_t EGLTimeKHR;
 #ifdef KHRONOS_SUPPORT_INT64
 #define EGL_SYNC_STATUS_KHR               0x30F1
 #define EGL_SIGNALED_KHR                  0x30F2
@@ -197,17 +266,9 @@ typedef khronos_utime_nanoseconds_t EGLTimeKHR;
 #define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR   0x0001
 #define EGL_FOREVER_KHR                   0xFFFFFFFFFFFFFFFFull
 #define EGL_NO_SYNC_KHR                   ((EGLSyncKHR)0)
-typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
-typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
 #ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync);
-EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
 EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
 #endif
 #endif /* KHRONOS_SUPPORT_INT64 */
 #endif /* EGL_KHR_reusable_sync */
@@ -309,6 +370,14 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy,
 #define EGL_KHR_surfaceless_context 1
 #endif /* EGL_KHR_surfaceless_context */
 
+#ifndef EGL_KHR_swap_buffers_with_damage
+#define EGL_KHR_swap_buffers_with_damage 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#endif
+#endif /* EGL_KHR_swap_buffers_with_damage */
+
 #ifndef EGL_KHR_vg_parent_image
 #define EGL_KHR_vg_parent_image 1
 #define EGL_VG_PARENT_IMAGE_KHR           0x30BA
@@ -365,6 +434,12 @@ EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR
 #define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
 #endif /* EGL_ANGLE_d3d_share_handle_client_buffer */
 
+#ifndef EGL_ANGLE_device_d3d
+#define EGL_ANGLE_device_d3d 1
+#define EGL_D3D9_DEVICE_ANGLE             0x33A0
+#define EGL_D3D11_DEVICE_ANGLE            0x33A1
+#endif /* EGL_ANGLE_device_d3d */
+
 #ifndef EGL_ANGLE_query_surface_pointer
 #define EGL_ANGLE_query_surface_pointer 1
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
@@ -377,6 +452,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
 #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
 #endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */
 
+#ifndef EGL_ANGLE_window_fixed_size
+#define EGL_ANGLE_window_fixed_size 1
+#define EGL_FIXED_SIZE_ANGLE              0x3201
+#endif /* EGL_ANGLE_window_fixed_size */
+
 #ifndef EGL_ARM_pixmap_multisample_discard
 #define EGL_ARM_pixmap_multisample_discard 1
 #define EGL_DISCARD_SAMPLES_ARM           0x3286
@@ -399,6 +479,42 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
 #define EGL_LOSE_CONTEXT_ON_RESET_EXT     0x31BF
 #endif /* EGL_EXT_create_context_robustness */
 
+#ifndef EGL_EXT_device_base
+#define EGL_EXT_device_base 1
+typedef void *EGLDeviceEXT;
+#define EGL_NO_DEVICE_EXT                 ((EGLDeviceEXT)(0))
+#define EGL_BAD_DEVICE_EXT                0x322B
+#define EGL_DEVICE_EXT                    0x322C
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value);
+typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value);
+EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
+#endif
+#endif /* EGL_EXT_device_base */
+
+#ifndef EGL_EXT_device_drm
+#define EGL_EXT_device_drm 1
+#define EGL_DRM_DEVICE_FILE_EXT           0x3233
+#endif /* EGL_EXT_device_drm */
+
+#ifndef EGL_EXT_device_enumeration
+#define EGL_EXT_device_enumeration 1
+#endif /* EGL_EXT_device_enumeration */
+
+#ifndef EGL_EXT_device_openwf
+#define EGL_EXT_device_openwf 1
+#define EGL_OPENWF_DEVICE_ID_EXT          0x3237
+#endif /* EGL_EXT_device_openwf */
+
+#ifndef EGL_EXT_device_query
+#define EGL_EXT_device_query 1
+#endif /* EGL_EXT_device_query */
+
 #ifndef EGL_EXT_image_dma_buf_import
 #define EGL_EXT_image_dma_buf_import 1
 #define EGL_LINUX_DMA_BUF_EXT             0x3270
@@ -430,6 +546,48 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
 #define EGL_MULTIVIEW_VIEW_COUNT_EXT      0x3134
 #endif /* EGL_EXT_multiview_window */
 
+#ifndef EGL_EXT_output_base
+#define EGL_EXT_output_base 1
+typedef void *EGLOutputLayerEXT;
+typedef void *EGLOutputPortEXT;
+#define EGL_NO_OUTPUT_LAYER_EXT           ((EGLOutputLayerEXT)0)
+#define EGL_NO_OUTPUT_PORT_EXT            ((EGLOutputPortEXT)0)
+#define EGL_BAD_OUTPUT_LAYER_EXT          0x322D
+#define EGL_BAD_OUTPUT_PORT_EXT           0x322E
+#define EGL_SWAP_INTERVAL_EXT             0x322F
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value);
+typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value);
+typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports);
+EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value);
+EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name);
+EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value);
+EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name);
+#endif
+#endif /* EGL_EXT_output_base */
+
+#ifndef EGL_EXT_output_drm
+#define EGL_EXT_output_drm 1
+#define EGL_DRM_CRTC_EXT                  0x3234
+#define EGL_DRM_PLANE_EXT                 0x3235
+#define EGL_DRM_CONNECTOR_EXT             0x3236
+#endif /* EGL_EXT_output_drm */
+
+#ifndef EGL_EXT_output_openwf
+#define EGL_EXT_output_openwf 1
+#define EGL_OPENWF_PIPELINE_ID_EXT        0x3238
+#define EGL_OPENWF_PORT_ID_EXT            0x3239
+#endif /* EGL_EXT_output_openwf */
+
 #ifndef EGL_EXT_platform_base
 #define EGL_EXT_platform_base 1
 typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
@@ -442,6 +600,11 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
 #endif
 #endif /* EGL_EXT_platform_base */
 
+#ifndef EGL_EXT_platform_device
+#define EGL_EXT_platform_device 1
+#define EGL_PLATFORM_DEVICE_EXT           0x313F
+#endif /* EGL_EXT_platform_device */
+
 #ifndef EGL_EXT_platform_wayland
 #define EGL_EXT_platform_wayland 1
 #define EGL_PLATFORM_WAYLAND_EXT          0x31D8
@@ -453,6 +616,19 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
 #define EGL_PLATFORM_X11_SCREEN_EXT       0x31D6
 #endif /* EGL_EXT_platform_x11 */
 
+#ifndef EGL_EXT_protected_surface
+#define EGL_EXT_protected_surface 1
+#define EGL_PROTECTED_CONTENT_EXT         0x32C0
+#endif /* EGL_EXT_protected_surface */
+
+#ifndef EGL_EXT_stream_consumer_egloutput
+#define EGL_EXT_stream_consumer_egloutput 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer);
+#endif
+#endif /* EGL_EXT_stream_consumer_egloutput */
+
 #ifndef EGL_EXT_swap_buffers_with_damage
 #define EGL_EXT_swap_buffers_with_damage 1
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
@@ -461,6 +637,35 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSu
 #endif
 #endif /* EGL_EXT_swap_buffers_with_damage */
 
+#ifndef EGL_EXT_yuv_surface
+#define EGL_EXT_yuv_surface 1
+#define EGL_YUV_ORDER_EXT                 0x3301
+#define EGL_YUV_NUMBER_OF_PLANES_EXT      0x3311
+#define EGL_YUV_SUBSAMPLE_EXT             0x3312
+#define EGL_YUV_DEPTH_RANGE_EXT           0x3317
+#define EGL_YUV_CSC_STANDARD_EXT          0x330A
+#define EGL_YUV_PLANE_BPP_EXT             0x331A
+#define EGL_YUV_BUFFER_EXT                0x3300
+#define EGL_YUV_ORDER_YUV_EXT             0x3302
+#define EGL_YUV_ORDER_YVU_EXT             0x3303
+#define EGL_YUV_ORDER_YUYV_EXT            0x3304
+#define EGL_YUV_ORDER_UYVY_EXT            0x3305
+#define EGL_YUV_ORDER_YVYU_EXT            0x3306
+#define EGL_YUV_ORDER_VYUY_EXT            0x3307
+#define EGL_YUV_ORDER_AYUV_EXT            0x3308
+#define EGL_YUV_SUBSAMPLE_4_2_0_EXT       0x3313
+#define EGL_YUV_SUBSAMPLE_4_2_2_EXT       0x3314
+#define EGL_YUV_SUBSAMPLE_4_4_4_EXT       0x3315
+#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT   0x3318
+#define EGL_YUV_DEPTH_RANGE_FULL_EXT      0x3319
+#define EGL_YUV_CSC_STANDARD_601_EXT      0x330B
+#define EGL_YUV_CSC_STANDARD_709_EXT      0x330C
+#define EGL_YUV_CSC_STANDARD_2020_EXT     0x330D
+#define EGL_YUV_PLANE_BPP_0_EXT           0x331B
+#define EGL_YUV_PLANE_BPP_8_EXT           0x331C
+#define EGL_YUV_PLANE_BPP_10_EXT          0x331D
+#endif /* EGL_EXT_yuv_surface */
+
 #ifndef EGL_HI_clientpixmap
 #define EGL_HI_clientpixmap 1
 struct EGLClientPixmapHI {
@@ -509,11 +714,42 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR
 #endif
 #endif /* EGL_MESA_drm_image */
 
+#ifndef EGL_MESA_image_dma_buf_export
+#define EGL_MESA_image_dma_buf_export 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers);
+EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets);
+#endif
+#endif /* EGL_MESA_image_dma_buf_export */
+
 #ifndef EGL_MESA_platform_gbm
 #define EGL_MESA_platform_gbm 1
 #define EGL_PLATFORM_GBM_MESA             0x31D7
 #endif /* EGL_MESA_platform_gbm */
 
+#ifndef EGL_NOK_swap_region
+#define EGL_NOK_swap_region 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
+#endif
+#endif /* EGL_NOK_swap_region */
+
+#ifndef EGL_NOK_swap_region2
+#define EGL_NOK_swap_region2 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
+#endif
+#endif /* EGL_NOK_swap_region2 */
+
+#ifndef EGL_NOK_texture_from_pixmap
+#define EGL_NOK_texture_from_pixmap 1
+#define EGL_Y_INVERTED_NOK                0x307F
+#endif /* EGL_NOK_texture_from_pixmap */
+
 #ifndef EGL_NV_3dvision_surface
 #define EGL_NV_3dvision_surface 1
 #define EGL_AUTO_STEREO_NV                0x3136
@@ -532,6 +768,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR
 #define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
 #endif /* EGL_NV_coverage_sample_resolve */
 
+#ifndef EGL_NV_cuda_event
+#define EGL_NV_cuda_event 1
+#define EGL_CUDA_EVENT_HANDLE_NV          0x323B
+#define EGL_SYNC_CUDA_EVENT_NV            0x323C
+#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV   0x323D
+#endif /* EGL_NV_cuda_event */
+
 #ifndef EGL_NV_depth_nonlinear
 #define EGL_NV_depth_nonlinear 1
 #define EGL_DEPTH_ENCODING_NV             0x30E2
@@ -539,6 +782,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR
 #define EGL_DEPTH_ENCODING_NONLINEAR_NV   0x30E3
 #endif /* EGL_NV_depth_nonlinear */
 
+#ifndef EGL_NV_device_cuda
+#define EGL_NV_device_cuda 1
+#define EGL_CUDA_DEVICE_NV                0x323A
+#endif /* EGL_NV_device_cuda */
+
 #ifndef EGL_NV_native_query
 #define EGL_NV_native_query 1
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id);
@@ -621,6 +869,16 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void);
 #endif /* KHRONOS_SUPPORT_INT64 */
 #endif /* EGL_NV_system_time */
 
+#ifndef EGL_TIZEN_image_native_buffer
+#define EGL_TIZEN_image_native_buffer 1
+#define EGL_NATIVE_BUFFER_TIZEN           0x32A0
+#endif /* EGL_TIZEN_image_native_buffer */
+
+#ifndef EGL_TIZEN_image_native_surface
+#define EGL_TIZEN_image_native_surface 1
+#define EGL_NATIVE_SURFACE_TIZEN          0x32A1
+#endif /* EGL_TIZEN_image_native_surface */
+
 #ifdef __cplusplus
 }
 #endif
index 1f07d4c..917a204 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -34,63 +34,6 @@ extern "C" {
 
 #include <EGL/eglplatform.h>
 
-/* EGL_MESA_screen extension  >>> PRELIMINARY <<< */
-#ifndef EGL_MESA_screen_surface
-#define EGL_MESA_screen_surface 1
-
-#define EGL_BAD_SCREEN_MESA                    0x4000
-#define EGL_BAD_MODE_MESA                      0x4001
-#define EGL_SCREEN_COUNT_MESA                  0x4002
-#define EGL_SCREEN_POSITION_MESA               0x4003
-#define EGL_SCREEN_POSITION_GRANULARITY_MESA   0x4004
-#define EGL_MODE_ID_MESA                       0x4005
-#define EGL_REFRESH_RATE_MESA                  0x4006
-#define EGL_OPTIMAL_MESA                       0x4007
-#define EGL_INTERLACED_MESA                    0x4008
-#define EGL_SCREEN_BIT_MESA                    0x08
-
-typedef khronos_uint32_t EGLScreenMESA;
-typedef khronos_uint32_t EGLModeMESA;
-
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
-EGLAPI EGLSurface EGLAPIENTRY eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
-EGLAPI EGLBoolean EGLAPIENTRY eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
-EGLAPI const char * EGLAPIENTRY eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSEMODEMESA) (EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMODESMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGetModeATTRIBMESA) (EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSCRREENSMESA) (EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
-typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESCREENSURFACEMESA) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSHOWSCREENSURFACEMESA) (EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSCREENPOSIITONMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENSURFACEMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENMODEMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
-typedef const char * (EGLAPIENTRYP PFNEGLQUERYMODESTRINGMESA) (EGLDisplay dpy, EGLModeMESA mode);
-
-#endif /* EGL_MESA_screen_surface */
-
-#ifndef EGL_MESA_copy_context
-#define EGL_MESA_copy_context 1
-
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
-
-#endif /* EGL_MESA_copy_context */
-
 #ifndef EGL_MESA_drm_display
 #define EGL_MESA_drm_display 1
 
@@ -134,25 +77,22 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, st
 
 #endif
 
-#ifndef EGL_NOK_swap_region
-#define EGL_NOK_swap_region 1
+#ifndef EGL_WL_create_wayland_buffer_from_image
+#define EGL_WL_create_wayland_buffer_from_image 1
 
 #ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects);
+EGLAPI struct wl_buffer * EGLAPIENTRY eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImageKHR image);
 #endif
+typedef struct wl_buffer * (EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (EGLDisplay dpy, EGLImageKHR image);
 
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects);
 #endif
 
-#ifndef EGL_NOK_texture_from_pixmap
-#define EGL_NOK_texture_from_pixmap 1
-
-#define EGL_Y_INVERTED_NOK                     0x307F
-#endif /* EGL_NOK_texture_from_pixmap */
+/* remnant of EGL_NOK_swap_region kept for compatibility because of a non-standard type name */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects);
 
-#ifndef EGL_ANDROID_image_native_buffer
-#define EGL_ANDROID_image_native_buffer 1
-#define EGL_NATIVE_BUFFER_ANDROID       0x3140  /* eglCreateImageKHR target */
+#ifndef EGL_MESA_configless_context
+#define EGL_MESA_configless_context 1
+#define EGL_NO_CONFIG_MESA                     ((EGLConfig)0)
 #endif
 
 #ifdef __cplusplus
index 6bf00aa..cd6dc7b 100644 (file)
@@ -25,7 +25,7 @@
 */
 
 /* Platform-specific types and definitions for egl.h
- * $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $
+ * $Revision: 30994 $ on $Date: 2015-04-30 13:36:48 -0700 (Thu, 30 Apr 2015) $
  *
  * Adopters may modify khrplatform.h and this file to suit their platform.
  * You are encouraged to submit all modifications to the Khronos group so that
@@ -77,7 +77,7 @@ typedef HDC     EGLNativeDisplayType;
 typedef HBITMAP EGLNativePixmapType;
 typedef HWND    EGLNativeWindowType;
 
-#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
+#elif defined(__APPLE__) || defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
 
 typedef int   EGLNativeDisplayType;
 typedef void *EGLNativeWindowType;
index db5e461..1bd0502 100644 (file)
@@ -50,6 +50,11 @@ 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*/);
+
     void (*release_tex_image)(struct yagl_client_interface */*iface*/,
                               void */*cookie*/);
 };
index f9b9881..b596cf5 100644 (file)
@@ -3,7 +3,7 @@
 Name:       emulator-yagl
 Summary:    YaGL - OpenGLES acceleration module for emulator
 Version:    1.4
-Release:    2
+Release:    5
 License:    MIT and LPGL-3.0
 #URL:        http://www.khronos.org
 ExclusiveArch:    %{ix86}
@@ -11,6 +11,7 @@ Source0:    %{name}-%{version}.tar.gz
 Source1001:     emulator-yagl.manifest
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(libdrm)
+BuildRequires:  pkgconfig(libtbm)
 BuildRequires:  flex
 BuildRequires:  bison
 %if %{with wayland}
@@ -22,9 +23,12 @@ BuildRequires:  pkgconfig(wayland-server)
 BuildRequires:  pkgconfig(xfixes)
 BuildRequires:  pkgconfig(x11)
 BuildRequires:  pkgconfig(x11-xcb)
+BuildRequires:  pkgconfig(xshmfence)
+BuildRequires:  pkgconfig(xcb)
 BuildRequires:  pkgconfig(xext)
 BuildRequires:  pkgconfig(dri2proto)
 %endif
+Requires:   libtbm
 Provides:   opengl-es-drv
 
 %description
@@ -69,9 +73,6 @@ ln -s libGLESv1_CM.so.1 %{buildroot}%{_libdir}/libGLESv1_CM.so
 ln -s yagl/libGLESv2.so.1.0 %{buildroot}%{_libdir}/libGLESv2.so.1
 ln -s libGLESv2.so.1 %{buildroot}%{_libdir}/libGLESv2.so
 
-mkdir -p %{buildroot}/etc/emulator
-cp packaging/opengl-es-setup-yagl-env.sh %{buildroot}/etc/emulator
-
 mkdir -p %{buildroot}/usr/share/license
 cp COPYING %{buildroot}/usr/share/license/%{name}
 %endif
@@ -101,7 +102,6 @@ cp pkgconfig/* %{buildroot}/usr/lib/pkgconfig/
 /usr/lib/libGLES*
 /usr/lib/yagl/*
 /usr/lib/dummy-gl/*
-%attr(777,root,root)/etc/emulator/opengl-es-setup-yagl-env.sh
 /usr/share/license/%{name}
 %endif
 
diff --git a/packaging/opengl-es-setup-yagl-env.sh b/packaging/opengl-es-setup-yagl-env.sh
deleted file mode 100755 (executable)
index 6c2be18..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
- #!/bin/sh
-
-echo -e "[${_G} Opengl-es acceleration module setting. ${C_}]"
-if grep "yagl=1" /proc/cmdline ; then
-    echo -e "[${_G} Emulator support gles hw acceleration. ${C_}]"
-    echo -e "[${_G} Change permission of /dev/yagl. ${C_}]"
-    chown root:video /dev/dri/card0
-    chown root:video /dev/yagl
-    chown root:video /dev/slp_global_lock
-    chmod 660 /dev/dri/card0
-    chmod 660 /dev/yagl
-    chmod 660 /dev/slp_global_lock
-    chsmack -a "*" /dev/dri/card0
-    chsmack -a "*" /dev/yagl
-    chsmack -a "*" /dev/slp_global_lock
-    echo -e "[${_G} Apply to use hw gles library. ${C_}]"
-    ln -s -f /usr/lib/yagl/libEGL.so.1.0 /usr/lib/libEGL.so
-    ln -s -f /usr/lib/yagl/libEGL.so.1.0 /usr/lib/libEGL.so.1
-    ln -s -f /usr/lib/yagl/libGLESv1_CM.so.1.0 /usr/lib/libGLESv1_CM.so
-    ln -s -f /usr/lib/yagl/libGLESv1_CM.so.1.0 /usr/lib/libGLESv1_CM.so.1
-    ln -s -f /usr/lib/yagl/libGLESv2.so.1.0 /usr/lib/libGLESv2.so
-    ln -s -f /usr/lib/yagl/libGLESv2.so.1.0 /usr/lib/libGLESv2.so.1
-else
-    echo -e "[${_G} Emulator does not support gles hw acceleration. ${C_}]"
-    echo -e "[${_G} Apply to use gles stub library. ${C_}]"
-    ln -s -f /usr/lib/dummy-gl/libEGL_dummy.so /usr/lib/libEGL.so
-    ln -s -f /usr/lib/dummy-gl/libEGL_dummy.so /usr/lib/libEGL.so.1
-    ln -s -f /usr/lib/dummy-gl/libGLESv1_dummy.so /usr/lib/libGLESv1_CM.so
-    ln -s -f /usr/lib/dummy-gl/libGLESv1_dummy.so /usr/lib/libGLESv1_CM.so.1
-    ln -s -f /usr/lib/dummy-gl/libGLESv2_dummy.so /usr/lib/libGLESv2.so
-    ln -s -f /usr/lib/dummy-gl/libGLESv2_dummy.so /usr/lib/libGLESv2.so.1
-fi