mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Add path to cache GL context on reinit.
If successful, can avoid libretro GL reset context callback being called.
This commit is contained in:
parent
b090f5ab36
commit
e18af77412
2
driver.c
2
driver.c
@ -373,7 +373,7 @@ void init_drivers(void)
|
|||||||
g_extern.frame_count = 0;
|
g_extern.frame_count = 0;
|
||||||
init_video_input();
|
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();
|
g_extern.system.hw_render_callback.context_reset();
|
||||||
|
|
||||||
init_audio();
|
init_audio();
|
||||||
|
5
driver.h
5
driver.h
@ -419,6 +419,11 @@ typedef struct driver
|
|||||||
|
|
||||||
bool threaded_video;
|
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.
|
// Set if the respective handles are owned by RetroArch driver core.
|
||||||
// Consoles upper logic will generally intialize the drivers before
|
// Consoles upper logic will generally intialize the drivers before
|
||||||
// the driver core initializes. It will then be up to upper logic
|
// the driver core initializes. It will then be up to upper logic
|
||||||
|
@ -113,20 +113,24 @@ static void gfx_ctx_check_window(bool *quit,
|
|||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case ClientMessage:
|
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;
|
g_quit = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
g_quit = true;
|
if (event.xdestroywindow.window == g_win)
|
||||||
|
g_quit = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MapNotify:
|
case MapNotify:
|
||||||
g_has_focus = true;
|
if (event.xmap.window == g_win)
|
||||||
|
g_has_focus = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UnmapNotify:
|
case UnmapNotify:
|
||||||
g_has_focus = false;
|
if (event.xunmap.window == g_win)
|
||||||
|
g_has_focus = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
@ -210,7 +214,9 @@ static bool gfx_ctx_init(void)
|
|||||||
GLXFBConfig *fbcs = NULL;
|
GLXFBConfig *fbcs = NULL;
|
||||||
g_quit = 0;
|
g_quit = 0;
|
||||||
|
|
||||||
g_dpy = XOpenDisplay(NULL);
|
if (!g_dpy)
|
||||||
|
g_dpy = XOpenDisplay(NULL);
|
||||||
|
|
||||||
if (!g_dpy)
|
if (!g_dpy)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -361,24 +367,32 @@ static bool gfx_ctx_set_video_mode(
|
|||||||
XEvent event;
|
XEvent event;
|
||||||
XIfEvent(g_dpy, &event, glx_wait_notify, NULL);
|
XIfEvent(g_dpy, &event, glx_wait_notify, NULL);
|
||||||
|
|
||||||
if (g_core)
|
|
||||||
{
|
|
||||||
const int attribs[] = {
|
|
||||||
GLX_CONTEXT_MAJOR_VERSION_ARB, g_major,
|
|
||||||
GLX_CONTEXT_MINOR_VERSION_ARB, g_minor,
|
|
||||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
|
||||||
None,
|
|
||||||
};
|
|
||||||
|
|
||||||
g_ctx = glx_create_context_attribs(g_dpy, g_fbc, NULL, True, attribs);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
g_ctx = glXCreateNewContext(g_dpy, g_fbc, GLX_RGBA_TYPE, 0, True);
|
|
||||||
|
|
||||||
if (!g_ctx)
|
if (!g_ctx)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[GLX]: Failed to create new context.\n");
|
if (g_core)
|
||||||
goto error;
|
{
|
||||||
|
const int attribs[] = {
|
||||||
|
GLX_CONTEXT_MAJOR_VERSION_ARB, g_major,
|
||||||
|
GLX_CONTEXT_MINOR_VERSION_ARB, g_minor,
|
||||||
|
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||||
|
None,
|
||||||
|
};
|
||||||
|
|
||||||
|
g_ctx = glx_create_context_attribs(g_dpy, g_fbc, NULL, True, attribs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_ctx = glXCreateNewContext(g_dpy, g_fbc, GLX_RGBA_TYPE, 0, True);
|
||||||
|
|
||||||
|
if (!g_ctx)
|
||||||
|
{
|
||||||
|
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);
|
glXMakeContextCurrent(g_dpy, g_glx_win, g_glx_win, g_ctx);
|
||||||
@ -445,8 +459,11 @@ static void gfx_ctx_destroy(void)
|
|||||||
if (g_dpy && g_ctx)
|
if (g_dpy && g_ctx)
|
||||||
{
|
{
|
||||||
glXMakeContextCurrent(g_dpy, None, None, NULL);
|
glXMakeContextCurrent(g_dpy, None, None, NULL);
|
||||||
glXDestroyContext(g_dpy, g_ctx);
|
if (!driver.video_cache_context)
|
||||||
g_ctx = NULL;
|
{
|
||||||
|
glXDestroyContext(g_dpy, g_ctx);
|
||||||
|
g_ctx = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_win)
|
if (g_win)
|
||||||
@ -487,7 +504,7 @@ static void gfx_ctx_destroy(void)
|
|||||||
g_should_reset_mode = false;
|
g_should_reset_mode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_dpy)
|
if (!driver.video_cache_context && g_dpy)
|
||||||
{
|
{
|
||||||
XCloseDisplay(g_dpy);
|
XCloseDisplay(g_dpy);
|
||||||
g_dpy = NULL;
|
g_dpy = NULL;
|
||||||
|
@ -1934,8 +1934,11 @@ void rarch_set_fullscreen(bool fullscreen)
|
|||||||
{
|
{
|
||||||
g_settings.video.fullscreen = fullscreen;
|
g_settings.video.fullscreen = fullscreen;
|
||||||
|
|
||||||
|
driver.video_cache_context = true;
|
||||||
|
driver.video_cache_context_ack = false;
|
||||||
uninit_drivers();
|
uninit_drivers();
|
||||||
init_drivers();
|
init_drivers();
|
||||||
|
driver.video_cache_context = false;
|
||||||
|
|
||||||
// Poll input to avoid possibly stale data to corrupt things.
|
// Poll input to avoid possibly stale data to corrupt things.
|
||||||
if (driver.input)
|
if (driver.input)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user