forked from enlightenment/efl
Added Debug feature for Evas GL's GL APIs. It can be set with
EVAS_GL_API_DEBUG=1 and when it is set, all the GL calls will check if make_current has been properly called. Also, it'll check if all the GL calls are called within the Pixel Getter function for Direct Rendering option. SVN revision: 77522
This commit is contained in:
parent
eb9cbc76a0
commit
52e4090f92
|
@ -1071,3 +1071,13 @@
|
|||
2012-10-03 Mike Blumenkrantz
|
||||
|
||||
* evas_object_del() now accepts NULL more peacefully
|
||||
|
||||
2012-10-05 Sung W. Park (sung_)
|
||||
|
||||
* Added Debug feature for Evas GL's GL APIs. It can be set with
|
||||
EVAS_GL_API_DEBUG=1 and when it is set, all the GL calls will check
|
||||
if make_current has been properly called. Also, it'll check if all
|
||||
the GL calls are called within the Pixel Getter function for Direct
|
||||
Rendering option.
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ Additions:
|
|||
* EVAS_CALLBACK_IMAGE_RESIZE.
|
||||
* Evas_Device registration/manipulation/querying API
|
||||
* Evas_Object_Display_Mode querying API
|
||||
* EVAS_GL_API_DEBUG=1 env. var option for outputting debug logs related to Evas GL's GL calls.
|
||||
|
||||
Improvements:
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ typedef struct _GL_Format
|
|||
// Globals
|
||||
static Evas_GL_API gl_funcs;
|
||||
EVGL_Engine *evgl_engine = NULL;
|
||||
int _evas_gl_log_dom = -1;
|
||||
|
||||
static void _surface_cap_print(EVGL_Engine *ee, int error);
|
||||
|
||||
|
@ -159,8 +160,6 @@ _internal_resources_create(EVGL_Engine *ee)
|
|||
goto error;
|
||||
}
|
||||
|
||||
|
||||
//rsc->surface = ee->funcs->surface_create(ee->engine_data);
|
||||
if (!rsc->surface)
|
||||
{
|
||||
ERR("Internal resource surface failed.");
|
||||
|
@ -924,7 +923,7 @@ _internal_config_set(EVGL_Engine *ee, EVGL_Surface *sfc, Evas_GL_Config *cfg)
|
|||
sfc->msaa_samples = ee->caps.fbo_fmts[i].samples;
|
||||
|
||||
// Direct Rendering Option
|
||||
if (!stencil_bit)
|
||||
if ( (!stencil_bit) || (ee->direct_override) )
|
||||
sfc->direct_fb_opt = cfg->options_bits & EVAS_GL_OPTIONS_DIRECT;
|
||||
|
||||
cfg_index = i;
|
||||
|
@ -952,6 +951,22 @@ _internal_config_set(EVGL_Engine *ee, EVGL_Surface *sfc, Evas_GL_Config *cfg)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_evgl_direct_renderable(EVGL_Engine *ee, EVGL_Context *ctx, EVGL_Surface *sfc)
|
||||
{
|
||||
EVGL_Resource *rsc;
|
||||
|
||||
if (!(rsc=_evgl_tls_resource_get(ee))) return 0;
|
||||
|
||||
if (ee->force_direct_off) return 0;
|
||||
if (rsc->id != ee->main_tid) return 0;
|
||||
if (!ctx) return 0;
|
||||
if (!sfc->direct_fb_opt) return 0;
|
||||
if (!rsc->direct_img_obj) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------//
|
||||
// Retrieve the internal resource object from TLS
|
||||
//---------------------------------------------------------------//
|
||||
|
@ -1010,9 +1025,18 @@ _evgl_current_context_get()
|
|||
EVGL_Engine *
|
||||
evgl_engine_create(EVGL_Interface *efunc, void *engine_data)
|
||||
{
|
||||
int direct_off = 0;
|
||||
int direct_off = 0, debug_mode = 0;
|
||||
char *s = NULL;
|
||||
|
||||
// Initialize Log Domain
|
||||
if (_evas_gl_log_dom < 0)
|
||||
_evas_gl_log_dom = eina_log_domain_register("EvasGL", EVAS_DEFAULT_LOG_COLOR);
|
||||
if (_evas_gl_log_dom < 0)
|
||||
{
|
||||
EINA_LOG_ERR("Can not create a module log domain.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Check the validity of the efunc
|
||||
if ((!efunc) ||
|
||||
(!efunc->surface_create) ||
|
||||
|
@ -1072,6 +1096,14 @@ evgl_engine_create(EVGL_Interface *efunc, void *engine_data)
|
|||
if (direct_off == 1)
|
||||
evgl_engine->force_direct_off = 1;
|
||||
|
||||
// Check if API Debug mode is on
|
||||
s = getenv("EVAS_GL_API_DEBUG");
|
||||
if (s) debug_mode = atoi(s);
|
||||
if (debug_mode == 1)
|
||||
evgl_engine->api_debug_mode = 1;
|
||||
|
||||
|
||||
// Maint Thread ID (get tid not available in eina thread yet)
|
||||
evgl_engine->main_tid = 0;
|
||||
|
||||
// Clear Function Pointers
|
||||
|
@ -1098,7 +1130,12 @@ int evgl_engine_destroy(EVGL_Engine *ee)
|
|||
ERR("EVGL Engine not valid!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Log
|
||||
if (_evas_gl_log_dom >= 0) return 0;
|
||||
eina_log_domain_unregister(_evas_gl_log_dom);
|
||||
_evas_gl_log_dom = -1;
|
||||
|
||||
// Destroy internal resources
|
||||
_internal_resources_destroy(ee);
|
||||
|
||||
|
@ -1147,6 +1184,15 @@ evgl_surface_create(EVGL_Engine *ee, Evas_GL_Config *cfg, int w, int h)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Check for Direct rendering override env var.
|
||||
if (!ee->direct_override)
|
||||
if ((s = getenv("EVAS_GL_DIRECT_OVERRIDE")))
|
||||
{
|
||||
direct_override = atoi(s);
|
||||
if (direct_override == 1)
|
||||
ee->direct_override = 1;
|
||||
}
|
||||
|
||||
// Allocate surface structure
|
||||
sfc = calloc(1, sizeof(EVGL_Surface));
|
||||
if (!sfc)
|
||||
|
@ -1173,14 +1219,6 @@ evgl_surface_create(EVGL_Engine *ee, Evas_GL_Config *cfg, int w, int h)
|
|||
goto error;
|
||||
};
|
||||
|
||||
if (!ee->direct_override)
|
||||
if ((s = getenv("EVAS_GL_DIRECT_OVERRIDE")))
|
||||
{
|
||||
direct_override = atoi(s);
|
||||
if (direct_override == 1)
|
||||
ee->direct_override = 1;
|
||||
}
|
||||
|
||||
return sfc;
|
||||
|
||||
error:
|
||||
|
@ -1210,8 +1248,16 @@ evgl_surface_destroy(EVGL_Engine *ee, EVGL_Surface *sfc)
|
|||
|
||||
if ((rsc->current_ctx) && (rsc->current_ctx->current_sfc == sfc) )
|
||||
{
|
||||
ERR("The surface is still current before it's being destroyed.");
|
||||
ERR("Doing make_current(NULL, NULL)");
|
||||
if (ee->api_debug_mode)
|
||||
{
|
||||
ERR("The surface is still current before it's being destroyed.");
|
||||
ERR("Doing make_current(NULL, NULL)");
|
||||
}
|
||||
else
|
||||
{
|
||||
WRN("The surface is still current before it's being destroyed.");
|
||||
WRN("Doing make_current(NULL, NULL)");
|
||||
}
|
||||
evgl_make_current(ee, NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -1379,22 +1425,8 @@ evgl_make_current(EVGL_Engine *ee, EVGL_Surface *sfc, EVGL_Context *ctx)
|
|||
if (!ctx->surface_fbo)
|
||||
glGenFramebuffers(1, &ctx->surface_fbo);
|
||||
|
||||
// Attach fbo and the buffers
|
||||
if (ctx->current_sfc != sfc)
|
||||
{
|
||||
if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo))
|
||||
{
|
||||
ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", ee, sfc, ctx->surface_fbo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Bind to the previously bound buffer
|
||||
if (ctx->current_fbo)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
|
||||
}
|
||||
|
||||
// Direct Rendering
|
||||
if (evgl_direct_enabled(ee))
|
||||
if (_evgl_direct_renderable(ee, ctx, sfc))
|
||||
{
|
||||
// This is to transition from FBO rendering to direct rendering
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
|
||||
|
@ -1403,10 +1435,28 @@ evgl_make_current(EVGL_Engine *ee, EVGL_Surface *sfc, EVGL_Context *ctx)
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
ctx->current_fbo = 0;
|
||||
}
|
||||
rsc->direct_enabled = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attach fbo and the buffers
|
||||
if (ctx->current_sfc != sfc)
|
||||
{
|
||||
if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo))
|
||||
{
|
||||
ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", ee, sfc, ctx->surface_fbo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Bind to the previously bound buffer
|
||||
if (ctx->current_fbo)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
|
||||
}
|
||||
|
||||
rsc->direct_enabled = 0;
|
||||
}
|
||||
|
||||
ctx->current_sfc = sfc;
|
||||
|
||||
rsc->current_ctx = ctx;
|
||||
|
||||
return 1;
|
||||
|
@ -1456,6 +1506,23 @@ evgl_native_surface_get(EVGL_Engine *ee, EVGL_Surface *sfc, Evas_Native_Surface
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
_evgl_not_in_pixel_get(EVGL_Engine *ee)
|
||||
{
|
||||
EVGL_Resource *rsc;
|
||||
|
||||
if (!(rsc=_evgl_tls_resource_get(ee))) return 1;
|
||||
|
||||
EVGL_Context *ctx = rsc->current_ctx;
|
||||
|
||||
if ((!ee->force_direct_off) && (rsc->id == ee->main_tid) &&
|
||||
(ctx) && (ctx->current_sfc) && (ctx->current_sfc->direct_fb_opt) &&
|
||||
(!rsc->direct_img_obj))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
evgl_direct_enabled(EVGL_Engine *ee)
|
||||
{
|
||||
|
@ -1463,17 +1530,7 @@ evgl_direct_enabled(EVGL_Engine *ee)
|
|||
|
||||
if (!(rsc=_evgl_tls_resource_get(ee))) return 0;
|
||||
|
||||
EVGL_Context *ctx = rsc->current_ctx;
|
||||
|
||||
if (ee->force_direct_off) return 0;
|
||||
|
||||
if (rsc->id != ee->main_tid) return 0;
|
||||
if (!ctx) return 0;
|
||||
if (!ctx->current_sfc) return 0;
|
||||
if (!ctx->current_sfc->direct_fb_opt) return 0;
|
||||
if (!rsc->direct_img_obj) return 0;
|
||||
|
||||
return 1;
|
||||
return rsc->direct_enabled;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1497,9 +1554,9 @@ evgl_direct_img_obj_get(EVGL_Engine *ee)
|
|||
}
|
||||
|
||||
Evas_GL_API *
|
||||
evgl_api_get(EVGL_Engine *ee __UNUSED__)
|
||||
evgl_api_get(EVGL_Engine *ee)
|
||||
{
|
||||
_evgl_api_get(&gl_funcs);
|
||||
_evgl_api_get(&gl_funcs, ee->api_debug_mode);
|
||||
|
||||
return &gl_funcs;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,33 @@
|
|||
|
||||
//#include "evas_gl_ext.h"
|
||||
|
||||
extern int _evas_gl_log_dom;
|
||||
|
||||
#ifdef ERR
|
||||
# undef ERR
|
||||
#endif
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_evas_gl_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef DBG
|
||||
# undef DBG
|
||||
#endif
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(_evas_gl_log_dom, __VA_ARGS__)
|
||||
#ifdef INF
|
||||
# undef INF
|
||||
#endif
|
||||
#define INF(...) EINA_LOG_DOM_INFO(_evas_gl_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef WRN
|
||||
# undef WRN
|
||||
#endif
|
||||
#define WRN(...) EINA_LOG_DOM_WARN(_evas_gl_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef CRIT
|
||||
# undef CRIT
|
||||
#endif
|
||||
#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_gl_log_dom, __VA_ARGS__)
|
||||
|
||||
|
||||
struct _EVGL_Interface
|
||||
{
|
||||
// Returns the native display of evas engine.
|
||||
|
@ -68,7 +95,6 @@ struct _EVGL_Surface
|
|||
|
||||
// Direct Rendering Option
|
||||
int direct_fb_opt;
|
||||
//int direct_override;
|
||||
|
||||
int cfg_index;
|
||||
|
||||
|
@ -76,9 +102,6 @@ struct _EVGL_Surface
|
|||
int fbo_attached;
|
||||
//-------------------------//
|
||||
|
||||
int direct_enabled;
|
||||
Evas_Object *direct_img_obj;
|
||||
|
||||
EVGL_Context *current_ctx;
|
||||
};
|
||||
|
||||
|
@ -173,8 +196,8 @@ struct _EVGL_Resource
|
|||
EVGLNative_Surface surface;
|
||||
|
||||
EVGL_Context *current_ctx;
|
||||
//EVGL_Surface *current_sfc;
|
||||
|
||||
int direct_enabled;
|
||||
Evas_Object *direct_img_obj;
|
||||
};
|
||||
|
||||
|
@ -206,6 +229,7 @@ struct _EVGL_Engine
|
|||
|
||||
|
||||
int direct_override;
|
||||
int api_debug_mode;
|
||||
|
||||
// Force Off fo Debug purposes
|
||||
int force_direct_off;
|
||||
|
@ -213,12 +237,14 @@ struct _EVGL_Engine
|
|||
void *engine_data;
|
||||
};
|
||||
|
||||
|
||||
// Evas GL Engine
|
||||
extern EVGL_Engine *evgl_engine;
|
||||
|
||||
// Internally used functions
|
||||
extern void _evgl_api_get(Evas_GL_API *api);
|
||||
extern EVGL_Resource *_evgl_tls_resource_get();
|
||||
extern void _evgl_api_get(Evas_GL_API *api, int debug);
|
||||
extern EVGL_Resource *_evgl_tls_resource_get(EVGL_Engine *ee);
|
||||
extern EVGL_Context *_evgl_current_context_get();
|
||||
extern int _evgl_not_in_pixel_get();
|
||||
|
||||
#endif //_EVAS_GL_CORE_PRIVATE_H
|
||||
|
|
Loading…
Reference in New Issue