mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
(performance.c) Refactor performance counter code
This commit is contained in:
parent
590fc9605c
commit
a0e4776277
@ -424,7 +424,7 @@ static void menu_action_setting_disp_set_label_cheat(
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_perf_counters_common(
|
||||
const struct retro_perf_counter **counters,
|
||||
struct retro_perf_counter **counters,
|
||||
unsigned offset, char *s, size_t len
|
||||
)
|
||||
{
|
||||
@ -445,7 +445,7 @@ static void menu_action_setting_disp_set_label_perf_counters_common(
|
||||
}
|
||||
|
||||
static void general_disp_set_label_perf_counters(
|
||||
const struct retro_perf_counter **counters,
|
||||
struct retro_perf_counter **counters,
|
||||
unsigned offset,
|
||||
char *s, size_t len,
|
||||
char *s2, size_t len2,
|
||||
@ -470,8 +470,7 @@ static void menu_action_setting_disp_set_label_perf_counters(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
const struct retro_perf_counter **counters =
|
||||
(const struct retro_perf_counter **)perf_counters_rarch;
|
||||
struct retro_perf_counter **counters = retro_get_perf_counter_rarch();
|
||||
unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN;
|
||||
general_disp_set_label_perf_counters(counters, offset, s, len,
|
||||
s2, len, path, w);
|
||||
@ -486,8 +485,7 @@ static void menu_action_setting_disp_set_label_libretro_perf_counters(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
const struct retro_perf_counter **counters =
|
||||
(const struct retro_perf_counter **)perf_counters_libretro;
|
||||
struct retro_perf_counter **counters = retro_get_perf_counter_libretro();
|
||||
unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN;
|
||||
general_disp_set_label_perf_counters(counters, offset, s, len,
|
||||
s2, len, path, w);
|
||||
|
@ -65,8 +65,7 @@ static int generic_action_start_performance_counters(struct retro_perf_counter *
|
||||
|
||||
static int action_start_performance_counters_core(unsigned type, const char *label)
|
||||
{
|
||||
struct retro_perf_counter **counters = (struct retro_perf_counter**)
|
||||
perf_counters_libretro;
|
||||
struct retro_perf_counter **counters = retro_get_perf_counter_libretro();
|
||||
unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN;
|
||||
|
||||
return generic_action_start_performance_counters(counters, offset, type, label);
|
||||
@ -75,8 +74,7 @@ static int action_start_performance_counters_core(unsigned type, const char *lab
|
||||
static int action_start_performance_counters_frontend(unsigned type,
|
||||
const char *label)
|
||||
{
|
||||
struct retro_perf_counter **counters = (struct retro_perf_counter**)
|
||||
perf_counters_rarch;
|
||||
struct retro_perf_counter **counters = retro_get_perf_counter_rarch();
|
||||
unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN;
|
||||
return generic_action_start_performance_counters(counters, offset, type, label);
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ static void menu_list_refresh(file_list_t *list)
|
||||
|
||||
static void menu_displaylist_push_perfcounter(
|
||||
menu_displaylist_info_t *info,
|
||||
const struct retro_perf_counter **counters,
|
||||
struct retro_perf_counter **counters,
|
||||
unsigned num, unsigned id)
|
||||
{
|
||||
unsigned i;
|
||||
@ -2674,9 +2674,9 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
|
||||
case DISPLAYLIST_PERFCOUNTERS_FRONTEND:
|
||||
menu_displaylist_push_perfcounter(info,
|
||||
(type == DISPLAYLIST_PERFCOUNTERS_CORE) ?
|
||||
perf_counters_libretro : perf_counters_rarch,
|
||||
retro_get_perf_counter_libretro() : retro_get_perf_counter_rarch(),
|
||||
(type == DISPLAYLIST_PERFCOUNTERS_CORE) ?
|
||||
perf_ptr_libretro : perf_ptr_rarch ,
|
||||
retro_get_perf_count_libretro() : retro_get_perf_count_rarch(),
|
||||
(type == DISPLAYLIST_PERFCOUNTERS_CORE) ?
|
||||
MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN :
|
||||
MENU_SETTINGS_PERF_COUNTERS_BEGIN);
|
||||
|
@ -108,10 +108,30 @@ static int clock_gettime(int clk_ik, struct timespec *t)
|
||||
#include "frontend/drivers/platform_linux.h"
|
||||
#endif
|
||||
|
||||
const struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS];
|
||||
const struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS];
|
||||
unsigned perf_ptr_rarch;
|
||||
unsigned perf_ptr_libretro;
|
||||
static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS];
|
||||
static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS];
|
||||
static unsigned perf_ptr_rarch;
|
||||
static unsigned perf_ptr_libretro;
|
||||
|
||||
struct retro_perf_counter **retro_get_perf_counter_rarch(void)
|
||||
{
|
||||
return perf_counters_rarch;
|
||||
}
|
||||
|
||||
struct retro_perf_counter **retro_get_perf_counter_libretro(void)
|
||||
{
|
||||
return perf_counters_libretro;
|
||||
}
|
||||
|
||||
unsigned retro_get_perf_count_rarch(void)
|
||||
{
|
||||
return perf_ptr_rarch;
|
||||
}
|
||||
|
||||
unsigned retro_get_perf_count_libretro(void)
|
||||
{
|
||||
return perf_ptr_libretro;
|
||||
}
|
||||
|
||||
void rarch_perf_register(struct retro_perf_counter *perf)
|
||||
{
|
||||
@ -140,8 +160,7 @@ void retro_perf_clear(void)
|
||||
memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro));
|
||||
}
|
||||
|
||||
static void log_counters(
|
||||
const struct retro_perf_counter **counters, unsigned num)
|
||||
static void log_counters(struct retro_perf_counter **counters, unsigned num)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < num; i++)
|
||||
|
@ -31,12 +31,15 @@ extern "C" {
|
||||
#define MAX_COUNTERS 64
|
||||
#endif
|
||||
|
||||
extern const struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS];
|
||||
extern const struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS];
|
||||
extern unsigned perf_ptr_rarch;
|
||||
extern unsigned perf_ptr_libretro;
|
||||
struct retro_perf_counter **retro_get_perf_counter_rarch(void);
|
||||
|
||||
/**
|
||||
struct retro_perf_counter **retro_get_perf_counter_libretro(void);
|
||||
|
||||
unsigned retro_get_perf_count_rarch(void);
|
||||
|
||||
unsigned retro_get_perf_count_libretro(void);
|
||||
|
||||
/*
|
||||
* retro_get_perf_counter:
|
||||
*
|
||||
* Gets performance counter.
|
||||
|
Loading…
x
Reference in New Issue
Block a user