Add path to cache GL context on reinit.

If successful, can avoid libretro GL reset context callback being
called.
This commit is contained in:
Themaister 2013-06-23 23:01:34 +02:00
parent b090f5ab36
commit e18af77412
4 changed files with 50 additions and 25 deletions

View File

@ -373,7 +373,7 @@ void init_drivers(void)
g_extern.frame_count = 0;
init_video_input();
if (g_extern.system.hw_render_callback.context_reset)
if (!driver.video_cache_context_ack && g_extern.system.hw_render_callback.context_reset)
g_extern.system.hw_render_callback.context_reset();
init_audio();

View File

@ -419,6 +419,11 @@ typedef struct driver
bool threaded_video;
// If set during context deinit, the driver should keep
// graphics context alive to avoid having to reset all context state.
bool video_cache_context;
bool video_cache_context_ack; // Set to true by driver if context caching succeeded.
// Set if the respective handles are owned by RetroArch driver core.
// Consoles upper logic will generally intialize the drivers before
// the driver core initializes. It will then be up to upper logic

View File

@ -113,19 +113,23 @@ static void gfx_ctx_check_window(bool *quit,
switch (event.type)
{
case ClientMessage:
if ((Atom)event.xclient.data.l[0] == g_quit_atom)
if (event.xclient.window == g_win &&
(Atom)event.xclient.data.l[0] == g_quit_atom)
g_quit = true;
break;
case DestroyNotify:
if (event.xdestroywindow.window == g_win)
g_quit = true;
break;
case MapNotify:
if (event.xmap.window == g_win)
g_has_focus = true;
break;
case UnmapNotify:
if (event.xunmap.window == g_win)
g_has_focus = false;
break;
@ -210,7 +214,9 @@ static bool gfx_ctx_init(void)
GLXFBConfig *fbcs = NULL;
g_quit = 0;
if (!g_dpy)
g_dpy = XOpenDisplay(NULL);
if (!g_dpy)
goto error;
@ -361,6 +367,8 @@ static bool gfx_ctx_set_video_mode(
XEvent event;
XIfEvent(g_dpy, &event, glx_wait_notify, NULL);
if (!g_ctx)
{
if (g_core)
{
const int attribs[] = {
@ -380,6 +388,12 @@ static bool gfx_ctx_set_video_mode(
RARCH_ERR("[GLX]: Failed to create new context.\n");
goto error;
}
}
else
{
driver.video_cache_context_ack = true;
RARCH_LOG("[GLX]: Using cached GL context.\n");
}
glXMakeContextCurrent(g_dpy, g_glx_win, g_glx_win, g_ctx);
XSync(g_dpy, False);
@ -445,9 +459,12 @@ static void gfx_ctx_destroy(void)
if (g_dpy && g_ctx)
{
glXMakeContextCurrent(g_dpy, None, None, NULL);
if (!driver.video_cache_context)
{
glXDestroyContext(g_dpy, g_ctx);
g_ctx = NULL;
}
}
if (g_win)
{
@ -487,7 +504,7 @@ static void gfx_ctx_destroy(void)
g_should_reset_mode = false;
}
if (g_dpy)
if (!driver.video_cache_context && g_dpy)
{
XCloseDisplay(g_dpy);
g_dpy = NULL;

View File

@ -1934,8 +1934,11 @@ void rarch_set_fullscreen(bool fullscreen)
{
g_settings.video.fullscreen = fullscreen;
driver.video_cache_context = true;
driver.video_cache_context_ack = false;
uninit_drivers();
init_drivers();
driver.video_cache_context = false;
// Poll input to avoid possibly stale data to corrupt things.
if (driver.input)