Rewrite perf interface - exposes callbacks now for RETRO_PERFORMANCE_INIT/RETRO_PERFORMANCE_START/RETRO_PERFORMANCE_STOP calls without messy, hardcoded preprocessor-dependent variables in macros - will update cores accordingly too
This commit is contained in:
parent
29b2683300
commit
9852c5dc4c
|
@ -63,10 +63,11 @@ typedef struct video4linux
|
|||
|
||||
static void process_image(video4linux_t *v4l, const uint8_t *buffer_yuv)
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(yuv_convert_direct);
|
||||
RETRO_PERFORMANCE_START(yuv_convert_direct);
|
||||
static retro_perf_counter_t yuv_convert_direct = { "yuv_convert_direct", 0, 0, 0, false };
|
||||
rarch_perf_init(&yuv_convert_direct, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&yuv_convert_direct, g_settings.perfcounter_enable);
|
||||
scaler_ctx_scale(&v4l->scaler, v4l->buffer_output, buffer_yuv);
|
||||
RETRO_PERFORMANCE_STOP(yuv_convert_direct);
|
||||
rarch_perf_stop(&yuv_convert_direct, g_settings.perfcounter_enable);
|
||||
}
|
||||
|
||||
static int xioctl(int fd, int request, void *args)
|
||||
|
|
14
dynamic.c
14
dynamic.c
|
@ -844,11 +844,15 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
|||
{
|
||||
RARCH_LOG("Environ GET_PERF_INTERFACE.\n");
|
||||
struct retro_perf_callback *cb = (struct retro_perf_callback*)data;
|
||||
cb->get_perf_counter = rarch_get_perf_counter;
|
||||
cb->get_time_usec = rarch_get_time_usec;
|
||||
cb->get_cpu_features = rarch_get_cpu_features;
|
||||
cb->perf_log = rarch_perf_log;
|
||||
cb->perf_register = rarch_perf_register;
|
||||
cb->get_perf_counter = rarch_get_perf_counter;
|
||||
cb->get_time_usec = rarch_get_time_usec;
|
||||
cb->get_cpu_features = rarch_get_cpu_features;
|
||||
cb->perf_init = rarch_perf_init;
|
||||
cb->perf_start = rarch_perf_start;
|
||||
cb->perf_stop = rarch_perf_stop;
|
||||
cb->perf_log = rarch_perf_log;
|
||||
cb->perf_logs = rarch_perf_logs;
|
||||
cb->perf_register = rarch_perf_register;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ returntype main_entry(signature())
|
|||
global_uninit_drivers();
|
||||
|
||||
#ifdef PERF_TEST
|
||||
rarch_perf_log();
|
||||
rarch_perf_logs();
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LOGGER) && !defined(ANDROID)
|
||||
|
|
|
@ -41,7 +41,7 @@ static void endloop(void)
|
|||
rarch_deinit_msg_queue();
|
||||
|
||||
#ifdef PERF_TEST
|
||||
rarch_perf_log();
|
||||
rarch_perf_logs();
|
||||
#endif
|
||||
|
||||
rarch_main_clear_state();
|
||||
|
|
|
@ -292,6 +292,7 @@ struct settings
|
|||
bool rgui_show_start_screen;
|
||||
#endif
|
||||
bool fps_show;
|
||||
bool perfcounter_enable;
|
||||
};
|
||||
|
||||
enum rarch_game_type
|
||||
|
|
|
@ -284,8 +284,9 @@ void D3DVideo::viewport_info(rarch_viewport &vp)
|
|||
|
||||
bool D3DVideo::read_viewport(uint8_t *buffer)
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(d3d_read_viewport);
|
||||
RETRO_PERFORMANCE_START(d3d_read_viewport);
|
||||
static retro_perf_counter_t d3d_read_viewport = { "d3d_read_viewport", 0, 0, 0, false };
|
||||
rarch_perf_init(&d3d_read_viewport, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&d3d_read_viewport, g_settings.perfcounter_enable);
|
||||
bool ret = true;
|
||||
IDirect3DSurface9 *target = nullptr;
|
||||
IDirect3DSurface9 *dest = nullptr;
|
||||
|
@ -338,7 +339,7 @@ bool D3DVideo::read_viewport(uint8_t *buffer)
|
|||
}
|
||||
|
||||
end:
|
||||
RETRO_PERFORMANCE_STOP(d3d_read_viewport);
|
||||
rarch_perf_stop(&d3d_read_viewport, g_settings.perfcounter_enable);
|
||||
if (target)
|
||||
target->Release();
|
||||
if (dest)
|
||||
|
@ -606,8 +607,9 @@ bool D3DVideo::frame(const void *frame,
|
|||
if (!frame)
|
||||
return true;
|
||||
|
||||
RETRO_PERFORMANCE_INIT(d3d_frame);
|
||||
RETRO_PERFORMANCE_START(d3d_frame);
|
||||
static retro_perf_counter_t d3d_frame = { "d3d_frame", 0, 0, 0, false };
|
||||
rarch_perf_init(&d3d_frame, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&d3d_frame, g_settings.perfcounter_enable);
|
||||
// We cannot recover in fullscreen.
|
||||
if (needs_restore && IsIconic(hWnd))
|
||||
return true;
|
||||
|
@ -670,7 +672,7 @@ bool D3DVideo::frame(const void *frame,
|
|||
}
|
||||
#endif
|
||||
|
||||
RETRO_PERFORMANCE_STOP(d3d_frame);
|
||||
rarch_perf_stop(&d3d_frame, g_settings.perfcounter_enable);
|
||||
|
||||
if (dev->Present(nullptr, nullptr, nullptr, nullptr) != D3D_OK)
|
||||
{
|
||||
|
|
35
gfx/gl.c
35
gfx/gl.c
|
@ -1315,13 +1315,14 @@ static void gl_pbo_async_readback(void *data)
|
|||
glPixelStorei(GL_PACK_ALIGNMENT, get_alignment(gl->vp.width * sizeof(uint32_t)));
|
||||
|
||||
// Read asynchronously into PBO buffer.
|
||||
RETRO_PERFORMANCE_INIT(async_readback);
|
||||
RETRO_PERFORMANCE_START(async_readback);
|
||||
static retro_perf_counter_t async_readback = { "async_readback", 0, 0, 0, false };
|
||||
rarch_perf_init(&async_readback, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&async_readback, g_settings.perfcounter_enable);
|
||||
glReadBuffer(GL_BACK);
|
||||
glReadPixels(gl->vp.x, gl->vp.y,
|
||||
gl->vp.width, gl->vp.height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
RETRO_PERFORMANCE_STOP(async_readback);
|
||||
rarch_perf_stop(&async_readback, g_settings.perfcounter_enable);
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
}
|
||||
|
@ -1372,8 +1373,9 @@ static inline void gl_draw_texture(void *data)
|
|||
|
||||
static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(frame_run);
|
||||
RETRO_PERFORMANCE_START(frame_run);
|
||||
static retro_perf_counter_t frame_run = { "frame_run", 0, 0, 0, false };
|
||||
rarch_perf_init(&frame_run, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&frame_run, g_settings.perfcounter_enable);
|
||||
|
||||
gl_t *gl = (gl_t*)data;
|
||||
|
||||
|
@ -1418,11 +1420,12 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||
if (!gl->hw_render_fbo_init)
|
||||
#endif
|
||||
{
|
||||
static retro_perf_counter_t copy_frame = { "copy_frame", 0, 0, 0, false };
|
||||
gl_update_input_size(gl, width, height, pitch, true);
|
||||
RETRO_PERFORMANCE_INIT(copy_frame);
|
||||
RETRO_PERFORMANCE_START(copy_frame);
|
||||
rarch_perf_init(©_frame, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(©_frame, g_settings.perfcounter_enable);
|
||||
gl_copy_frame(gl, frame, width, height, pitch);
|
||||
RETRO_PERFORMANCE_STOP(copy_frame);
|
||||
rarch_perf_stop(©_frame, g_settings.perfcounter_enable);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1501,7 +1504,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||
|
||||
context_update_window_title_func();
|
||||
|
||||
RETRO_PERFORMANCE_STOP(frame_run);
|
||||
rarch_perf_stop(&frame_run, g_settings.perfcounter_enable);
|
||||
|
||||
#ifdef HAVE_FBO
|
||||
// Reset state which could easily mess up libretro core.
|
||||
|
@ -1527,8 +1530,9 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||
#ifdef HAVE_GL_SYNC
|
||||
if (g_settings.video.hard_sync && gl->have_sync)
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(gl_fence);
|
||||
RETRO_PERFORMANCE_START(gl_fence);
|
||||
static retro_perf_counter_t gl_fence = {"gl_fence", 0, 0, 0, false};
|
||||
rarch_perf_init(&gl_fence, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&gl_fence, g_settings.perfcounter_enable);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gl->fences[gl->fence_count++] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
|
||||
|
@ -1541,7 +1545,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||
memmove(gl->fences, gl->fences + 1, gl->fence_count * sizeof(GLsync));
|
||||
}
|
||||
|
||||
RETRO_PERFORMANCE_STOP(gl_fence);
|
||||
rarch_perf_stop(&gl_fence, g_settings.perfcounter_enable);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2337,12 +2341,13 @@ static void gl_viewport_info(void *data, struct rarch_viewport *vp)
|
|||
|
||||
static bool gl_read_viewport(void *data, uint8_t *buffer)
|
||||
{
|
||||
static retro_perf_counter_t read_viewport = { "read_viewport", 0, 0, 0, false };
|
||||
unsigned i;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
(void)i;
|
||||
|
||||
RETRO_PERFORMANCE_INIT(read_viewport);
|
||||
RETRO_PERFORMANCE_START(read_viewport);
|
||||
rarch_perf_init(&read_viewport, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&read_viewport, g_settings.perfcounter_enable);
|
||||
|
||||
#ifdef HAVE_FBO
|
||||
// Make sure we're reading from backbuffer incase some state has been overridden.
|
||||
|
@ -2398,7 +2403,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
|||
}
|
||||
#endif
|
||||
|
||||
RETRO_PERFORMANCE_STOP(read_viewport);
|
||||
rarch_perf_stop(&read_viewport, g_settings.perfcounter_enable);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -305,10 +305,11 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigne
|
|||
if (SDL_MUSTLOCK(vid->screen))
|
||||
SDL_LockSurface(vid->screen);
|
||||
|
||||
RETRO_PERFORMANCE_INIT(sdl_scale);
|
||||
RETRO_PERFORMANCE_START(sdl_scale);
|
||||
static retro_perf_counter_t sdl_scale = { "sdl_scale", 0, 0, 0, false };
|
||||
rarch_perf_init(&sdl_scale, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&sdl_scale, g_settings.perfcounter_enable);
|
||||
scaler_ctx_scale(&vid->scaler, vid->screen->pixels, frame);
|
||||
RETRO_PERFORMANCE_STOP(sdl_scale);
|
||||
rarch_perf_stop(&sdl_scale, g_settings.perfcounter_enable);
|
||||
|
||||
if (msg)
|
||||
sdl_render_msg(vid, vid->screen, msg, vid->screen->w, vid->screen->h, vid->screen->format);
|
||||
|
|
|
@ -394,8 +394,9 @@ static bool thread_focus(void *data)
|
|||
static bool thread_frame(void *data, const void *frame_,
|
||||
unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(thread_frame);
|
||||
RETRO_PERFORMANCE_START(thread_frame);
|
||||
static retro_perf_counter_t thread_frame = { "thread_frame", 0, 0, 0, false};
|
||||
rarch_perf_init(&thread_frame, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&thread_frame, g_settings.perfcounter_enable);
|
||||
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
unsigned copy_stride = width * (thr->info.rgb32 ? sizeof(uint32_t) : sizeof(uint16_t));
|
||||
|
@ -461,7 +462,7 @@ static bool thread_frame(void *data, const void *frame_,
|
|||
|
||||
slock_unlock(thr->lock);
|
||||
|
||||
RETRO_PERFORMANCE_STOP(thread_frame);
|
||||
rarch_perf_stop(&thread_frame, g_settings.perfcounter_enable);
|
||||
|
||||
thr->last_time = rarch_get_time_usec();
|
||||
return true;
|
||||
|
|
15
gfx/vg.c
15
gfx/vg.c
|
@ -353,9 +353,9 @@ static void vg_copy_frame(void *data, const void *frame, unsigned width, unsigne
|
|||
|
||||
static bool vg_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
|
||||
RETRO_PERFORMANCE_INIT(vg_fr);
|
||||
RETRO_PERFORMANCE_START(vg_fr);
|
||||
static retro_perf_counter_t vg_fr = { "vg_fr", 0, 0, 0, false };
|
||||
rarch_perf_init(&vg_fr, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&vg_fr, g_settings.perfcounter_enable);
|
||||
vg_t *vg = (vg_t*)data;
|
||||
|
||||
if (width != vg->mRenderWidth || height != vg->mRenderHeight || vg->should_resize)
|
||||
|
@ -377,10 +377,11 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||
vgClear(0, 0, vg->mScreenWidth, vg->mScreenHeight);
|
||||
vgSeti(VG_SCISSORING, VG_TRUE);
|
||||
|
||||
RETRO_PERFORMANCE_INIT(vg_image);
|
||||
RETRO_PERFORMANCE_START(vg_image);
|
||||
static retro_perf_counter_t vg_image = { "vg_image", 0, 0, 0, false };
|
||||
rarch_perf_init(&vg_image, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&vg_image, g_settings.perfcounter_enable);
|
||||
vg_copy_frame(vg, frame, width, height, pitch);
|
||||
RETRO_PERFORMANCE_STOP(vg_image);
|
||||
rarch_perf_stop(&vg_image, g_settings.perfcounter_enable);
|
||||
|
||||
vgDrawImage(vg->mImage);
|
||||
|
||||
|
@ -389,7 +390,7 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||
|
||||
vg->driver->update_window_title();
|
||||
|
||||
RETRO_PERFORMANCE_STOP(vg_fr);
|
||||
rarch_perf_stop(&vg_fr, g_settings.perfcounter_enable);
|
||||
vg->driver->swap_buffers();
|
||||
|
||||
return true;
|
||||
|
|
47
libretro.h
47
libretro.h
|
@ -616,7 +616,11 @@ typedef struct retro_perf_counter
|
|||
typedef retro_time_t (*retro_perf_get_time_usec_t)(void);
|
||||
typedef retro_perf_tick_t (*retro_perf_get_counter_t)(void);
|
||||
typedef void (*retro_get_cpu_features_t)(unsigned*);
|
||||
typedef void (*retro_perf_log_t)(void);
|
||||
typedef void (*retro_perf_init_t)(void*, bool);
|
||||
typedef void (*retro_perf_start_t)(void*, bool);
|
||||
typedef void (*retro_perf_stop_t)(void*, bool);
|
||||
typedef void (*retro_perf_log_t)(void*, const char*, bool);
|
||||
typedef void (*retro_perf_logs_t)(void);
|
||||
typedef void (*retro_perf_register_t)(retro_perf_counter_t*);
|
||||
|
||||
struct retro_perf_callback
|
||||
|
@ -624,47 +628,14 @@ struct retro_perf_callback
|
|||
retro_perf_get_time_usec_t get_time_usec;
|
||||
retro_perf_get_counter_t get_perf_counter;
|
||||
retro_get_cpu_features_t get_cpu_features;
|
||||
retro_perf_init_t perf_init;
|
||||
retro_perf_start_t perf_start;
|
||||
retro_perf_stop_t perf_stop;
|
||||
retro_perf_log_t perf_log;
|
||||
retro_perf_logs_t perf_logs;
|
||||
retro_perf_register_t perf_register;
|
||||
};
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#define retro_perf_register_func rarch_perf_register
|
||||
#define retro_perf_register_func_exists 1
|
||||
#define retro_get_perf_counter_func rarch_get_perf_counter
|
||||
#define retro_get_perf_counter_func_exists 1
|
||||
#else
|
||||
#define retro_perf_register_func perf_register_cb
|
||||
#define retro_perf_register_func_exists retro_perf_register_func
|
||||
#define retro_get_perf_counter_func perf_get_counter_cb
|
||||
#define retro_get_perf_counter_func_exists retro_get_perf_counter_func
|
||||
#endif
|
||||
|
||||
#if defined(PERF_TEST) || !defined(RARCH_INTERNAL)
|
||||
#define RETRO_PERFORMANCE_INIT(X) \
|
||||
static retro_perf_counter_t X = {#X}; \
|
||||
do { \
|
||||
if (!(X).registered && retro_perf_register_func_exists) \
|
||||
retro_perf_register_func(&(X)); \
|
||||
} while(0)
|
||||
|
||||
#define RETRO_PERFORMANCE_START(X) do { \
|
||||
(X).call_cnt++; \
|
||||
if (retro_get_perf_counter_func_exists) \
|
||||
(X).start = retro_get_perf_counter_func(); \
|
||||
} while(0)
|
||||
|
||||
#define RETRO_PERFORMANCE_STOP(X) do { \
|
||||
if (retro_get_perf_counter_func_exists) \
|
||||
(X).total += retro_get_perf_counter_func() - (X).start; \
|
||||
} while(0)
|
||||
|
||||
#else
|
||||
#define RETRO_PERFORMANCE_INIT(X)
|
||||
#define RETRO_PERFORMANCE_START(X)
|
||||
#define RETRO_PERFORMANCE_STOP(X)
|
||||
#endif
|
||||
|
||||
// FIXME: Document the sensor API and work out behavior.
|
||||
// It will be marked as experimental until then.
|
||||
enum retro_sensor_action
|
||||
|
|
|
@ -76,19 +76,20 @@ static unsigned perf_ptr;
|
|||
|
||||
void rarch_perf_register(struct retro_perf_counter *perf)
|
||||
{
|
||||
if (perf_ptr >= MAX_COUNTERS)
|
||||
if (!perf && perf_ptr >= MAX_COUNTERS)
|
||||
return;
|
||||
|
||||
perf_counters[perf_ptr++] = perf;
|
||||
perf->registered = true;
|
||||
}
|
||||
|
||||
void rarch_perf_log(void)
|
||||
|
||||
void rarch_perf_logs(void)
|
||||
{
|
||||
unsigned i;
|
||||
RARCH_LOG("[PERF]: Performance counters:\n");
|
||||
for (i = 0; i < perf_ptr; i++)
|
||||
RETRO_PERFORMANCE_LOG(perf_counters[i]->ident, *perf_counters[i]);
|
||||
rarch_perf_log(perf_counters[i], perf_counters[i]->ident, true);
|
||||
}
|
||||
|
||||
retro_perf_tick_t rarch_get_perf_counter(void)
|
||||
|
@ -129,6 +130,49 @@ retro_perf_tick_t rarch_get_perf_counter(void)
|
|||
return time;
|
||||
}
|
||||
|
||||
void rarch_perf_init(void *data, bool enable)
|
||||
{
|
||||
struct retro_perf_counter *perf = (struct retro_perf_counter*)data;
|
||||
if (!enable || !perf)
|
||||
return;
|
||||
|
||||
if (!perf->registered)
|
||||
rarch_perf_register(perf);
|
||||
}
|
||||
|
||||
void rarch_perf_start(void *data, bool enable)
|
||||
{
|
||||
struct retro_perf_counter *perf = (struct retro_perf_counter*)data;
|
||||
if (!enable || !perf)
|
||||
return;
|
||||
|
||||
perf->call_cnt++;
|
||||
perf->start = rarch_get_perf_counter();
|
||||
}
|
||||
|
||||
void rarch_perf_stop(void *data, bool enable)
|
||||
{
|
||||
struct retro_perf_counter *perf = (struct retro_perf_counter*)data;
|
||||
if (!enable || !perf)
|
||||
return;
|
||||
|
||||
perf->total += rarch_get_perf_counter() - perf->start;
|
||||
}
|
||||
|
||||
void rarch_perf_log(void *data, const char *funcname, bool enable)
|
||||
{
|
||||
struct retro_perf_counter *perf = (struct retro_perf_counter*)data;
|
||||
if (!enable || !perf)
|
||||
return;
|
||||
#ifdef _WIN32
|
||||
RARCH_LOG("[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n",
|
||||
funcname, perf->total / perf->call_cnt, perf->call_cnt);
|
||||
#else
|
||||
RARCH_LOG("[PERF]: Avg (%s): %llu ticks, %llu runs.\n",
|
||||
funcname, perf->total / perf->call_cnt, perf->call_cnt);
|
||||
#endif
|
||||
}
|
||||
|
||||
retro_time_t rarch_get_time_usec(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
|
|
|
@ -31,25 +31,14 @@ extern "C" {
|
|||
retro_perf_tick_t rarch_get_perf_counter(void);
|
||||
retro_time_t rarch_get_time_usec(void);
|
||||
void rarch_perf_register(struct retro_perf_counter *perf);
|
||||
void rarch_perf_log(void);
|
||||
void rarch_perf_logs(void);
|
||||
|
||||
void rarch_get_cpu_features(unsigned *cpu);
|
||||
|
||||
#if defined(PERF_TEST) || !defined(RARCH_INTERNAL)
|
||||
#ifdef _WIN32
|
||||
#define RETRO_PERFORMANCE_LOG(functionname, X) RARCH_LOG("[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n", \
|
||||
functionname, \
|
||||
(X).total / (X).call_cnt, \
|
||||
(X).call_cnt)
|
||||
#else
|
||||
#define RETRO_PERFORMANCE_LOG(functionname, X) RARCH_LOG("[PERF]: Avg (%s): %llu ticks, %llu runs.\n", \
|
||||
functionname, \
|
||||
(X).total / (X).call_cnt, \
|
||||
(X).call_cnt)
|
||||
#endif
|
||||
#else
|
||||
#define RETRO_PERFORMANCE_LOG(functionname, X)
|
||||
#endif
|
||||
void rarch_perf_init(void *data, bool enable);
|
||||
void rarch_perf_start(void *data, bool enable);
|
||||
void rarch_perf_stop(void *data, bool enable);
|
||||
void rarch_perf_log(void *data, const char *funcname, bool enable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
30
retroarch.c
30
retroarch.c
|
@ -276,8 +276,9 @@ static void video_frame(const void *data, unsigned width, unsigned height, size_
|
|||
|
||||
if (g_extern.system.pix_fmt == RETRO_PIXEL_FORMAT_0RGB1555 && data && data != RETRO_HW_FRAME_BUFFER_VALID)
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(video_frame_conv);
|
||||
RETRO_PERFORMANCE_START(video_frame_conv);
|
||||
static retro_perf_counter_t video_frame_conv = { "video_frame_conv", 0, 0, 0, false };
|
||||
rarch_perf_init(&video_frame_conv, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&video_frame_conv, g_settings.perfcounter_enable);
|
||||
driver.scaler.in_width = width;
|
||||
driver.scaler.in_height = height;
|
||||
driver.scaler.out_width = width;
|
||||
|
@ -288,7 +289,7 @@ static void video_frame(const void *data, unsigned width, unsigned height, size_
|
|||
scaler_ctx_scale(&driver.scaler, driver.scaler_out, data);
|
||||
data = driver.scaler_out;
|
||||
pitch = driver.scaler.out_stride;
|
||||
RETRO_PERFORMANCE_STOP(video_frame_conv);
|
||||
rarch_perf_stop(&video_frame_conv, g_settings.perfcounter_enable);
|
||||
}
|
||||
|
||||
// Slightly messy code,
|
||||
|
@ -381,11 +382,13 @@ static bool audio_flush(const int16_t *data, size_t samples)
|
|||
unsigned output_frames = 0;
|
||||
|
||||
struct resampler_data src_data = {0};
|
||||
RETRO_PERFORMANCE_INIT(audio_convert_s16);
|
||||
RETRO_PERFORMANCE_START(audio_convert_s16);
|
||||
static retro_perf_counter_t audio_convert_s16 = { "audio_convert_s16", 0, 0, 0, false };
|
||||
|
||||
rarch_perf_init(&audio_convert_s16, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&audio_convert_s16, g_settings.perfcounter_enable);
|
||||
audio_convert_s16_to_float(g_extern.audio_data.data, data, samples,
|
||||
g_extern.audio_data.volume_gain);
|
||||
RETRO_PERFORMANCE_STOP(audio_convert_s16);
|
||||
rarch_perf_stop(&audio_convert_s16, g_settings.perfcounter_enable);
|
||||
|
||||
#if defined(HAVE_DYLIB)
|
||||
rarch_dsp_output_t dsp_output = {0};
|
||||
|
@ -412,11 +415,13 @@ static bool audio_flush(const int16_t *data, size_t samples)
|
|||
if (g_extern.is_slowmotion)
|
||||
src_data.ratio *= g_settings.slowmotion_ratio;
|
||||
|
||||
RETRO_PERFORMANCE_INIT(resampler_proc);
|
||||
RETRO_PERFORMANCE_START(resampler_proc);
|
||||
static retro_perf_counter_t resampler_proc = { "resampler_proc", 0, 0, 0, false };
|
||||
|
||||
rarch_perf_init(&resampler_proc, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&resampler_proc, g_settings.perfcounter_enable);
|
||||
rarch_resampler_process(g_extern.audio_data.resampler,
|
||||
g_extern.audio_data.resampler_data, &src_data);
|
||||
RETRO_PERFORMANCE_STOP(resampler_proc);
|
||||
rarch_perf_stop(&resampler_proc, g_settings.perfcounter_enable);
|
||||
|
||||
output_data = g_extern.audio_data.outsamples;
|
||||
output_frames = src_data.output_frames;
|
||||
|
@ -431,11 +436,12 @@ static bool audio_flush(const int16_t *data, size_t samples)
|
|||
}
|
||||
else
|
||||
{
|
||||
RETRO_PERFORMANCE_INIT(audio_convert_float);
|
||||
RETRO_PERFORMANCE_START(audio_convert_float);
|
||||
static retro_perf_counter_t audio_convert_float = { "audio_convert_float", 0, 0, 0, false };
|
||||
rarch_perf_init(&audio_convert_float, g_settings.perfcounter_enable);
|
||||
rarch_perf_start(&audio_convert_float, g_settings.perfcounter_enable);
|
||||
audio_convert_float_to_s16(g_extern.audio_data.conv_outsamples,
|
||||
output_data, output_frames * 2);
|
||||
RETRO_PERFORMANCE_STOP(audio_convert_float);
|
||||
rarch_perf_stop(&audio_convert_float, g_settings.perfcounter_enable);
|
||||
|
||||
if (audio_write_func(g_extern.audio_data.conv_outsamples, output_frames * sizeof(int16_t) * 2) < 0)
|
||||
{
|
||||
|
|
|
@ -350,6 +350,10 @@ void config_set_defaults(void)
|
|||
*g_settings.rgui_config_directory = '\0';
|
||||
#endif
|
||||
|
||||
#ifdef PERF_TEST
|
||||
g_settings.perfcounter_enable = true;
|
||||
#endif
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_MENU);
|
||||
|
||||
|
|
Loading…
Reference in New Issue