evas_gl: add creating a debug context
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Wed, 19 Apr 2017 06:07:27 +0000 (15:07 +0900)
committerJiyoun Park <jy0703.park@samsung.com>
Thu, 21 Dec 2017 13:30:52 +0000 (22:30 +0900)
When users create a debug context,
have to check EGL_KHR_create_context extension with
evas_gl_string_query().

Change-Id: I0ee03d18232301e1b97ae6ad98967065a9ec99a7

13 files changed:
src/lib/evas/Evas_GL.h
src/lib/evas/canvas/evas_gl.c
src/lib/evas/include/evas_private.h
src/modules/evas/engines/gl_common/evas_gl_core.c
src/modules/evas/engines/gl_common/evas_gl_core.h
src/modules/evas/engines/gl_common/evas_gl_core_private.h
src/modules/evas/engines/gl_drm/evas_engine.c
src/modules/evas/engines/gl_generic/evas_engine.c
src/modules/evas/engines/gl_sdl/evas_engine.c
src/modules/evas/engines/gl_tbm/evas_engine.c
src/modules/evas/engines/gl_x11/evas_engine.c
src/modules/evas/engines/software_generic/evas_engine.c
src/modules/evas/engines/wayland_egl/evas_engine.c

index 477601e..c5c3fa9 100755 (executable)
@@ -548,9 +548,10 @@ typedef enum _Evas_GL_Multisample_Bits
  */
 typedef enum _Evas_GL_Context_Version
 {
-   EVAS_GL_GLES_1_X = 1, /**< OpenGL-ES 1.x */
-   EVAS_GL_GLES_2_X = 2, /**< OpenGL-ES 2.x is the default */
-   EVAS_GL_GLES_3_X = 3  /**< @internal OpenGL-ES 3.x, not implemented yet */
+   EVAS_GL_GLES_1_X = 1,       /**< OpenGL-ES 1.x */
+   EVAS_GL_GLES_2_X = 2,       /**< OpenGL-ES 2.x is the default */
+   EVAS_GL_GLES_3_X = 3,       /**< OpenGL-ES 3.x (@b Since: 2.4) */
+   EVAS_GL_DEBUG    = 0x1000   /**< Enable debug mode on this context (See GL_KHR_debug) (@b Since 4.0) */
 } Evas_GL_Context_Version;
 
 /**
index a54de42..efe1ba1 100644 (file)
@@ -3,6 +3,7 @@
 #include "evas_private.h"
 #include "Evas_GL.h"
 
+#define CONTEXT_VERSION_MASK 0xFF
 typedef struct _Evas_GL_TLS_data Evas_GL_TLS_data;
 
 /* since 1.16: store current evas gl - this TLS is never destroyed */
@@ -24,6 +25,7 @@ struct _Evas_GL_Context
 {
    void    *data;
    Evas_GL_Context_Version version;
+   int ctx_flag;
 };
 
 struct _Evas_GL_Surface
