raster pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=acf4e6742098c6aacb81cd7a1488cd3faa8eec7c
commit acf4e6742098c6aacb81cd7a1488cd3faa8eec7c Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Tue Jul 29 23:19:52 2014 +0900 ecore-x-vsync - found issue when vt switchign with nvidia - workaround --- src/lib/ecore_x/ecore_x_vsync_tool.c | 7 ++- src/lib/ecore_x/ecore_x_vsync_tool_glx.c | 90 +++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/src/lib/ecore_x/ecore_x_vsync_tool.c b/src/lib/ecore_x/ecore_x_vsync_tool.c index 34c9340..07b702f 100644 --- a/src/lib/ecore_x/ecore_x_vsync_tool.c +++ b/src/lib/ecore_x/ecore_x_vsync_tool.c @@ -88,9 +88,11 @@ static void _tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg) { double *t = msg; + static double pt = 0.0; if (t) { + pt = *t; _svr_broadcast_time(*t); free(t); } @@ -228,8 +230,8 @@ _svr_init(void) { if (*s == ':') *s = '='; } - svr = ecore_con_server_add(ECORE_CON_LOCAL_USER, buf, 1, NULL); - if (!svr) exit(0); +// svr = ecore_con_server_add(ECORE_CON_LOCAL_USER, buf, 1, NULL); +// if (!svr) exit(0); ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, _svr_add, NULL); ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, _svr_del, NULL); ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, _svr_data, NULL); @@ -248,6 +250,7 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED) if (!_vsync_init()) return 7; _svr_init(); _tick_init(); + _tick_start(); ecore_main_loop_begin(); _tick_send(-1); diff --git a/src/lib/ecore_x/ecore_x_vsync_tool_glx.c b/src/lib/ecore_x/ecore_x_vsync_tool_glx.c index 1d5b347..a6f6a0c 100644 --- a/src/lib/ecore_x/ecore_x_vsync_tool_glx.c +++ b/src/lib/ecore_x/ecore_x_vsync_tool_glx.c @@ -188,6 +188,15 @@ static void *disp = NULL; static long gwin = 0; static void *context = NULL; +static int _vsync_init_glx2(void); + +static void +_vsync_shutdown_glx(void) +{ + if (disp) sym_XCloseDisplay(disp); + disp = NULL; +} + static void * lib_load(const char *files[]) { @@ -206,22 +215,6 @@ int _vsync_init_glx(void) { int fail = 0; - GLXFBConfig *fbconfigs; - int num = 0; - int attr[] = - { - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DOUBLEBUFFER, 1, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - 0 - }; - XVisualInfo *vi; - XSetWindowAttributes wa; - long win; - const char *extns; /*---------------------------*/ lib_x11 = lib_load(lib_x11_files); @@ -252,40 +245,65 @@ _vsync_init_glx(void) if (fail) goto err; /*---------------------------*/ + if (!_vsync_init_glx2()) goto err; + return 1; + +err: + if (disp) sym_XCloseDisplay(disp); + if (lib_gl) dlclose(lib_gl); + if (lib_x11) dlclose(lib_x11); + return 0; +} + +static int +_vsync_init_glx2(void) +{ + GLXFBConfig *fbconfigs; + int num = 0; + int attr[] = + { + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DOUBLEBUFFER, 1, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + 0 + }; + XVisualInfo *vi; + XSetWindowAttributes wa; + long win; + const char *extns; + disp = sym_XOpenDisplay(NULL); - if (!disp) goto err; + if (!disp) return 0; fbconfigs = sym_glXChooseFBConfig(disp, 0, attr, &num); - if (!fbconfigs) goto err; + if (!fbconfigs) return 0; vi = sym_glXGetVisualFromFBConfig(disp, fbconfigs[0]); - if (!vi) goto err; + if (!vi) return 0; wa.override_redirect = 1; wa.border_pixel = 0; wa.colormap = sym_XCreateColormap(disp, RootWindow(disp, vi->screen), vi->visual, AllocNone); - if (!wa.colormap) goto err; + if (!wa.colormap) return 0; win = sym_XCreateWindow(disp, RootWindow(disp, vi->screen), -77, -777, 1, 1, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWOverrideRedirect, &wa); - if (!win) goto err; + if (!win) return 0; context = sym_glXCreateNewContext(disp, fbconfigs[0], GLX_RGBA_TYPE, NULL, 1); - if (!context) goto err; + if (!context) return 0; gwin = sym_glXCreateWindow(disp, fbconfigs[0], win, NULL); - if (!gwin) goto err; + if (!gwin) return 0; extns = sym_glXQueryExtensionsString(disp, 0); - if (!extns) goto err; - if (!strstr(extns, "GLX_SGI_swap_control")) goto err; + if (!extns) return 0; + if (!strstr(extns, "GLX_SGI_swap_control")) return 0; sym_glXGetVideoSyncSGI = sym_glXGetProcAddressARB("glXGetVideoSyncSGI"); sym_glXWaitVideoSyncSGI = sym_glXGetProcAddressARB("glXWaitVideoSyncSGI"); - if ((!sym_glXGetVideoSyncSGI) || (!sym_glXWaitVideoSyncSGI)) goto err; + if ((!sym_glXGetVideoSyncSGI) || (!sym_glXWaitVideoSyncSGI)) return 0; return 1; -err: - if (disp) sym_XCloseDisplay(disp); - if (lib_gl) dlclose(lib_gl); - if (lib_x11) dlclose(lib_x11); - return 0; } double @@ -293,10 +311,20 @@ _vsync_wait_glx(void) { double t; unsigned int rc = 0; + static unsigned int prc = 0; +again: sym_glXMakeContextCurrent(disp, gwin, gwin, context); sym_glXGetVideoSyncSGI(&rc); sym_glXWaitVideoSyncSGI(1, 0, &rc); + if (prc == rc) + { + _vsync_shutdown_glx(); + usleep(200000); + if (!_vsync_init_glx2()) exit(1); + goto again; + } + prc = rc; t = ecore_time_get(); return t; } --