Move driver->video_cache_context and driver->video_cache_context_ack

to video_driver.c
This commit is contained in:
twinaphex 2015-11-29 20:44:51 +01:00
parent df9f0fc6d1
commit 1d44619f41
8 changed files with 48 additions and 28 deletions

View File

@ -1226,10 +1226,14 @@ bool event_command(enum event_command cmd)
const struct retro_hw_render_callback *hw_render =
(const struct retro_hw_render_callback*)video_driver_callback();
driver->video_cache_context = hw_render->cache_context;
driver->video_cache_context_ack = false;
if (hw_render->cache_context)
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT, NULL);
else
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, NULL);
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, NULL);
event_command(EVENT_CMD_RESET_CONTEXT);
driver->video_cache_context = false;
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, NULL);
/* Poll input to avoid possibly stale data to corrupt things. */
input_driver_ctl(RARCH_INPUT_CTL_POLL, NULL);

View File

@ -385,10 +385,10 @@ void init_drivers(int flags)
video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_RESET, NULL);
video_driver_ctl(RARCH_DISPLAY_CTL_INIT, NULL);
if (!driver->video_cache_context_ack
if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK, NULL)
&& hw_render->context_reset)
hw_render->context_reset();
driver->video_cache_context_ack = false;
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, NULL);
system->frame_time_last = 0;
}

View File

@ -229,14 +229,6 @@ typedef struct driver
const menu_ctx_driver_t *menu_ctx;
#endif
/* If set during context deinit, the driver should keep
* graphics context alive to avoid having to reset all
* context state. */
bool video_cache_context;
/* Set to true by driver if context caching succeeded. */
bool video_cache_context_ack;
/* Set this to true if the platform in question needs to 'own'
* the respective handle and therefore skip regular RetroArch
* driver teardown/reiniting procedure.

View File

@ -63,8 +63,6 @@ static int glx_nul_handler(Display *dpy, XErrorEvent *event)
static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
{
driver_t *driver = driver_get_ptr();
if (!glx)
return;
@ -76,7 +74,7 @@ static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
glFinish();
glXMakeContextCurrent(g_x11_dpy, None, None, NULL);
if (!driver->video_cache_context)
if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
{
if (glx->g_hw_ctx)
glXDestroyContext(g_x11_dpy, glx->g_hw_ctx);
@ -120,7 +118,7 @@ static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
glx->g_should_reset_mode = false;
}
if (!driver->video_cache_context && g_x11_dpy)
if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL) && g_x11_dpy)
{
XCloseDisplay(g_x11_dpy);
g_x11_dpy = NULL;
@ -283,7 +281,6 @@ static bool gfx_ctx_glx_set_video_mode(void *data,
XVisualInfo *vi = NULL;
XSetWindowAttributes swa = {0};
int (*old_handler)(Display*, XErrorEvent*) = NULL;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)
gfx_ctx_data_get_ptr();
@ -446,7 +443,7 @@ static bool gfx_ctx_glx_set_video_mode(void *data,
}
else
{
driver->video_cache_context_ack = true;
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL);
RARCH_LOG("[GLX]: Using cached GL context.\n");
}

View File

@ -158,10 +158,9 @@ static void sdl_ctx_swap_interval(void *data, unsigned interval)
}
static bool sdl_ctx_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
bool fullscreen)
{
unsigned fsflag = 0;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
@ -207,7 +206,7 @@ static bool sdl_ctx_set_video_mode(void *data, unsigned width, unsigned height,
#ifdef HAVE_SDL2
if (sdl->g_ctx)
driver->video_cache_context_ack = true;
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL);
else
{
sdl->g_ctx = SDL_GL_CreateContext(sdl->g_win);

View File

@ -100,7 +100,6 @@ void create_gl_context(HWND hwnd, bool *quit)
bool core_context;
const struct retro_hw_render_callback *hw_render =
(const struct retro_hw_render_callback*)video_driver_callback();
driver_t *driver = driver_get_ptr();
bool debug = hw_render->debug_context;
#ifdef _WIN32
@ -118,7 +117,7 @@ void create_gl_context(HWND hwnd, bool *quit)
if (g_hrc)
{
RARCH_LOG("[WGL]: Using cached GL context.\n");
driver->video_cache_context_ack = true;
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL);
}
else
{
@ -317,7 +316,6 @@ static bool gfx_ctx_wgl_init(void *data)
static void gfx_ctx_wgl_destroy(void *data)
{
driver_t *driver = driver_get_ptr();
HWND window = win32_get_window();
(void)data;
@ -327,7 +325,7 @@ static void gfx_ctx_wgl_destroy(void *data)
glFinish();
wglMakeCurrent(NULL, NULL);
if (!driver->video_cache_context)
if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
{
if (g_hw_hrc)
wglDeleteContext(g_hw_hrc);

View File

@ -75,6 +75,14 @@ typedef struct video_pixel_scaler
void *scaler_out;
} video_pixel_scaler_t;
/* If set during context deinit, the driver should keep
* graphics context alive to avoid having to reset all
* context state. */
static bool video_cache_context;
/* Set to true by driver if context caching succeeded. */
static bool video_cache_context_ack;
/* Opaque handles to currently running window.
* Used by e.g. input drivers which bind to a window.
* Drivers are responsible for setting these if an input driver
@ -548,7 +556,7 @@ static bool uninit_video_input(void)
event_command(EVENT_CMD_SHADER_DIR_DEINIT);
video_monitor_compute_fps_statistics();
if (hw_render->context_destroy && !driver->video_cache_context)
if (hw_render->context_destroy && !video_cache_context)
hw_render->context_destroy();
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_RGBA, NULL);
@ -1627,6 +1635,22 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
break;
case RARCH_DISPLAY_CTL_OWNS_DRIVER:
return video_data_own;
case RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT:
video_cache_context = true;
break;
case RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT:
video_cache_context = false;
break;
case RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT:
return video_cache_context;
case RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK:
video_cache_context_ack = true;
break;
case RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK:
video_cache_context_ack = false;
break;
case RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK:
return video_cache_context_ack;
case RARCH_DISPLAY_CTL_NONE:
default:
break;

View File

@ -316,7 +316,13 @@ enum rarch_display_ctl_state
RARCH_DISPLAY_CTL_GET_FRAME_COUNT,
RARCH_DISPLAY_CTL_SET_OWN_DRIVER,
RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER,
RARCH_DISPLAY_CTL_OWNS_DRIVER
RARCH_DISPLAY_CTL_OWNS_DRIVER,
RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT,
RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT,
RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT,
RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK,
RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK,
RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK
};
bool video_driver_ctl(enum rarch_display_ctl_state state, void *data);