@@ -371,12 +373,16 @@ evas_gl_context_version_create(Evas_GL *evas_gl, Evas_GL_Context *share_ctx,
                                Evas_GL_Context_Version version)
 {
    Evas_GL_Context *ctx;
+   int ctx_flag;
 
    // Magic
    MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
    return NULL;
    MAGIC_CHECK_END();
 
+   ctx_flag = version & EVAS_GL_DEBUG;
+   version &= CONTEXT_VERSION_MASK;
+
    if ((version < EVAS_GL_GLES_1_X) || (version > EVAS_GL_GLES_3_X))
      {
         ERR("Can not create an OpenGL-ES %d.x context (not supported).",
@@ -396,9 +402,10 @@ evas_gl_context_version_create(Evas_GL *evas_gl, Evas_GL_Context *share_ctx,
 
    // Call engine->gl_create_context
    ctx->version = version;
+   ctx->ctx_flag = ctx_flag;
    ctx->data = evas_gl->evas->engine.func->gl_context_create
      (_evas_engine_context(evas_gl->evas), share_ctx ? share_ctx->data : NULL,
-      version, &evas_gl_native_context_get, &evas_gl_engine_data_get);
+      version, ctx_flag, &evas_gl_native_context_get, &evas_gl_engine_data_get);
 
    // Set a few variables
    if (!ctx->data)
index 5b887dc..03ed83d 100755 (executable)
@@ -1434,7 +1434,7 @@ struct _Evas_Func
    void *(*gl_surface_create)            (void *engine, void *config, int w, int h);
    void *(*gl_pbuffer_surface_create)    (void *engine, void *config, int w, int h, int const *attrib_list);
    int  (*gl_surface_destroy)            (void *engine, void *surface);
-   void *(*gl_context_create)            (void *engine, void *share_context, int version, void *(*native_context_get)(void *ctx), void *(*engine_data_get)(void *evasgl));
+   void *(*gl_context_create)            (void *engine, void *share_context, int version, int ctx_flag, void *(*native_context_get)(void *ctx), void *(*engine_data_get)(void *evasgl));
    int  (*gl_context_destroy)            (void *engine, void *context);
    int  (*gl_make_current)               (void *engine, void *surface, void *context);
    const char *(*gl_string_query)        (void *engine, int name);
index a899965..b6bf159 100755 (executable)
@@ -127,7 +127,7 @@ _internal_resource_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context
         if (!rsc->context)
           {
              // Create a resource context
-             rsc->context = evgl_engine->funcs->context_create(eng_data, NULL, EVAS_GL_GLES_2_X);
+             rsc->context = evgl_engine->funcs->context_create(eng_data, NULL, EVAS_GL_GLES_2_X, 0);
              if (!rsc->context)
                {
                   ERR("Internal resource context creation failed.");
@@ -2455,7 +2455,7 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc)
 
 void *
 evgl_context_create(void *eng_data, EVGL_Context *share_ctx,
-                    Evas_GL_Context_Version version,
+                    Evas_GL_Context_Version version, int ctx_flag,
                     void *(*native_context_get)(void *),
                     void *(*engine_data_get)(void *))
 {
@@ -2504,9 +2504,9 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx,
 
    // Call engine create context
    if (share_ctx)
-      ctx->context = evgl_engine->funcs->context_create(eng_data, share_ctx->context, version);
+      ctx->context = evgl_engine->funcs->context_create(eng_data, share_ctx->context, version, ctx_flag);
    else
-      ctx->context = evgl_engine->funcs->context_create(eng_data, NULL, version);
+      ctx->context = evgl_engine->funcs->context_create(eng_data, NULL, version, ctx_flag);
 
    // Call engine create context
    if (!ctx->context)
index 8401a10..d7c737a 100755 (executable)
@@ -59,7 +59,7 @@ EVGL_Engine *evgl_engine_init(void *eng_data, const EVGL_Interface *efunc);
 void        *evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h);
 void        *evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h, const int *attrib_list);
 int          evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc);
-void        *evgl_context_create(void *eng_data, EVGL_Context *share_ctx, Evas_GL_Context_Version version, void *(*native_context_get)(void *), void *(*engine_data_get)(void *));
+void        *evgl_context_create(void *eng_data, EVGL_Context *share_ctx, Evas_GL_Context_Version version, int ctx_flag, void *(*native_context_get)(void *), void *(*engine_data_get)(void *));
 int          evgl_context_destroy(void *eng_data, EVGL_Context *ctx);
 int          evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx);
 
index 582fcf8..76d0a0c 100755 (executable)
@@ -323,7 +323,7 @@ struct _EVGL_Interface
    int         (*surface_destroy)(void *data, void *surface);
 
    // Creates/Destroys the native surface from evas engine.
-   void       *(*context_create)(void *data, void *share_ctx, Evas_GL_Context_Version version);
+   void       *(*context_create)(void *data, void *share_ctx, Evas_GL_Context_Version version, int ctx_flag);
    int         (*context_destroy)(void *data, void *context);
 
    // Calls the make_current from evas_engine.
index e3419d9..3eb53cc 100755 (executable)
@@ -91,7 +91,7 @@ static void *evgl_eng_native_window_create(void *data);
 static int evgl_eng_native_window_destroy(void *data, void *native_window);
 static void *evgl_eng_window_surface_create(void *data, void *native_window);
 static int evgl_eng_window_surface_destroy(void *data, void *surface);
-static void *evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version);
+static void *evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version, int ctx_flag);
 static int evgl_eng_context_destroy(void *data, void *context);
 static const char *evgl_eng_string_get(void *data);
 static void *evgl_eng_proc_address_get(const char *name);
