evas gl engines - avoid getting context if possible

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
This commit is contained in:
Carsten Haitzler 2018-11-06 11:54:04 +00:00
parent f66414beec
commit e7771438a2
4 changed files with 18 additions and 5 deletions

View File

@ -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 *

View File

@ -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;
@ -463,10 +464,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))
@ -765,6 +767,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 *

View File

@ -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 *

View File

@ -7,6 +7,7 @@ static Outbuf *_evas_gl_wl_window = NULL;
static EGLContext context = EGL_NO_CONTEXT;
static struct wl_display *display = NULL;
static int win_count = 0;
static unsigned char gl_context_valid = 0;
Outbuf *
eng_window_new(Evas_Engine_Info_Wayland *einfo, int w, int h, Render_Output_Swap_Mode swap_mode)
@ -214,10 +215,11 @@ eng_window_use(Outbuf *gw)
glsym_evas_gl_preload_render_lock(eng_preload_make_current, gw);
if ((gw) && (!gw->gl_context)) return;
if (_evas_gl_wl_window)
if ((_evas_gl_wl_window) && (!gl_context_valid))
{
if (eglGetCurrentContext() != _evas_gl_wl_window->egl_context)
force = EINA_TRUE;
gl_context_valid = 1;
}
if ((_evas_gl_wl_window != gw) || (force))
@ -517,6 +519,7 @@ eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage, Tilebuf_Rect *buffer_
end:
glsym_evas_gl_preload_render_unlock(eng_preload_make_current, ob);
ecore_wl2_display_flush(ob->wl2_disp);
gl_context_valid = 0;
}
Evas_Engine_GL_Context *