From 1093db2d58529f6cc3cd17744d5dc70e9aa28739 Mon Sep 17 00:00:00 2001 From: Minkyoung Kim Date: Tue, 27 Dec 2016 17:15:30 +0900 Subject: [PATCH] Evas GL: Skip FBO creation when direct_mem_opt is set, unless direct fallback is set. Summary: When direct_mem_opt is set, FBO should not be created, unless the render target for direct rendering is FBO. There are cases where evas_gl_make_current is called outside on pixel callback in webkit, and since they use direct_mem_opt, FBO is repeatedly created/destroyed during switch from direct to indirect. This should fix it. @tizen_fix : bug fix Change-Id: I5e73913069f2b214e0cbd0e7136d1221ed0fb95c --- src/modules/evas/engines/gl_common/evas_gl_core.c | 102 ++++++++++++++------- src/modules/evas/engines/gl_common/evas_gl_core.h | 3 + .../evas/engines/gl_common/evas_gl_core_private.h | 2 + src/modules/evas/engines/gl_generic/evas_engine.c | 7 ++ 4 files changed, 79 insertions(+), 35 deletions(-) mode change 100644 => 100755 src/modules/evas/engines/gl_common/evas_gl_core.h diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c index 5e9caea..0d923ef 100755 --- a/src/modules/evas/engines/gl_common/evas_gl_core.c +++ b/src/modules/evas/engines/gl_common/evas_gl_core.c @@ -2618,19 +2618,25 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx) } else { - // Create internal buffers if not yet created - // TIZEN_ONLY(20171110) : Direct rendering render to map fix - if (!sfc->buffers_allocated) - { - if (dbg) DBG("Allocating buffers for sfc %p", sfc); - if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, ctx->version)) - { - ERR("Unable Create Specificed Surfaces. Unsupported format!"); - evas_gl_common_error_set(EVAS_GL_BAD_ALLOC); - return 0; - } - sfc->buffers_allocated = 1; - } + if ((sfc->direct_fb_opt) && (!sfc->direct_fallback)) + { + DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!"); + } + else + { + // Create internal buffers if not yet created + if (!sfc->buffers_allocated) + { + if (dbg) DBG("Allocating buffers for sfc %p", sfc); + if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, ctx->version)) + { + ERR("Unable Create Specificed Surfaces. Unsupported format!"); + evas_gl_common_error_set(EVAS_GL_BAD_ALLOC); + return 0; + } + sfc->buffers_allocated = 1; + } + } } } else @@ -2824,33 +2830,39 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx) if ((ctx_changed) || (ctx->current_sfc != sfc) || (rsc->direct.rendered)) { sfc->current_ctx = ctx; - // If it's transitioning from direct render to fbo render - // Call end tiling - // TIZEN_ONLY(20171110) : Direct rendering render to map fix - if (rsc->direct.partial.enabled) - evgl_direct_partial_render_end(); - - if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo, ctx->version)) + if ((sfc->direct_mem_opt) && (sfc->direct_fb_opt) && (!sfc->direct_fallback)) { - ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo); - evas_gl_common_error_set(EVAS_GL_BAD_CONTEXT); - return 0; + DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!"); } + else + { + // If it's transitioning from direct render to fbo render + // Call end tiling + if (rsc->direct.partial.enabled) + evgl_direct_partial_render_end(); - // Bind to the previously bound buffer + if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo, ctx->version)) + { + ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo); + evas_gl_common_error_set(EVAS_GL_BAD_CONTEXT); + return 0; + } - if (ctx->version == EVAS_GL_GLES_3_X) - { - if (ctx->current_draw_fbo) - _framebuffer_draw_bind(ctx->current_draw_fbo, ctx->version); + // Bind to the previously bound buffer - if (ctx->current_read_fbo) - _framebuffer_read_bind(ctx->current_read_fbo, ctx->version); - } - else - { - if (ctx->current_fbo) - _framebuffer_bind(ctx->current_fbo, ctx->version); + if (ctx->version == EVAS_GL_GLES_3_X) + { + if (ctx->current_draw_fbo) + _framebuffer_draw_bind(ctx->current_draw_fbo, ctx->version); + + if (ctx->current_read_fbo) + _framebuffer_read_bind(ctx->current_read_fbo, ctx->version); + } + else + { + if (ctx->current_fbo) + _framebuffer_bind(ctx->current_fbo, ctx->version); + } } } rsc->direct.rendered = 0; @@ -3050,6 +3062,26 @@ evgl_native_surface_direct_opts_get(Evas_Native_Surface *ns, return EINA_TRUE; } +// TIZEN_ONLY(20171110) : Skip FBO creation when direct_mem_opt is set, unless direct fallback is set +void +evgl_native_surface_direct_fallback_set(Evas_Native_Surface *ns, + Eina_Bool direct_fallback) +{ + EVGL_Surface *sfc; + + if (!evgl_engine) return EINA_FALSE; + if (!ns) return EINA_FALSE; + + if (ns->type == EVAS_NATIVE_SURFACE_EVASGL && + ns->data.evasgl.surface) + { + sfc = ns->data.evasgl.surface; + } + else return; + + sfc->direct_fallback = direct_fallback; +} + void evgl_direct_info_set(int win_w, int win_h, int rot, unsigned int map_tex, int img_x, int img_y, int img_w, int img_h, diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.h b/src/modules/evas/engines/gl_common/evas_gl_core.h old mode 100644 new mode 100755 index 50d17cf..8401a10 --- a/src/modules/evas/engines/gl_common/evas_gl_core.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core.h @@ -83,6 +83,9 @@ Eina_Bool evgl_native_surface_direct_opts_get(Evas_Native_Surface *ns, Eina_Bool *direct_render, Eina_Bool *client_side_rotation, Eina_Bool *direct_override); +// TIZEN_ONLY(20171110) : Skip FBO creation when direct_mem_opt is set, unless direct fallback is set +void evgl_native_surface_direct_fallback_set(Evas_Native_Surface *ns, + Eina_Bool direct_fallback); void evgl_direct_partial_info_set(int pres); void evgl_direct_partial_info_clear(void); diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h index 47958ce..27c7fed 100755 --- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h @@ -121,6 +121,8 @@ struct _EVGL_Surface // Moved from evgl_engine unsigned direct_override : 1; unsigned direct_mem_opt : 1; + // TIZEN_ONLY(20171110) : Skip FBO creation when direct_mem_opt is set, unless direct fallback is set + unsigned direct_fallback : 1; // Set when render target for direct rendering is FBO // Init Flag unsigned buffers_skip_allocate : 1; diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 461104c..e5a8c0c 100755 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -1766,8 +1766,15 @@ eng_gl_surface_direct_renderable_get(void *eng, void *output, Evas_Native_Surfac { // TIZEN_ONLY(20171110) : Direct rendering render to map fix *override = EINA_FALSE; + // TIZEN_ONLY(20171110) : Skip FBO creation when direct_mem_opt is set, unless direct fallback is set + evgl_native_surface_direct_fallback_set(ns, EINA_TRUE); return EINA_FALSE; } + else + { + // TIZEN_ONLY(20171110) : Skip FBO creation when direct_mem_opt is set, unless direct fallback is set + evgl_native_surface_direct_fallback_set(ns, EINA_FALSE); + } return EINA_TRUE; } -- 2.7.4