evas gl engines - avoid getting context if possible
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 6 Nov 2018 11:54:04 +0000 (11:54 +0000)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 20 Nov 2018 06:56:18 +0000 (15:56 +0900)
so getting context at least on some dviers is expensive. it may really
impact cpu usage a lot (in this cate getpid() was being called by the
nouveau drivers and that can be expensive. it is on ARM as it's a full
syscall and 1-2% of cpu time was just getting pid all the time thanks
to this...

@opt

src/modules/evas/engines/eglfs/evas_outbuf.c
src/modules/evas/engines/gl_drm/evas_outbuf.c
src/modules/evas/engines/gl_x11/evas_x_main.c

index c42914e..51e2234 100755 (executable)
@@ -8,6 +8,7 @@
 static hwc_layer_1_t *fblayer;
 static hwc_composer_device_1_t *hwcDevicePtr;
 static hwc_display_contents_1_t **mList;
+static unsigned char gl_context_valid = 0;
 
 void present(void *user_data, struct ANativeWindow *window,
                                           struct ANativeWindowBuffer *buffer)
@@ -459,10 +460,11 @@ evas_outbuf_use(Outbuf *ob)
 
    glsym_evas_gl_preload_render_lock(_evas_outbuf_make_current, ob);
 
-   if (_evas_eglfs_window)
+   if ((_evas_eglfs_window) && (!gl_context_valid))
      {
         if (eglGetCurrentContext() != _evas_eglfs_window->egl.context[0])
           force = EINA_TRUE;
+        gl_context_valid = 1;
      }
 
    if ((_evas_eglfs_window != ob) || (force))
@@ -637,6 +639,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage EINA_UNUSED, Tilebuf_
 
 end:
    glsym_evas_gl_preload_render_unlock(_evas_outbuf_make_current, ob);
+   gl_context_valid = 0;
 }
 
 Evas_Engine_GL_Context *
index a9093f1..88097b8 100755 (executable)
@@ -4,6 +4,7 @@
 static Outbuf *_evas_gl_drm_window = NULL;
 static EGLContext context = EGL_NO_CONTEXT;
 static int win_count = 0;
+static unsigned char gl_context_valid = 0;
 
 #ifdef EGL_MESA_platform_gbm
 static PFNEGLGETPLATFORMDISPLAYEXTPROC dlsym_eglGetPlatformDisplayEXT = NULL;
@@ -465,10 +466,11 @@ evas_outbuf_use(Outbuf *ob)
 
    glsym_evas_gl_preload_render_lock(_evas_outbuf_make_current, ob);
 
-   if (_evas_gl_drm_window)
+   if ((_evas_gl_drm_window) && (!gl_context_valid))
      {
         if (eglGetCurrentContext() != _evas_gl_drm_window->egl.context)
           force = EINA_TRUE;
+        gl_context_valid = 1;
      }
 
    if ((_evas_gl_drm_window != ob) || (force))
@@ -767,6 +769,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage, Tilebuf_Rect *buffer
 end:
    //TODO: Need render unlock after drm page flip?
    glsym_evas_gl_preload_render_unlock(_evas_outbuf_make_current, ob);
+   gl_context_valid = 0;
 }
 
 Evas_Engine_GL_Context *
index 17f7842..980e68c 100755 (executable)
@@ -38,6 +38,7 @@ static Eina_Hash *_evas_gl_visuals = NULL;
 
 static int win_count = 0;
 static Eina_Bool initted = EINA_FALSE;
+static unsigned char gl_context_valid = 0;
 
 #if 0
 static double
@@ -737,17 +738,19 @@ eng_window_use(Outbuf *gw)
    if ((gw) && (!gw->gl_context)) return;
 
 #ifdef GL_GLES
-   if (xwin)
+   if ((xwin) && (!gl_context_valid))
      {
         if ((evas_eglGetCurrentDisplay() != xwin->egl_disp) ||
             (evas_eglGetCurrentContext() != xwin->egl_context))
           force_use = EINA_TRUE;
+        gl_context_valid = 1;
      }
 #else
-   if (xwin)
+   if ((xwin) && (!gl_context_valid))
      {
         if (glXGetCurrentContext() != xwin->context)
            force_use = EINA_TRUE;
+        gl_context_valid = 1;
      }
 #endif
    if ((xwin != gw) || (force_use))
@@ -1711,6 +1714,7 @@ eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage EINA_UNUSED, Tilebuf_R
 
  end:
    glsym_evas_gl_preload_render_unlock(eng_preload_make_current, ob);
+   gl_context_valid = 0;
 }
 
 Evas_Engine_GL_Context *