From 389cf13db5657bad150ab4ae85c5607f33f99c41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Nov 2015 18:50:49 +0100 Subject: [PATCH] Don't reference driver->video_data outside of gx/video_driver.c anymore --- driver.c | 16 ++-------------- gfx/d3d/d3d.cpp | 10 ++++------ gfx/image/image.c | 3 +-- gfx/video_driver.c | 8 ++++++++ gfx/video_shader_driver.c | 7 ++++--- gfx/video_thread_wrapper.c | 7 ++----- input/drivers/sdl_input.c | 3 +-- menu/cbs/menu_cbs_get_value.c | 5 ----- menu/drivers_display/menu_display_d3d.cpp | 8 +------- menu/drivers_display/menu_display_gl.c | 6 ++---- 10 files changed, 25 insertions(+), 48 deletions(-) diff --git a/driver.c b/driver.c index c7e906b2de..3184cb552c 100644 --- a/driver.c +++ b/driver.c @@ -236,7 +236,7 @@ static void driver_adjust_system_rates(void) audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); - if (!driver->video_data) + if (!video_driver_get_ptr(false)) return; if (system->force_nonblock) @@ -276,7 +276,7 @@ void driver_set_nonblock_state(bool enable) driver_t *driver = driver_get_ptr(); /* Only apply non-block-state for video if we're using vsync. */ - if (driver->video_active && driver->video_data) + if (driver->video_active && video_driver_get_ptr(false)) { bool video_nonblock = enable; @@ -464,18 +464,6 @@ void uninit_drivers(int flags) if (flags & DRIVERS_VIDEO_INPUT) video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT, NULL); - if (flags & DRIVER_VIDEO) - { - const struct retro_hw_render_callback *hw_render = - (const struct retro_hw_render_callback*)video_driver_callback(); - - if (hw_render->context_destroy && !driver->video_cache_context) - hw_render->context_destroy(); - } - - if ((flags & DRIVER_VIDEO) && !driver->video_data_own) - driver->video_data = NULL; - if ((flags & DRIVER_INPUT) && !driver->input_data_own) driver->input_data = NULL; diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 77518825a3..9734b606ce 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -730,7 +730,6 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data) /* Default to Direct3D9 for now. TODO: GL core contexts through ANGLE? */ unsigned minor = 0; - driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); #if defined(HAVE_D3D8) unsigned major = 8; @@ -739,7 +738,7 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data) unsigned major = 9; enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API; #endif - return gfx_ctx_init_first(driver->video_data, + return gfx_ctx_init_first(video_driver_get_ptr(false), settings->video.context_driver, api, major, minor, false); } @@ -748,13 +747,12 @@ static void *d3d_init(const video_info_t *info, const input_driver_t **input, void **input_data) { d3d_video_t *vid = NULL; - driver_t *driver = driver_get_ptr(); const gfx_ctx_driver_t *ctx = NULL; #ifdef _XBOX - if (driver->video_data) + if (video_driver_get_ptr(false)) { - d3d_video_t *vid = (d3d_video_t*)driver->video_data; + d3d_video_t *vid = (d3d_video_t*)video_driver_get_ptr(false); /* Reinitialize renderchain as we * might have changed pixel formats.*/ @@ -771,7 +769,7 @@ static void *d3d_init(const video_info_t *info, driver->video_data_own = true; driver->input_data_own = true; - return driver->video_data; + return vid; } } #endif diff --git a/gfx/image/image.c b/gfx/image/image.c index ecf88c713f..11af97fabc 100644 --- a/gfx/image/image.c +++ b/gfx/image/image.c @@ -186,8 +186,7 @@ void texture_image_free(struct texture_image *img) bool texture_image_load(struct texture_image *out_img, const char *path) { D3DXIMAGE_INFO m_imageInfo; - driver_t *driver = driver_get_ptr(); - d3d_video_t *d3d = (d3d_video_t*)driver->video_data; + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false); LPDIRECT3DTEXTURE d3dt = (LPDIRECT3DTEXTURE)out_img->texture_buf; LPDIRECT3DVERTEXBUFFER d3dv = (LPDIRECT3DVERTEXBUFFER)out_img->vertex_buf; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index bfdf79cde3..61a9294681 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -505,6 +505,8 @@ static void deinit_pixel_converter(void) static bool uninit_video_input(void) { driver_t *driver = driver_get_ptr(); + const struct retro_hw_render_callback *hw_render = + (const struct retro_hw_render_callback*)video_driver_callback(); event_command(EVENT_CMD_OVERLAY_DEINIT); @@ -529,8 +531,14 @@ 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) + hw_render->context_destroy(); + current_video = NULL; + if (!driver->video_data_own) + driver->video_data = NULL; + return true; } diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index ae4a9f180d..d4b18cb4c4 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -72,14 +72,15 @@ const shader_backend_t *shader_ctx_init_first(void) struct video_shader *video_shader_driver_get_current_shader(void) { - driver_t *driver = driver_get_ptr(); + driver_t *driver = driver_get_ptr(); + void *video_driver = video_driver_get_ptr(true); if (!driver->video_poke) return NULL; - if (!driver->video_data) + if (!video_driver) return NULL; if (!driver->video_poke->get_current_shader) return NULL; - return driver->video_poke->get_current_shader(driver->video_data); + return driver->video_poke->get_current_shader(video_driver); } void video_shader_scale(unsigned idx, diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 8458a1bf79..5bfca6e1bb 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -1131,8 +1131,7 @@ bool rarch_threaded_video_init(const video_driver_t **out_driver, **/ void *rarch_threaded_video_get_ptr(const video_driver_t **drv) { - driver_t *driver = driver_get_ptr(); - const thread_video_t *thr = (const thread_video_t*)driver->video_data; + const thread_video_t *thr = (const thread_video_t*)video_driver_get_ptr(true); if (drv) *drv = thr->driver; @@ -1144,9 +1143,7 @@ void *rarch_threaded_video_get_ptr(const video_driver_t **drv) const char *rarch_threaded_video_get_ident(void) { - driver_t *driver = driver_get_ptr(); - const thread_video_t *thr = driver ? (const thread_video_t*) - driver->video_data : NULL; + const thread_video_t *thr = (const thread_video_t*)video_driver_get_ptr(true); if (!thr || !thr->driver) return NULL; diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 604ff82bce..c4f771b541 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -299,12 +299,11 @@ static void sdl_grab_mouse(void *data, bool state) struct temp{ SDL_Window *w; }; - driver_t *driver = driver_get_ptr(); if (!strcmp(video_driver_get_ident(), "sdl2")) { /* First member of sdl2_video_t is the window */ - SDL_SetWindowGrab(((struct temp*)driver->video_data)->w, + SDL_SetWindowGrab(((struct temp*)video_driver_get_ptr(false))->w, state ? SDL_TRUE : SDL_FALSE); } #endif diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 9dfc602b1b..2c1210c0ea 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -252,11 +252,6 @@ static void menu_action_setting_disp_set_label_shader_parameter( const struct video_shader_parameter *param = NULL; struct video_shader *shader = NULL; #endif - driver_t *driver = driver_get_ptr(); - - if (!driver->video_poke || !driver->video_data) - return; - *s = '\0'; *w = 19; strlcpy(s2, path, len2); diff --git a/menu/drivers_display/menu_display_d3d.cpp b/menu/drivers_display/menu_display_d3d.cpp index 77fca9bbef..26dc453cf6 100644 --- a/menu/drivers_display/menu_display_d3d.cpp +++ b/menu/drivers_display/menu_display_d3d.cpp @@ -140,11 +140,6 @@ static void menu_display_d3d_draw( d3d_set_viewport(d3d->dev, &vp); d3d_set_texture(d3d->dev, 0, (LPDIRECT3DTEXTURE)texture); -#if 0 - gl->shader->set_coords(coords); - gl->shader->set_mvp(driver->video_data, mat); -#endif - d3d_draw_primitive(d3d->dev, (D3DPRIMITIVETYPE)menu_display_prim_to_d3d_enum(prim_type), 0, coords->vertices); #if 0 @@ -254,8 +249,7 @@ static bool menu_display_d3d_font_init_first(const void **font_driver, if (settings->video.threaded && !hw_render->context_type) { thread_packet_t pkt; - driver_t *driver = driver_get_ptr(); - thread_video_t *thr = (thread_video_t*)driver->video_data; + thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true); if (!thr) return false; diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 90de5d33a3..968aa53d9e 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -100,7 +100,6 @@ static void menu_display_gl_draw( enum menu_display_prim_type prim_type ) { - driver_t *driver = driver_get_ptr(); gl_t *gl = gl_get_ptr(); math_matrix_4x4 *mat = (math_matrix_4x4*)matrix_data; @@ -124,7 +123,7 @@ static void menu_display_gl_draw( glBindTexture(GL_TEXTURE_2D, (GLuint)texture); gl->shader->set_coords(coords); - gl->shader->set_mvp(driver->video_data, mat); + gl->shader->set_mvp(video_driver_get_ptr(false), mat); glDrawArrays(menu_display_prim_to_gl_enum(prim_type), 0, coords->vertices); @@ -226,8 +225,7 @@ static bool menu_display_gl_font_init_first(const void **font_driver, if (settings->video.threaded && !hw_render->context_type) { thread_packet_t pkt; - driver_t *driver = driver_get_ptr(); - thread_video_t *thr = (thread_video_t*)driver->video_data; + thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true); if (!thr) return false;