mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-18 17:04:34 +00:00
(video driver) Minor cleanups
This commit is contained in:
parent
19813a8958
commit
4b01726f48
@ -396,7 +396,7 @@ bool core_unload(void)
|
||||
|
||||
bool core_unload_game(void)
|
||||
{
|
||||
video_driver_deinit_hw_context();
|
||||
video_driver_free_hw_context();
|
||||
audio_driver_stop();
|
||||
core.retro_unload_game();
|
||||
core_game_loaded = false;
|
||||
|
2
driver.c
2
driver.c
@ -412,7 +412,7 @@ static void uninit_drivers(int flags)
|
||||
wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL);
|
||||
|
||||
if (flags & DRIVERS_VIDEO_INPUT)
|
||||
video_driver_deinit();
|
||||
video_driver_free();
|
||||
|
||||
if ((flags & DRIVER_VIDEO_MASK) && !video_driver_owns_driver())
|
||||
video_driver_destroy_data();
|
||||
|
@ -417,22 +417,28 @@ bool video_driver_set_shader(enum rarch_shader_type type,
|
||||
return false;
|
||||
}
|
||||
|
||||
static void deinit_video_filter(void)
|
||||
static void video_driver_filter_free(void)
|
||||
{
|
||||
rarch_softfilter_free(video_driver_state_filter);
|
||||
#ifdef _3DS
|
||||
linearFree(video_driver_state_buffer);
|
||||
#else
|
||||
free(video_driver_state_buffer);
|
||||
#endif
|
||||
if (video_driver_state_filter)
|
||||
rarch_softfilter_free(video_driver_state_filter);
|
||||
video_driver_state_filter = NULL;
|
||||
|
||||
if (video_driver_state_buffer)
|
||||
{
|
||||
#ifdef _3DS
|
||||
linearFree(video_driver_state_buffer);
|
||||
#else
|
||||
free(video_driver_state_buffer);
|
||||
#endif
|
||||
}
|
||||
video_driver_state_buffer = NULL;
|
||||
|
||||
video_driver_state_scale = 0;
|
||||
video_driver_state_out_bpp = 0;
|
||||
video_driver_state_out_rgb32 = false;
|
||||
}
|
||||
|
||||
static void init_video_filter(enum retro_pixel_format colfmt)
|
||||
static void video_driver_init_filter(enum retro_pixel_format colfmt)
|
||||
{
|
||||
unsigned width, height, pow2_x, pow2_y, maxsize;
|
||||
void *buf = NULL;
|
||||
@ -445,12 +451,6 @@ static void init_video_filter(enum retro_pixel_format colfmt)
|
||||
if (colfmt == RETRO_PIXEL_FORMAT_0RGB1555)
|
||||
colfmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||
|
||||
if (video_driver_is_hw_context())
|
||||
{
|
||||
RARCH_WARN("Cannot use CPU filters when hardware rendering is used.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (av_info)
|
||||
geom = (struct retro_game_geometry*)&av_info->geometry;
|
||||
|
||||
@ -487,9 +487,11 @@ static void init_video_filter(enum retro_pixel_format colfmt)
|
||||
|
||||
/* TODO: Aligned output. */
|
||||
#ifdef _3DS
|
||||
buf = linearMemAlign(width * height * video_driver_state_out_bpp, 0x80);
|
||||
buf = linearMemAlign(
|
||||
width * height * video_driver_state_out_bpp, 0x80);
|
||||
#else
|
||||
buf = malloc(width * height * video_driver_state_out_bpp);
|
||||
buf = malloc(
|
||||
width * height * video_driver_state_out_bpp);
|
||||
#endif
|
||||
if (!buf)
|
||||
goto error;
|
||||
@ -500,7 +502,7 @@ static void init_video_filter(enum retro_pixel_format colfmt)
|
||||
|
||||
error:
|
||||
RARCH_ERR("Softfilter initialization failed.\n");
|
||||
deinit_video_filter();
|
||||
video_driver_filter_free();
|
||||
}
|
||||
|
||||
static void init_video_input(const input_driver_t *tmp)
|
||||
@ -543,12 +545,6 @@ static void video_monitor_compute_fps_statistics(void)
|
||||
double stddev = 0.0;
|
||||
unsigned samples = 0;
|
||||
|
||||
if (video_driver_is_threaded())
|
||||
{
|
||||
RARCH_LOG("Monitor FPS estimation is disabled for threaded video.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_driver_frame_time_count <
|
||||
(2 * MEASURE_FRAME_TIME_SAMPLES_COUNT))
|
||||
{
|
||||
@ -565,7 +561,7 @@ static void video_monitor_compute_fps_statistics(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void deinit_pixel_converter(void)
|
||||
static void video_driver_pixel_converter_free(void)
|
||||
{
|
||||
if (!video_driver_scaler_ptr)
|
||||
return;
|
||||
@ -585,12 +581,14 @@ static void deinit_pixel_converter(void)
|
||||
video_driver_scaler_ptr = NULL;
|
||||
}
|
||||
|
||||
static bool uninit_video_input(void)
|
||||
static void video_driver_free_internal(void)
|
||||
{
|
||||
bool is_threaded = video_driver_is_threaded();
|
||||
|
||||
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
||||
|
||||
if (!video_driver_is_video_cache_context())
|
||||
video_driver_deinit_hw_context();
|
||||
video_driver_free_hw_context();
|
||||
|
||||
if (
|
||||
!input_driver_owns_driver() &&
|
||||
@ -599,22 +597,24 @@ static bool uninit_video_input(void)
|
||||
input_driver_deinit();
|
||||
|
||||
if (
|
||||
!video_driver_owns_driver()
|
||||
!video_driver_data_own
|
||||
&& video_driver_data
|
||||
&& current_video && current_video->free
|
||||
)
|
||||
current_video->free(video_driver_data);
|
||||
|
||||
deinit_pixel_converter();
|
||||
deinit_video_filter();
|
||||
video_driver_pixel_converter_free();
|
||||
video_driver_filter_free();
|
||||
|
||||
command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL);
|
||||
video_monitor_compute_fps_statistics();
|
||||
|
||||
return true;
|
||||
if (is_threaded)
|
||||
return;
|
||||
|
||||
video_monitor_compute_fps_statistics();
|
||||
}
|
||||
|
||||
static bool init_video_pixel_converter(unsigned size)
|
||||
static bool video_driver_pixel_converter_init(unsigned size)
|
||||
{
|
||||
struct retro_hw_render_callback *hwr =
|
||||
video_driver_get_hw_context();
|
||||
@ -665,13 +665,13 @@ static bool init_video_pixel_converter(unsigned size)
|
||||
return true;
|
||||
|
||||
error:
|
||||
deinit_pixel_converter();
|
||||
deinit_video_filter();
|
||||
video_driver_pixel_converter_free();
|
||||
video_driver_filter_free();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool init_video(void)
|
||||
static bool video_driver_init_internal(void)
|
||||
{
|
||||
unsigned max_dim, scale, width, height;
|
||||
video_viewport_t *custom_vp = NULL;
|
||||
@ -686,10 +686,17 @@ static bool init_video(void)
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||
|
||||
deinit_video_filter();
|
||||
video_driver_filter_free();
|
||||
|
||||
if (!string_is_empty(settings->path.softfilter_plugin))
|
||||
init_video_filter(video_driver_pix_fmt);
|
||||
{
|
||||
if (video_driver_is_hw_context())
|
||||
{
|
||||
RARCH_WARN("Cannot use CPU filters when hardware rendering is used.\n");
|
||||
}
|
||||
else
|
||||
video_driver_init_filter(video_driver_pix_fmt);
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_SHADER_DIR_INIT, NULL);
|
||||
|
||||
@ -764,7 +771,7 @@ static bool init_video(void)
|
||||
video_driver_display_set(0);
|
||||
video_driver_window_set(0);
|
||||
|
||||
if (!init_video_pixel_converter(RARCH_SCALE_BASE * scale))
|
||||
if (!video_driver_pixel_converter_init(RARCH_SCALE_BASE * scale))
|
||||
{
|
||||
RARCH_ERR("Failed to initialize pixel converter.\n");
|
||||
goto error;
|
||||
@ -1512,7 +1519,7 @@ bool video_driver_get_prev_video_out(void)
|
||||
bool video_driver_init(void)
|
||||
{
|
||||
video_driver_lock_new();
|
||||
return init_video();
|
||||
return video_driver_init_internal();
|
||||
}
|
||||
|
||||
void video_driver_destroy_data(void)
|
||||
@ -1520,9 +1527,9 @@ void video_driver_destroy_data(void)
|
||||
video_driver_data = NULL;
|
||||
}
|
||||
|
||||
void video_driver_deinit(void)
|
||||
void video_driver_free(void)
|
||||
{
|
||||
uninit_video_input();
|
||||
video_driver_free_internal();
|
||||
video_driver_lock_free();
|
||||
video_driver_data = NULL;
|
||||
}
|
||||
@ -1769,7 +1776,7 @@ bool video_driver_is_hw_context(void)
|
||||
return is_hw_context;
|
||||
}
|
||||
|
||||
void video_driver_deinit_hw_context(void)
|
||||
void video_driver_free_hw_context(void)
|
||||
{
|
||||
video_driver_context_lock();
|
||||
|
||||
|
@ -297,7 +297,8 @@ bool video_driver_get_next_video_out(void);
|
||||
bool video_driver_get_prev_video_out(void);
|
||||
bool video_driver_init(void);
|
||||
void video_driver_destroy_data(void);
|
||||
void video_driver_deinit(void);
|
||||
void video_driver_free(void);
|
||||
void video_driver_free_hw_context(void);
|
||||
void video_driver_monitor_reset(void);
|
||||
void video_driver_set_aspect_ratio(void);
|
||||
void video_driver_show_mouse(void);
|
||||
@ -317,7 +318,6 @@ void video_driver_set_own_driver(void);
|
||||
void video_driver_unset_own_driver(void);
|
||||
bool video_driver_owns_driver(void);
|
||||
bool video_driver_is_hw_context(void);
|
||||
void video_driver_deinit_hw_context(void);
|
||||
struct retro_hw_render_callback *video_driver_get_hw_context(void);
|
||||
const struct retro_hw_render_context_negotiation_interface
|
||||
*video_driver_get_context_negotiation_interface(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user