evas/gl_x11: Optimize out calls to make current

Summary: Reducing the number of calling eglMakeCurrent.

Reviewers: jpeg

Subscribers: wonsik, cedric, spacegrapher

Differential Revision: https://phab.enlightenment.org/D2094
This commit is contained in:
Minkyoung Kim 2015-03-17 11:17:26 +09:00 committed by Jean-Philippe Andre
parent 84634ea51f
commit 0585540bb3
8 changed files with 57 additions and 15 deletions

View File

@ -641,6 +641,7 @@ eng_setup(Evas *eo_e, void *in)
eng_outbuf_egl_display_get,
eng_gl_context_new,
eng_gl_context_use,
NULL,//eng_outbuf_context_is_current_set
&evgl_funcs,
epd->output.w, epd->output.h))
{

View File

@ -14,6 +14,7 @@ typedef Evas_Engine_GL_Context *(*Window_GL_Context_Get)(Outbuf *ob);
typedef void *(*Window_EGL_Display_Get)(Outbuf *ob);
typedef Context_3D *(*Window_GL_Context_New)(Outbuf *ob);
typedef void (*Window_GL_Context_Use)(Context_3D *ctx);
typedef void (*Window_Context_Is_Current_Set)(Outbuf *ob, Eina_Bool context_current);
struct _Render_Engine_GL_Generic
{
@ -24,6 +25,7 @@ struct _Render_Engine_GL_Generic
Window_EGL_Display_Get window_egl_display_get;
Window_GL_Context_New window_gl_context_new;
Window_GL_Context_Use window_gl_context_use;
Window_Context_Is_Current_Set window_context_is_current_set;
struct {
Evas_Object_Image_Pixels_Get_Cb get_pixels;
@ -56,6 +58,7 @@ evas_render_engine_gl_generic_init(Render_Engine_GL_Generic *re,
Window_EGL_Display_Get window_egl_display_get,
Window_GL_Context_New window_gl_context_new,
Window_GL_Context_Use window_gl_context_use,
Window_Context_Is_Current_Set window_context_is_current_set,
const EVGL_Interface *evgl_funcs,
int w, int h)
{
@ -78,6 +81,7 @@ evas_render_engine_gl_generic_init(Render_Engine_GL_Generic *re,
re->window_egl_display_get = window_egl_display_get;
re->window_gl_context_new = window_gl_context_new;
re->window_gl_context_use = window_gl_context_use;
re->window_context_is_current_set = window_context_is_current_set;
re->func.get_pixels = NULL;
re->func.get_pixels_data = NULL;

View File

@ -805,6 +805,23 @@ eng_image_data_preload_cancel(void *data EINA_UNUSED, void *image, const Eo *tar
evas_gl_preload_target_unregister(gim->tex, (Eo*) target);
}
static void
eng_gl_get_pixels_pre(void *data EINA_UNUSED)
{
evgl_get_pixels_pre();
}
static void
eng_gl_get_pixels_post(void *data)
{
Render_Engine_GL_Generic *re = data;
if (!re) return;
evgl_get_pixels_post();
if (re->window_context_is_current_set)
re->window_context_is_current_set(re->software.ob, EINA_FALSE);
}
static Eina_Bool
eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth, Eina_Bool do_async EINA_UNUSED)
{
@ -856,9 +873,9 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
direct_surface);
// Call pixel get function
evgl_get_pixels_pre();
eng_gl_get_pixels_pre(re);
re->func.get_pixels(re->func.get_pixels_data, re->func.obj);
evgl_get_pixels_post();
eng_gl_get_pixels_post(re);
// Call end tile if it's being used
if ((gl_context->master_clip.enabled) &&
@ -1374,18 +1391,6 @@ eng_gl_get_pixels_set(void *data, void *get_pixels, void *get_pixels_data, void
re->func.obj = (Evas_Object*)obj;
}
static void
eng_gl_get_pixels_pre(void *data EINA_UNUSED)
{
evgl_get_pixels_pre();
}
static void
eng_gl_get_pixels_post(void *data EINA_UNUSED)
{
evgl_get_pixels_post();
}
static Eina_Bool
eng_gl_surface_lock(void *data, void *surface)
{

View File

@ -318,6 +318,7 @@ eng_setup(Evas *eo_e, void *in)
_window_egl_display_get,
_window_gl_context_new,
_window_gl_context_use,
NULL,//eng_outbuf_context_is_current_set
&evgl_funcs,
e->output.w, e->output.h))
goto on_error;

View File

@ -1645,6 +1645,7 @@ eng_setup(Evas *eo_e, void *in)
eng_outbuf_egl_display_get,
eng_gl_context_new,
eng_gl_context_use,
eng_outbuf_context_is_current_set,
&evgl_funcs,
e->output.w, e->output.h))
{

View File

@ -108,6 +108,9 @@ struct _Outbuf
struct {
unsigned char drew : 1;
} draw;
Eina_Bool context_switch_optimize : 1;
Eina_Bool context_current : 1;
};
struct _Context_3D
@ -196,6 +199,7 @@ void eng_outbuf_push_updated_region(Outbuf *ob, RGBA_Image *update,
void eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode);
Evas_Engine_GL_Context *eng_outbuf_gl_context_get(Outbuf *ob);
void *eng_outbuf_egl_display_get(Outbuf *ob);
void eng_outbuf_context_is_current_set(Outbuf *ob, Eina_Bool context_current);
Eina_Bool eng_preload_make_current(void *data, void *doit);

View File

@ -133,7 +133,8 @@ eng_window_new(Evas_Engine_Info_GL_X11 *info,
#endif
const GLubyte *vendor, *renderer, *version, *glslversion;
int blacklist = 0;
int val = 0;
int val = 0, context_optimize_disable = 0;
char* s;
if (!fbconf) eng_best_visual_get(info);
if (!_evas_gl_x11_vi) return NULL;
@ -158,6 +159,15 @@ eng_window_new(Evas_Engine_Info_GL_X11 *info,
gw->depth_bits = depth_bits;
gw->stencil_bits = stencil_bits;
gw->msaa_bits = msaa_bits;
gw->context_current = EINA_FALSE;
if ((s = getenv("EVAS_GL_CONTEXT_SWITCH_OPTIMIZE_DISABLE")) != NULL)
context_optimize_disable = atoi(s);
if (context_optimize_disable == 1)
gw->context_switch_optimize = EINA_FALSE;
else
gw->context_switch_optimize = EINA_TRUE;
if (gw->alpha && _evas_gl_x11_rgba_vi)
gw->visualinfo = _evas_gl_x11_rgba_vi;
@ -581,6 +591,10 @@ eng_window_use(Outbuf *gw)
xwin = _tls_outbuf_get();
if (xwin && (xwin == gw))
if (gw->context_switch_optimize && gw->context_current)
return;
glsym_evas_gl_preload_render_lock(eng_window_make_current, gw);
#ifdef GL_GLES
if (xwin)
@ -635,6 +649,8 @@ eng_window_use(Outbuf *gw)
ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->win, (void *)gw->context);
}
#endif
if (xwin) xwin->context_current = EINA_FALSE;
gw->context_current = EINA_TRUE;
}
}
if (gw) glsym_evas_gl_common_context_use(gw->gl_context);
@ -1459,3 +1475,12 @@ eng_outbuf_egl_display_get(Outbuf *ob)
return NULL;
#endif
}
void
eng_outbuf_context_is_current_set(Outbuf *ob, Eina_Bool context_current)
{
if (!ob) return;
ob->context_current = context_current;
return;
}

View File

@ -618,6 +618,7 @@ eng_setup(Evas *evas, void *info)
eng_outbuf_egl_display_get,
eng_gl_context_new,
eng_gl_context_use,
NULL, //eng_outbuf_context_is_current_set
&evgl_funcs,
epd->output.w, epd->output.h))
{