mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +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,19 +113,23 @@ 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:
|
||||||
|
if (event.xdestroywindow.window == g_win)
|
||||||
g_quit = true;
|
g_quit = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MapNotify:
|
case MapNotify:
|
||||||
|
if (event.xmap.window == g_win)
|
||||||
g_has_focus = true;
|
g_has_focus = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UnmapNotify:
|
case UnmapNotify:
|
||||||
|
if (event.xunmap.window == g_win)
|
||||||
g_has_focus = false;
|
g_has_focus = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -210,7 +214,9 @@ static bool gfx_ctx_init(void)
|
|||||||
GLXFBConfig *fbcs = NULL;
|
GLXFBConfig *fbcs = NULL;
|
||||||
g_quit = 0;
|
g_quit = 0;
|
||||||
|
|
||||||
|
if (!g_dpy)
|
||||||
g_dpy = XOpenDisplay(NULL);
|
g_dpy = XOpenDisplay(NULL);
|
||||||
|
|
||||||
if (!g_dpy)
|
if (!g_dpy)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -361,6 +367,8 @@ 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_ctx)
|
||||||
|
{
|
||||||
if (g_core)
|
if (g_core)
|
||||||
{
|
{
|
||||||
const int attribs[] = {
|
const int attribs[] = {
|
||||||
@ -380,6 +388,12 @@ static bool gfx_ctx_set_video_mode(
|
|||||||
RARCH_ERR("[GLX]: Failed to create new context.\n");
|
RARCH_ERR("[GLX]: Failed to create new context.\n");
|
||||||
goto error;
|
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);
|
||||||
XSync(g_dpy, False);
|
XSync(g_dpy, False);
|
||||||
@ -445,9 +459,12 @@ 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);
|
||||||
|
if (!driver.video_cache_context)
|
||||||
|
{
|
||||||
glXDestroyContext(g_dpy, g_ctx);
|
glXDestroyContext(g_dpy, g_ctx);
|
||||||
g_ctx = NULL;
|
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