mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Cleanups and buildfix
This commit is contained in:
parent
05e4aa8bfb
commit
3dee62ce62
@ -429,7 +429,7 @@ static void *gl1_gfx_init(const video_info_t *video,
|
||||
return gl1;
|
||||
|
||||
error:
|
||||
video_context_driver_destroy();
|
||||
video_context_driver_free();
|
||||
if (gl1)
|
||||
{
|
||||
if (gl1->extensions)
|
||||
|
@ -3981,7 +3981,7 @@ static void *gl2_init(const video_info_t *video,
|
||||
return gl;
|
||||
|
||||
error:
|
||||
video_context_driver_destroy();
|
||||
video_context_driver_free();
|
||||
gl2_destroy_resources(gl);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1353,7 +1353,7 @@ static void *gl_core_init(const video_info_t *video,
|
||||
return gl;
|
||||
|
||||
error:
|
||||
video_context_driver_destroy();
|
||||
video_context_driver_free();
|
||||
gl_core_destroy_resources(gl);
|
||||
if (gl)
|
||||
free(gl);
|
||||
|
@ -288,9 +288,9 @@ static void *vg_init(const video_info_t *video,
|
||||
return vg;
|
||||
|
||||
error:
|
||||
video_context_driver_free();
|
||||
if (vg)
|
||||
free(vg);
|
||||
video_context_driver_destroy();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "video_driver.h"
|
||||
|
||||
#include "../ui/ui_companion_driver.h"
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
typedef struct
|
||||
@ -235,12 +237,31 @@ bool video_driver_translate_coord_viewport(
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_monitor_set_refresh_rate:
|
||||
* @hz : New refresh rate for monitor.
|
||||
*
|
||||
* Sets monitor refresh rate to new value.
|
||||
**/
|
||||
void video_monitor_compute_fps_statistics(uint64_t
|
||||
frame_time_count)
|
||||
{
|
||||
double avg_fps = 0.0;
|
||||
double stddev = 0.0;
|
||||
unsigned samples = 0;
|
||||
|
||||
if (frame_time_count <
|
||||
(2 * MEASURE_FRAME_TIME_SAMPLES_COUNT))
|
||||
{
|
||||
RARCH_LOG(
|
||||
"[Video]: Does not have enough samples for monitor refresh rate"
|
||||
" estimation. Requires to run for at least %u frames.\n",
|
||||
2 * MEASURE_FRAME_TIME_SAMPLES_COUNT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_monitor_fps_statistics(&avg_fps, &stddev, &samples))
|
||||
{
|
||||
RARCH_LOG("[Video]: Average monitor Hz: %.6f Hz. (%.3f %% frame time"
|
||||
" deviation, based on %u last samples).\n",
|
||||
avg_fps, 100.0f * stddev, samples);
|
||||
}
|
||||
}
|
||||
|
||||
void video_monitor_set_refresh_rate(float hz)
|
||||
{
|
||||
char msg[128];
|
||||
@ -297,3 +318,128 @@ void video_driver_force_fallback(const char *driver)
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static bool video_context_driver_get_metrics_null(
|
||||
void *data, enum display_metric_types type,
|
||||
float *value) { return false; }
|
||||
|
||||
void video_context_driver_destroy(gfx_ctx_driver_t *ctx_driver)
|
||||
{
|
||||
if (!ctx_driver)
|
||||
return;
|
||||
|
||||
ctx_driver->init = NULL;
|
||||
ctx_driver->bind_api = NULL;
|
||||
ctx_driver->swap_interval = NULL;
|
||||
ctx_driver->set_video_mode = NULL;
|
||||
ctx_driver->get_video_size = NULL;
|
||||
ctx_driver->get_video_output_size = NULL;
|
||||
ctx_driver->get_video_output_prev = NULL;
|
||||
ctx_driver->get_video_output_next = NULL;
|
||||
ctx_driver->get_metrics =
|
||||
video_context_driver_get_metrics_null;
|
||||
ctx_driver->translate_aspect = NULL;
|
||||
ctx_driver->update_window_title = NULL;
|
||||
ctx_driver->check_window = NULL;
|
||||
ctx_driver->set_resize = NULL;
|
||||
ctx_driver->suppress_screensaver = NULL;
|
||||
ctx_driver->swap_buffers = NULL;
|
||||
ctx_driver->input_driver = NULL;
|
||||
ctx_driver->get_proc_address = NULL;
|
||||
ctx_driver->image_buffer_init = NULL;
|
||||
ctx_driver->image_buffer_write = NULL;
|
||||
ctx_driver->show_mouse = NULL;
|
||||
ctx_driver->ident = NULL;
|
||||
ctx_driver->get_flags = NULL;
|
||||
ctx_driver->set_flags = NULL;
|
||||
ctx_driver->bind_hw_render = NULL;
|
||||
ctx_driver->get_context_data = NULL;
|
||||
ctx_driver->make_current = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_video_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all video driver names, separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all video driver names, separated by '|'.
|
||||
**/
|
||||
const char* config_get_video_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_VIDEO_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void video_driver_pixel_converter_free(
|
||||
video_pixel_scaler_t *scalr)
|
||||
{
|
||||
if (!scalr)
|
||||
return;
|
||||
|
||||
if (scalr->scaler)
|
||||
{
|
||||
scaler_ctx_gen_reset(scalr->scaler);
|
||||
free(scalr->scaler);
|
||||
}
|
||||
if (scalr->scaler_out)
|
||||
free(scalr->scaler_out);
|
||||
|
||||
scalr->scaler = NULL;
|
||||
scalr->scaler_out = NULL;
|
||||
|
||||
free(scalr);
|
||||
}
|
||||
|
||||
video_pixel_scaler_t *video_driver_pixel_converter_init(
|
||||
const enum retro_pixel_format video_driver_pix_fmt,
|
||||
struct retro_hw_render_callback *hwr,
|
||||
unsigned size)
|
||||
{
|
||||
void *scalr_out = NULL;
|
||||
video_pixel_scaler_t *scalr = NULL;
|
||||
struct scaler_ctx *scalr_ctx = NULL;
|
||||
|
||||
/* If pixel format is not 0RGB1555, we don't need to do
|
||||
* any internal pixel conversion. */
|
||||
if (video_driver_pix_fmt != RETRO_PIXEL_FORMAT_0RGB1555)
|
||||
return NULL;
|
||||
|
||||
/* No need to perform pixel conversion for HW rendering contexts. */
|
||||
if (hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE)
|
||||
return NULL;
|
||||
|
||||
RARCH_WARN("[Video]: 0RGB1555 pixel format is deprecated,"
|
||||
" and will be slower. For 15/16-bit, RGB565"
|
||||
" format is preferred.\n");
|
||||
|
||||
if (!(scalr = (video_pixel_scaler_t*)malloc(sizeof(*scalr))))
|
||||
goto error;
|
||||
|
||||
scalr->scaler = NULL;
|
||||
scalr->scaler_out = NULL;
|
||||
|
||||
if (!(scalr_ctx = (struct scaler_ctx*)calloc(1, sizeof(*scalr_ctx))))
|
||||
goto error;
|
||||
|
||||
scalr->scaler = scalr_ctx;
|
||||
scalr->scaler->scaler_type = SCALER_TYPE_POINT;
|
||||
scalr->scaler->in_fmt = SCALER_FMT_0RGB1555;
|
||||
/* TODO/FIXME: Pick either ARGB8888 or RGB565 depending on driver. */
|
||||
scalr->scaler->out_fmt = SCALER_FMT_RGB565;
|
||||
|
||||
if (!scaler_ctx_gen_filter(scalr_ctx))
|
||||
goto error;
|
||||
|
||||
if (!(scalr_out = calloc(sizeof(uint16_t), size * size)))
|
||||
goto error;
|
||||
|
||||
scalr->scaler_out = scalr_out;
|
||||
|
||||
return scalr;
|
||||
|
||||
error:
|
||||
video_driver_pixel_converter_free(scalr);
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
video_driver_filter_free();
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include <gfx/scaler/pixconv.h>
|
||||
#include <gfx/scaler/scaler.h>
|
||||
|
||||
#include "../input/input_driver.h"
|
||||
#include "../input/input_types.h"
|
||||
|
||||
@ -317,6 +320,12 @@ typedef struct video_shader_ctx_texture
|
||||
unsigned id;
|
||||
} video_shader_ctx_texture_t;
|
||||
|
||||
typedef struct video_pixel_scaler
|
||||
{
|
||||
struct scaler_ctx *scaler;
|
||||
void *scaler_out;
|
||||
} video_pixel_scaler_t;
|
||||
|
||||
typedef void (*gfx_ctx_proc_t)(void);
|
||||
|
||||
typedef struct video_info
|
||||
@ -984,6 +993,14 @@ struct video_viewport *video_viewport_get_custom(void);
|
||||
**/
|
||||
void video_monitor_set_refresh_rate(float hz);
|
||||
|
||||
/**
|
||||
* video_monitor_compute_fps_statistics:
|
||||
*
|
||||
* Computes monitor FPS statistics.
|
||||
**/
|
||||
void video_monitor_compute_fps_statistics(uint64_t
|
||||
frame_time_count);
|
||||
|
||||
/**
|
||||
* video_monitor_fps_statistics
|
||||
* @refresh_rate : Monitor refresh rate.
|
||||
@ -1085,8 +1102,6 @@ const gfx_ctx_driver_t *video_context_driver_init_first(
|
||||
|
||||
bool video_context_driver_set(const gfx_ctx_driver_t *data);
|
||||
|
||||
void video_context_driver_destroy(void);
|
||||
|
||||
bool video_context_driver_get_ident(gfx_ctx_ident_t *ident);
|
||||
|
||||
bool video_context_driver_get_refresh_rate(float *refresh_rate);
|
||||
@ -1095,6 +1110,8 @@ bool video_context_driver_set_flags(gfx_ctx_flags_t *flags);
|
||||
|
||||
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics);
|
||||
|
||||
void video_context_driver_destroy(gfx_ctx_driver_t *ctx_driver);
|
||||
|
||||
enum gfx_ctx_api video_context_driver_get_api(void);
|
||||
|
||||
void video_context_driver_free(void);
|
||||
@ -1140,6 +1157,18 @@ const char *hw_render_context_name(
|
||||
video_driver_t *hw_render_context_driver(
|
||||
enum retro_hw_context_type type, int major, int minor);
|
||||
|
||||
void video_driver_pixel_converter_free(
|
||||
video_pixel_scaler_t *scalr);
|
||||
|
||||
video_pixel_scaler_t *video_driver_pixel_converter_init(
|
||||
const enum retro_pixel_format video_driver_pix_fmt,
|
||||
struct retro_hw_render_callback *hwr,
|
||||
unsigned size);
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
void video_driver_filter_free(void);
|
||||
#endif
|
||||
|
||||
extern video_driver_t video_gl_core;
|
||||
extern video_driver_t video_gl2;
|
||||
extern video_driver_t video_gl1;
|
||||
|
165
retroarch.c
165
retroarch.c
@ -20272,18 +20272,6 @@ bool video_driver_started_fullscreen(void)
|
||||
static bool get_metrics_null(void *data, enum display_metric_types type,
|
||||
float *value) { return false; }
|
||||
|
||||
/**
|
||||
* config_get_video_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all video driver names, separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all video driver names, separated by '|'.
|
||||
**/
|
||||
const char* config_get_video_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_VIDEO_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
bool video_driver_is_threaded(void)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
@ -20352,46 +20340,6 @@ bool video_context_driver_set(const gfx_ctx_driver_t *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void video_context_driver_destroy_internal(
|
||||
gfx_ctx_driver_t *ctx_driver)
|
||||
{
|
||||
if (!ctx_driver)
|
||||
return;
|
||||
|
||||
ctx_driver->init = NULL;
|
||||
ctx_driver->bind_api = NULL;
|
||||
ctx_driver->swap_interval = NULL;
|
||||
ctx_driver->set_video_mode = NULL;
|
||||
ctx_driver->get_video_size = NULL;
|
||||
ctx_driver->get_video_output_size = NULL;
|
||||
ctx_driver->get_video_output_prev = NULL;
|
||||
ctx_driver->get_video_output_next = NULL;
|
||||
ctx_driver->get_metrics = get_metrics_null;
|
||||
ctx_driver->translate_aspect = NULL;
|
||||
ctx_driver->update_window_title = NULL;
|
||||
ctx_driver->check_window = NULL;
|
||||
ctx_driver->set_resize = NULL;
|
||||
ctx_driver->suppress_screensaver = NULL;
|
||||
ctx_driver->swap_buffers = NULL;
|
||||
ctx_driver->input_driver = NULL;
|
||||
ctx_driver->get_proc_address = NULL;
|
||||
ctx_driver->image_buffer_init = NULL;
|
||||
ctx_driver->image_buffer_write = NULL;
|
||||
ctx_driver->show_mouse = NULL;
|
||||
ctx_driver->ident = NULL;
|
||||
ctx_driver->get_flags = NULL;
|
||||
ctx_driver->set_flags = NULL;
|
||||
ctx_driver->bind_hw_render = NULL;
|
||||
ctx_driver->get_context_data = NULL;
|
||||
ctx_driver->make_current = NULL;
|
||||
}
|
||||
|
||||
void video_context_driver_destroy(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
video_context_driver_destroy_internal(&p_rarch->current_video_context);
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_get_current_framebuffer:
|
||||
*
|
||||
@ -20421,7 +20369,7 @@ static retro_proc_address_t video_driver_get_proc_address(const char *sym)
|
||||
}
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
static void video_driver_filter_free(void)
|
||||
void video_driver_filter_free(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
|
||||
@ -20443,9 +20391,7 @@ static void video_driver_filter_free(void)
|
||||
p_rarch->video_driver_state_out_bpp = 0;
|
||||
p_rarch->video_driver_state_out_rgb32 = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
static void video_driver_init_filter(enum retro_pixel_format colfmt_int,
|
||||
settings_t *settings)
|
||||
{
|
||||
@ -20570,56 +20516,6 @@ static void video_driver_init_input(
|
||||
input_driver_st->current_data = new_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_monitor_compute_fps_statistics:
|
||||
*
|
||||
* Computes monitor FPS statistics.
|
||||
**/
|
||||
static void video_driver_monitor_compute_fps_statistics(uint64_t
|
||||
frame_time_count)
|
||||
{
|
||||
double avg_fps = 0.0;
|
||||
double stddev = 0.0;
|
||||
unsigned samples = 0;
|
||||
|
||||
if (frame_time_count <
|
||||
(2 * MEASURE_FRAME_TIME_SAMPLES_COUNT))
|
||||
{
|
||||
RARCH_LOG(
|
||||
"[Video]: Does not have enough samples for monitor refresh rate"
|
||||
" estimation. Requires to run for at least %u frames.\n",
|
||||
2 * MEASURE_FRAME_TIME_SAMPLES_COUNT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_monitor_fps_statistics(&avg_fps, &stddev, &samples))
|
||||
{
|
||||
RARCH_LOG("[Video]: Average monitor Hz: %.6f Hz. (%.3f %% frame time"
|
||||
" deviation, based on %u last samples).\n",
|
||||
avg_fps, 100.0f * stddev, samples);
|
||||
}
|
||||
}
|
||||
|
||||
static void video_driver_pixel_converter_free(
|
||||
video_pixel_scaler_t *scalr)
|
||||
{
|
||||
if (!scalr)
|
||||
return;
|
||||
|
||||
if (scalr->scaler)
|
||||
{
|
||||
scaler_ctx_gen_reset(scalr->scaler);
|
||||
free(scalr->scaler);
|
||||
}
|
||||
if (scalr->scaler_out)
|
||||
free(scalr->scaler_out);
|
||||
|
||||
scalr->scaler = NULL;
|
||||
scalr->scaler_out = NULL;
|
||||
|
||||
free(scalr);
|
||||
}
|
||||
|
||||
static void video_driver_free_hw_context(struct rarch_state *p_rarch)
|
||||
{
|
||||
VIDEO_DRIVER_CONTEXT_LOCK();
|
||||
@ -20695,62 +20591,7 @@ static void video_driver_free_internal(struct rarch_state *p_rarch)
|
||||
return;
|
||||
#endif
|
||||
|
||||
video_driver_monitor_compute_fps_statistics(p_rarch->video_driver_frame_time_count);
|
||||
}
|
||||
|
||||
static video_pixel_scaler_t *video_driver_pixel_converter_init(
|
||||
const enum retro_pixel_format video_driver_pix_fmt,
|
||||
struct retro_hw_render_callback *hwr,
|
||||
unsigned size)
|
||||
{
|
||||
void *scalr_out = NULL;
|
||||
video_pixel_scaler_t *scalr = NULL;
|
||||
struct scaler_ctx *scalr_ctx = NULL;
|
||||
|
||||
/* If pixel format is not 0RGB1555, we don't need to do
|
||||
* any internal pixel conversion. */
|
||||
if (video_driver_pix_fmt != RETRO_PIXEL_FORMAT_0RGB1555)
|
||||
return NULL;
|
||||
|
||||
/* No need to perform pixel conversion for HW rendering contexts. */
|
||||
if (hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE)
|
||||
return NULL;
|
||||
|
||||
RARCH_WARN("[Video]: 0RGB1555 pixel format is deprecated,"
|
||||
" and will be slower. For 15/16-bit, RGB565"
|
||||
" format is preferred.\n");
|
||||
|
||||
if (!(scalr = (video_pixel_scaler_t*)malloc(sizeof(*scalr))))
|
||||
goto error;
|
||||
|
||||
scalr->scaler = NULL;
|
||||
scalr->scaler_out = NULL;
|
||||
|
||||
if (!(scalr_ctx = (struct scaler_ctx*)calloc(1, sizeof(*scalr_ctx))))
|
||||
goto error;
|
||||
|
||||
scalr->scaler = scalr_ctx;
|
||||
scalr->scaler->scaler_type = SCALER_TYPE_POINT;
|
||||
scalr->scaler->in_fmt = SCALER_FMT_0RGB1555;
|
||||
/* TODO/FIXME: Pick either ARGB8888 or RGB565 depending on driver. */
|
||||
scalr->scaler->out_fmt = SCALER_FMT_RGB565;
|
||||
|
||||
if (!scaler_ctx_gen_filter(scalr_ctx))
|
||||
goto error;
|
||||
|
||||
if (!(scalr_out = calloc(sizeof(uint16_t), size * size)))
|
||||
goto error;
|
||||
|
||||
scalr->scaler_out = scalr_out;
|
||||
|
||||
return scalr;
|
||||
|
||||
error:
|
||||
video_driver_pixel_converter_free(scalr);
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
video_driver_filter_free();
|
||||
#endif
|
||||
return NULL;
|
||||
video_monitor_compute_fps_statistics(p_rarch->video_driver_frame_time_count);
|
||||
}
|
||||
|
||||
static void video_driver_set_viewport_config(
|
||||
@ -23159,7 +23000,7 @@ const gfx_ctx_driver_t *video_context_driver_init_first(void *data,
|
||||
void video_context_driver_free(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
video_context_driver_destroy_internal(&p_rarch->current_video_context);
|
||||
video_context_driver_destroy(&p_rarch->current_video_context);
|
||||
p_rarch->video_context_data = NULL;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,8 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
|
||||
|
||||
#define RETRO_ENVIRONMENT_RETROARCH_START_BLOCK 0x800000
|
||||
|
||||
#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (2 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK)
|
||||
|
@ -73,8 +73,6 @@
|
||||
#define BSV_MOVIE_IS_PLAYBACK_OFF() (p_rarch->bsv_movie_state_handle && !p_rarch->bsv_movie_state.movie_playback)
|
||||
#endif
|
||||
|
||||
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
|
||||
|
||||
#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time)))
|
||||
|
||||
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
|
||||
@ -930,12 +928,6 @@ enum input_game_focus_cmd_type
|
||||
GAME_FOCUS_CMD_REAPPLY
|
||||
};
|
||||
|
||||
typedef struct video_pixel_scaler
|
||||
{
|
||||
struct scaler_ctx *scaler;
|
||||
void *scaler_out;
|
||||
} video_pixel_scaler_t;
|
||||
|
||||
typedef void *(*constructor_t)(void);
|
||||
typedef void (*destructor_t )(void*);
|
||||
|
||||
|
@ -228,7 +228,7 @@ static enum ui_msg_window_response ui_msg_window_win32_warning(
|
||||
MessageBoxA(NULL, (LPCSTR)state->text, (LPCSTR)state->title, flags));
|
||||
}
|
||||
|
||||
static ui_msg_window_t ui_msg_window_win32 = {
|
||||
ui_msg_window_t ui_msg_window_win32 = {
|
||||
ui_msg_window_win32_error,
|
||||
ui_msg_window_win32_information,
|
||||
ui_msg_window_win32_question,
|
||||
|
@ -149,6 +149,8 @@ extern ui_companion_driver_t ui_companion_cocoatouch;
|
||||
extern ui_companion_driver_t ui_companion_qt;
|
||||
extern ui_companion_driver_t ui_companion_win32;
|
||||
|
||||
extern ui_msg_window_t ui_msg_window_win32;
|
||||
|
||||
bool ui_companion_is_on_foreground(void);
|
||||
|
||||
void ui_companion_set_foreground(unsigned enable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user