@@ -476,7 +476,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
 }
 
 static void *
-evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version)
+evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version, int ctx_flag EINA_UNUSED)
 {
    Render_Engine *re;
    EGLContext context = EGL_NO_CONTEXT;
index c120947..552f0dc 100755 (executable)
@@ -1739,14 +1739,14 @@ eng_gl_surface_destroy(void *engine, void *surface)
 }
 
 static void *
-eng_gl_context_create(void *engine, void *share_context, int version,
+eng_gl_context_create(void *engine, void *share_context, int version, int ctx_flag,
                       void *(*native_context_get)(void *),
                       void *(*engine_data_get)(void *))
 {
    EVGL_Context  *sctx = (EVGL_Context *)share_context;
 
    EVGLINIT(NULL);
-   return evgl_context_create(re, sctx, version, native_context_get, engine_data_get);
+   return evgl_context_create(re, sctx, version, ctx_flag, native_context_get, engine_data_get);
 }
 
 static int
index e6a968d..a99c225 100755 (executable)
@@ -196,7 +196,7 @@ evgl_eng_window_surface_destroy(void *data EINA_UNUSED,
 }
 
 static void *
-evgl_eng_context_create(void *data, void *share_ctx EINA_UNUSED, Evas_GL_Context_Version version)
+evgl_eng_context_create(void *data, void *share_ctx EINA_UNUSED, Evas_GL_Context_Version version, int ctx_flag EINA_UNUSED)
 {
    Render_Engine *re = data;
 
index 5c1f716..2adef03 100755 (executable)
@@ -127,7 +127,7 @@ static void *evgl_eng_native_window_create(void *engine);
 static int evgl_eng_native_window_destroy(void *engine, void *native_window);
 static void *evgl_eng_window_surface_create(void *engine, void *native_window);
 static int evgl_eng_window_surface_destroy(void *engine, void *surface);
-static void *evgl_eng_context_create(void *engine, void *share_ctx, Evas_GL_Context_Version version);
+static void *evgl_eng_context_create(void *engine, void *share_ctx, Evas_GL_Context_Version version, int ctx_flag);
 static int evgl_eng_context_destroy(void *engine, void *context);
 static const char *evgl_eng_string_get(void *engine);
 static void *evgl_eng_proc_address_get(const char *name);
@@ -474,7 +474,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
 }
 
 static void *
-evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version)
+evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version, int ctx_flag EINA_UNUSED)
 {
    Render_Engine *re;
    Outbuf *ob;
index c13b0c3..60fe00a 100755 (executable)
@@ -464,7 +464,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
 }
 
 static void *
-evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version)
+evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version, int ctx_flag EINA_UNUSED )
 {
    Render_Engine *re = (Render_Engine *)data;
 
index de64f21..5175e99 100755 (executable)
@@ -3591,7 +3591,7 @@ eng_gl_surface_destroy(void *data EINA_UNUSED, void *surface)
 }
 
 static void *
-eng_gl_context_create(void *data EINA_UNUSED, void *share_context, int version,
+eng_gl_context_create(void *data EINA_UNUSED, void *share_context, int version, int ctx_flag EINA_UNUSED,
                       void *(*native_context_get)(void *) EINA_UNUSED,
                       void *(*engine_data_get)(void *) EINA_UNUSED)
 {
index 98c7685..59bae45 100644 (file)
@@ -469,12 +469,12 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
 }
 
 static void *
-evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version)
+evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version, int ctx_flag)
 {
    Render_Engine *re;
    Outbuf *ob;
    EGLContext context = EGL_NO_CONTEXT;
-   int attrs[3];
+   int attrs[5] = {0};
 
    if (!(re = (Render_Engine *)data))
      {
@@ -522,7 +522,15 @@ evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version)
 
    attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
    attrs[1] = version;
-   attrs[2] = EGL_NONE;
+
+   if (ctx_flag & EVAS_GL_DEBUG)
+     {
+        attrs[2] = EGL_CONTEXT_FLAGS_KHR;
+        attrs[3] |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+        attrs[4] = EGL_NONE;
+     }
+   else
+     attrs[2] = EGL_NONE;
 
    if (ctxt)
      {