Merge pull request #4506 from libretro/msr_temp

More video driver/performance counter refactoring work
This commit is contained in:
Twinaphex 2017-01-25 17:14:15 +01:00 committed by GitHub
commit 7bdab3973d
28 changed files with 313 additions and 286 deletions

View File

@ -511,6 +511,7 @@ void audio_driver_set_nonblocking_state(bool enable)
static bool audio_driver_flush(const int16_t *data, size_t samples)
{
struct resampler_data src_data;
bool is_perfcnt_enable = false;
bool is_paused = false;
bool is_idle = false;
bool is_slowmotion = false;
@ -530,18 +531,19 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
if (recording_data)
recording_push_audio(data, samples);
runloop_get_status(&is_paused, &is_idle, &is_slowmotion);
runloop_get_status(&is_paused, &is_idle, &is_slowmotion,
&is_perfcnt_enable);
if (is_paused || settings->audio.mute_enable)
return true;
if (!audio_driver_active || !audio_driver_input_data)
return false;
performance_counter_init(&audio_convert_s16, "audio_convert_s16");
performance_counter_start(&audio_convert_s16);
performance_counter_init(audio_convert_s16, "audio_convert_s16");
performance_counter_start_plus(is_perfcnt_enable, audio_convert_s16);
convert_s16_to_float(audio_driver_input_data, data, samples,
audio_driver_volume_gain);
performance_counter_stop(&audio_convert_s16);
performance_counter_stop_plus(is_perfcnt_enable, audio_convert_s16);
src_data.data_in = audio_driver_input_data;
src_data.input_frames = samples >> 1;
@ -560,10 +562,10 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
dsp_data.input = audio_driver_input_data;
dsp_data.input_frames = samples >> 1;
performance_counter_init(&audio_dsp, "audio_dsp");
performance_counter_start(&audio_dsp);
performance_counter_init(audio_dsp, "audio_dsp");
performance_counter_start_plus(is_perfcnt_enable, audio_dsp);
retro_dsp_filter_process(audio_driver_dsp, &dsp_data);
performance_counter_stop(&audio_dsp);
performance_counter_stop_plus(is_perfcnt_enable, audio_dsp);
if (dsp_data.output)
{
@ -607,11 +609,11 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
if (is_slowmotion)
src_data.ratio *= settings->slowmotion_ratio;
performance_counter_init(&resampler_proc, "resampler_proc");
performance_counter_start(&resampler_proc);
performance_counter_init(resampler_proc, "resampler_proc");
performance_counter_start_plus(is_perfcnt_enable, resampler_proc);
audio_driver_resampler->process(audio_driver_resampler_data, &src_data);
performance_counter_stop(&resampler_proc);
performance_counter_stop_plus(is_perfcnt_enable, resampler_proc);
output_data = audio_driver_output_samples_buf;
output_frames = src_data.output_frames;
@ -620,11 +622,11 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
{
static struct retro_perf_counter audio_convert_float = {0};
performance_counter_init(&audio_convert_float, "audio_convert_float");
performance_counter_start(&audio_convert_float);
performance_counter_init(audio_convert_float, "audio_convert_float");
performance_counter_start_plus(is_perfcnt_enable, audio_convert_float);
convert_float_to_s16(audio_driver_output_samples_conv_buf,
(const float*)output_data, output_frames * 2);
performance_counter_stop(&audio_convert_float);
performance_counter_stop_plus(is_perfcnt_enable, audio_convert_float);
output_data = audio_driver_output_samples_conv_buf;
output_size = sizeof(int16_t);

View File

@ -176,8 +176,8 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size)
(void)samples_played;
(void)current_tick;
performance_counter_init(&ctraudio_f, "ctraudio_f");
performance_counter_start(&ctraudio_f);
performance_counter_init(ctraudio_f, "ctraudio_f");
performance_counter_start(ctraudio_f);
ctr_csnd_audio_update_playpos(ctr);
@ -209,7 +209,7 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size)
GSPGPU_FlushDataCache(ctr->l, CTR_CSND_AUDIO_SIZE);
GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE);
performance_counter_stop(&ctraudio_f);
performance_counter_stop(ctraudio_f);
return size;
}

View File

@ -116,8 +116,8 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
}
}
performance_counter_init(&ctraudio_dsp_f, "ctraudio_dsp_f");
performance_counter_start(&ctraudio_dsp_f);
performance_counter_init(ctraudio_dsp_f, "ctraudio_dsp_f");
performance_counter_start(ctraudio_dsp_f);
pos = ctr->pos << 2;
@ -140,7 +140,7 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
ctr->pos += size >> 2;
ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK;
performance_counter_stop(&ctraudio_dsp_f);
performance_counter_stop(ctraudio_dsp_f);
return size;
}

View File

@ -205,8 +205,8 @@ static ssize_t ax_audio_write(void* data, const void* buf, size_t size)
return 0;
/* Measure copy performance from here */
performance_counter_init(&ax_audio_write_perf, "ax_audio_write");
performance_counter_start(&ax_audio_write_perf);
performance_counter_init(ax_audio_write_perf, "ax_audio_write");
performance_counter_start(ax_audio_write_perf);
if(count > AX_AUDIO_MAX_FREE)
count = AX_AUDIO_MAX_FREE;
@ -286,7 +286,7 @@ static ssize_t ax_audio_write(void* data, const void* buf, size_t size)
ax_audio_start(ax, false);
/* Done copying new data */
performance_counter_stop(&ax_audio_write_perf);
performance_counter_stop(ax_audio_write_perf);
/* return what was actually copied */
return (count << 2);

View File

@ -70,10 +70,10 @@ static void process_image(video4linux_t *v4l, const uint8_t *buffer_yuv)
{
static struct retro_perf_counter yuv_convert_direct = {0};
performance_counter_init(&yuv_convert_direct, "yuv_convert_direct");
performance_counter_start(&yuv_convert_direct);
performance_counter_init(yuv_convert_direct, "yuv_convert_direct");
performance_counter_start(yuv_convert_direct);
scaler_ctx_scale(&v4l->scaler, v4l->buffer_output, buffer_yuv);
performance_counter_stop(&yuv_convert_direct);
performance_counter_stop(yuv_convert_direct);
}
static int xioctl(int fd, int request, void *args)

View File

@ -2378,8 +2378,10 @@ bool command_event(enum event_command cmd, void *data)
bool is_paused = false;
bool is_idle = false;
bool is_slowmotion = false;
bool is_perfcnt_enable = false;
runloop_get_status(&is_paused, &is_idle, &is_slowmotion);
runloop_get_status(&is_paused, &is_idle, &is_slowmotion,
&is_perfcnt_enable);
if (is_paused)
{

View File

@ -952,6 +952,21 @@ static bool dynamic_verify_hw_context(enum retro_hw_context_type type,
return true;
}
static void core_performance_counter_start(struct retro_perf_counter *perf)
{
if (runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL))
{
perf->call_cnt++;
perf->start = cpu_features_get_perf_counter();
}
}
static void core_performance_counter_stop(struct retro_perf_counter *perf)
{
if (runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL))
perf->total += cpu_features_get_perf_counter() - perf->start;
}
/**
* rarch_environment_cb:
* @cmd : Identifier of command.
@ -1410,8 +1425,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
cb->get_perf_counter = cpu_features_get_perf_counter;
cb->perf_register = performance_counter_register;
cb->perf_start = performance_counter_start;
cb->perf_stop = performance_counter_stop;
cb->perf_start = core_performance_counter_start;
cb->perf_stop = core_performance_counter_stop;
cb->perf_log = retro_perf_log;
break;
}

View File

@ -2241,10 +2241,10 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
{
static struct retro_perf_counter fence_wait = {0};
performance_counter_init(&fence_wait, "fence_wait");
performance_counter_start(&fence_wait);
performance_counter_init(fence_wait, "fence_wait");
performance_counter_start(fence_wait);
vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX);
performance_counter_stop(&fence_wait);
performance_counter_stop(fence_wait);
vkResetFences(vk->context.device, 1, next_fence);
}

View File

@ -464,6 +464,9 @@ static bool ctr_frame(void* data, const void* frame,
uint32_t diff;
static uint64_t currentTick,lastTick;
touchPosition state_tmp_touch;
extern GSPGPU_FramebufferInfo topFramebufferInfo;
extern u8* gfxSharedMemory;
extern u8 gfxThreadID;
uint32_t state_tmp = 0;
ctr_video_t *ctr = (ctr_video_t*)data;
static float fps = 0.0;
@ -609,8 +612,8 @@ static bool ctr_frame(void* data, const void* frame,
#endif
fflush(stdout);
performance_counter_init(&ctrframe_f, "ctrframe_f");
performance_counter_start(&ctrframe_f);
performance_counter_init(ctrframe_f, "ctrframe_f");
performance_counter_start_plus(video_info->is_perfcnt_enable, ctrframe_f);
if (ctr->should_resize)
ctr_update_viewport(ctr);
@ -802,38 +805,44 @@ static bool ctr_frame(void* data, const void* frame,
/* Swap buffers : */
extern GSPGPU_FramebufferInfo topFramebufferInfo;
extern u8* gfxSharedMemory;
extern u8 gfxThreadID;
topFramebufferInfo.active_framebuf=ctr->current_buffer_top;
topFramebufferInfo.framebuf0_vaddr=(u32*)gfxTopLeftFramebuffers[ctr->current_buffer_top];
topFramebufferInfo.
active_framebuf = ctr->current_buffer_top;
topFramebufferInfo.
framebuf0_vaddr = (u32*)gfxTopLeftFramebuffers[ctr->current_buffer_top];
if(ctr->video_mode == CTR_VIDEO_MODE_800x240)
{
topFramebufferInfo.framebuf1_vaddr=(u32*)(gfxTopLeftFramebuffers[ctr->current_buffer_top] + 240 * 3);
topFramebufferInfo.framebuf_widthbytesize = 240 * 3 * 2;
topFramebufferInfo.
framebuf1_vaddr = (u32*)(gfxTopLeftFramebuffers[ctr->current_buffer_top] + 240 * 3);
topFramebufferInfo.
framebuf_widthbytesize = 240 * 3 * 2;
}
else
{
topFramebufferInfo.framebuf1_vaddr=(u32*)gfxTopRightFramebuffers[ctr->current_buffer_top];
topFramebufferInfo.framebuf_widthbytesize = 240 * 3;
topFramebufferInfo.
framebuf1_vaddr = (u32*)gfxTopRightFramebuffers[ctr->current_buffer_top];
topFramebufferInfo.
framebuf_widthbytesize = 240 * 3;
}
topFramebufferInfo.format=(1<<8)|(1<<5)|GSP_BGR8_OES;
topFramebufferInfo.framebuf_dispselect=ctr->current_buffer_top;
topFramebufferInfo.unk=0x00000000;
topFramebufferInfo.format = (1<<8)|(1<<5)|GSP_BGR8_OES;
topFramebufferInfo.
framebuf_dispselect = ctr->current_buffer_top;
topFramebufferInfo.unk = 0x00000000;
u8* framebufferInfoHeader=gfxSharedMemory+0x200+gfxThreadID*0x80;
GSPGPU_FramebufferInfo* framebufferInfo=(GSPGPU_FramebufferInfo*)&framebufferInfoHeader[0x4];
framebufferInfoHeader[0x0] ^= 1;
u8* framebufferInfoHeader = gfxSharedMemory+0x200+gfxThreadID*0x80;
GSPGPU_FramebufferInfo*
framebufferInfo = (GSPGPU_FramebufferInfo*)&framebufferInfoHeader[0x4];
framebufferInfoHeader[0x0] ^= 1;
framebufferInfo[framebufferInfoHeader[0x0]] = topFramebufferInfo;
framebufferInfoHeader[0x1]=1;
framebufferInfoHeader[0x1] = 1;
ctr->current_buffer_top ^= 1;
ctr->p3d_event_pending = true;
ctr->ppf_event_pending = true;
performance_counter_stop(&ctrframe_f);
ctr->current_buffer_top ^= 1;
ctr->p3d_event_pending = true;
ctr->ppf_event_pending = true;
performance_counter_stop_plus(video_info->is_perfcnt_enable, ctrframe_f);
return true;
}

View File

@ -1387,8 +1387,8 @@ static bool d3d_frame(void *data, const void *frame,
if (!frame)
return true;
performance_counter_init(&d3d_frame, "d3d_frame");
performance_counter_start(&d3d_frame);
performance_counter_init(d3d_frame, "d3d_frame");
performance_counter_start_plus(video_info->is_perfcnt_enable, d3d_frame);
/* We cannot recover in fullscreen. */
if (d3d->needs_restore)
@ -1467,7 +1467,7 @@ static bool d3d_frame(void *data, const void *frame,
video_context_driver_update_window_title(video_info);
performance_counter_stop(&d3d_frame);
performance_counter_stop_plus(video_info->is_perfcnt_enable, d3d_frame);
video_context_driver_swap_buffers(video_info);

View File

@ -1530,8 +1530,8 @@ static bool cg_d3d9_renderchain_read_viewport(void *data, uint8_t *buffer)
video_driver_get_size(&width, &height);
performance_counter_init(&d3d_read_viewport, "d3d_read_viewport");
performance_counter_start(&d3d_read_viewport);
performance_counter_init(d3d_read_viewport, "d3d_read_viewport");
performance_counter_start(d3d_read_viewport);
(void)data;
(void)buffer;
@ -1583,7 +1583,7 @@ static bool cg_d3d9_renderchain_read_viewport(void *data, uint8_t *buffer)
ret = false;
end:
performance_counter_stop(&d3d_read_viewport);
performance_counter_stop(d3d_read_viewport);
if (target)
target->Release();
if (dest)

View File

@ -689,8 +689,8 @@ static INLINE void gl_copy_frame(gl_t *gl,
{
static struct retro_perf_counter copy_frame = {0};
performance_counter_init(&copy_frame, "copy_frame");
performance_counter_start(&copy_frame);
performance_counter_init(copy_frame, "copy_frame");
performance_counter_start_plus(video_info->is_perfcnt_enable, copy_frame);
#if defined(HAVE_PSGL)
{
@ -820,7 +820,7 @@ static INLINE void gl_copy_frame(gl_t *gl,
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
#endif
performance_counter_stop(&copy_frame);
performance_counter_stop_plus(video_info->is_perfcnt_enable, copy_frame);
}
static INLINE void gl_set_shader_viewport(gl_t *gl, unsigned idx)
@ -994,8 +994,8 @@ static void gl_pbo_async_readback(gl_t *gl)
video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)));
/* Read asynchronously into PBO buffer. */
performance_counter_init(&async_readback, "async_readback");
performance_counter_start(&async_readback);
performance_counter_init(async_readback, "async_readback");
performance_counter_start(async_readback);
glReadBuffer(GL_BACK);
#ifdef HAVE_OPENGLES3
glReadPixels(gl->vp.x, gl->vp.y,
@ -1006,7 +1006,7 @@ static void gl_pbo_async_readback(gl_t *gl)
gl->vp.width, gl->vp.height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
#endif
performance_counter_stop(&async_readback);
performance_counter_stop(async_readback);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
}
@ -1101,8 +1101,8 @@ static bool gl_frame(void *data, const void *frame,
unsigned width = video_info->width;
unsigned height = video_info->height;
performance_counter_init(&frame_run, "frame_run");
performance_counter_start(&frame_run);
performance_counter_init(frame_run, "frame_run");
performance_counter_start_plus(video_info->is_perfcnt_enable, frame_run);
if (!gl)
return false;
@ -1293,7 +1293,7 @@ static bool gl_frame(void *data, const void *frame,
video_context_driver_update_window_title(video_info);
performance_counter_stop(&frame_run);
performance_counter_stop_plus(video_info->is_perfcnt_enable, frame_run);
#ifdef HAVE_FBO
/* Reset state which could easily mess up libretro core. */
@ -1353,8 +1353,9 @@ static bool gl_frame(void *data, const void *frame,
{
static struct retro_perf_counter gl_fence = {0};
performance_counter_init(&gl_fence, "gl_fence");
performance_counter_start(&gl_fence);
performance_counter_init(gl_fence, "gl_fence");
performance_counter_start_plus(video_info->is_perfcnt_enable,
gl_fence);
glClear(GL_COLOR_BUFFER_BIT);
gl->fences[gl->fence_count++] =
glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
@ -1370,7 +1371,8 @@ static bool gl_frame(void *data, const void *frame,
gl->fence_count * sizeof(GLsync));
}
performance_counter_stop(&gl_fence);
performance_counter_stop_plus(video_info->is_perfcnt_enable,
gl_fence);
}
#endif
@ -2371,8 +2373,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle)
context_bind_hw_render(false);
performance_counter_init(&read_viewport, "read_viewport");
performance_counter_start(&read_viewport);
performance_counter_init(read_viewport, "read_viewport");
performance_counter_start(read_viewport);
num_pixels = gl->vp.width * gl->vp.height;
@ -2438,7 +2440,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle)
if (!gl->readback_buffer_screenshot)
{
performance_counter_stop(&read_viewport);
performance_counter_stop(read_viewport);
goto error;
}
@ -2454,7 +2456,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle)
gl->readback_buffer_screenshot = NULL;
}
performance_counter_stop(&read_viewport);
performance_counter_stop(read_viewport);
context_bind_hw_render(true);
return true;

View File

@ -1451,8 +1451,8 @@ static bool gx_frame(void *data, const void *frame,
fps_text_buf[0] = '\0';
performance_counter_init(&gx_frame, "gx_frame");
performance_counter_start(&gx_frame);
performance_counter_init(gx_frame, "gx_frame");
performance_counter_start_plus(video_info->is_perfcnt_enable, gx_frame);
if(!gx || (!frame && !gx->menu_texture_enable))
return true;
@ -1487,8 +1487,8 @@ static bool gx_frame(void *data, const void *frame,
{
static struct retro_perf_counter gx_frame_convert = {0};
performance_counter_init(&gx_frame_convert, "gx_frame_convert");
performance_counter_start(&gx_frame_convert);
performance_counter_init(gx_frame_convert, "gx_frame_convert");
performance_counter_start_plus(video_info->is_perfcnt_enable, gx_frame_convert);
if (gx->rgb32)
convert_texture32(frame, g_tex.data, width, height, pitch);
@ -1498,7 +1498,7 @@ static bool gx_frame(void *data, const void *frame,
convert_texture16(frame, g_tex.data, width, height, pitch);
DCFlushRange(g_tex.data, height * (width << (gx->rgb32 ? 2 : 1)));
performance_counter_stop(&gx_frame_convert);
performance_counter_stop_plus(video_info->is_perfcnt_enable, gx_frame_convert);
}
if (gx->menu_texture_enable && gx->menu_data)
@ -1580,7 +1580,7 @@ static bool gx_frame(void *data, const void *frame,
VIDEO_SetNextFramebuffer(gx->framebuf[g_current_framebuf]);
VIDEO_Flush();
performance_counter_stop(&gx_frame);
performance_counter_stop_plus(video_info->is_perfcnt_enable, gx_frame);
return true;
}

View File

@ -534,8 +534,8 @@ static bool psp_frame(void *data, const void *frame,
psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
performance_counter_init(&psp_frame_run, "psp_frame_run");
performance_counter_start(&psp_frame_run);
performance_counter_init(psp_frame_run, "psp_frame_run");
performance_counter_start_plus(video_info->is_perfcnt_enable, psp_frame_run);
if (psp->should_resize)
psp_update_viewport(psp, video_info);
@ -568,7 +568,7 @@ static bool psp_frame(void *data, const void *frame,
sceGuFinish();
performance_counter_stop(&psp_frame_run);
performance_counter_stop_plus(video_info->is_perfcnt_enable, psp_frame_run);
#ifdef HAVE_MENU
menu_driver_frame(video_info);

View File

@ -349,8 +349,8 @@ static void sdl_refresh_input_size(sdl2_video_t *vid, bool menu, bool rgb32,
sdl_tex_zero(target);
performance_counter_init(&sdl_create_texture, "sdl_create_texture");
performance_counter_start(&sdl_create_texture);
performance_counter_init(sdl_create_texture, "sdl_create_texture");
performance_counter_start(sdl_create_texture);
if (menu)
format = rgb32 ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_RGBA4444;
@ -364,7 +364,7 @@ static void sdl_refresh_input_size(sdl2_video_t *vid, bool menu, bool rgb32,
target->tex = SDL_CreateTexture(vid->renderer, format,
SDL_TEXTUREACCESS_STREAMING, width, height);
performance_counter_stop(&sdl_create_texture);
performance_counter_stop(sdl_create_texture);
if (!target->tex)
{
@ -513,12 +513,12 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
sdl_refresh_input_size(vid, false, vid->video.rgb32, width, height, pitch);
performance_counter_init(&sdl_copy_frame, "sdl_copy_frame");
performance_counter_start(&sdl_copy_frame);
performance_counter_init(sdl_copy_frame, "sdl_copy_frame");
performance_counter_start_plus(video_info->is_perfcnt_enable, sdl_copy_frame);
SDL_UpdateTexture(vid->frame.tex, NULL, frame, pitch);
performance_counter_stop(&sdl_copy_frame);
performance_counter_stop_plus(video_info->is_perfcnt_enable, sdl_copy_frame);
}
SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);
@ -632,8 +632,8 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle)
sdl2_video_t *vid = (sdl2_video_t*)data;
static struct retro_perf_counter sdl2_gfx_read_viewport = {0};
performance_counter_init(&sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport");
performance_counter_start(&sdl2_gfx_read_viewport);
performance_counter_init(sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport");
performance_counter_start(sdl2_gfx_read_viewport);
if (!is_idle)
video_driver_cached_frame();
@ -649,7 +649,7 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle)
memcpy(buffer, bgr24->pixels, bgr24->h * bgr24->pitch);
performance_counter_stop(&sdl2_gfx_read_viewport);
performance_counter_stop(sdl2_gfx_read_viewport);
return true;
}
@ -709,12 +709,12 @@ static void sdl2_poke_set_texture_frame(void *data, const void *frame, bool rgb3
sdl_refresh_input_size(vid, true, rgb32, width, height,
width * (rgb32 ? 4 : 2));
performance_counter_init(&copy_texture_frame, "copy_texture_frame");
performance_counter_start(&copy_texture_frame);
performance_counter_init(copy_texture_frame, "copy_texture_frame");
performance_counter_start(copy_texture_frame);
SDL_UpdateTexture(vid->menu.tex, NULL, frame, vid->menu.pitch);
performance_counter_stop(&copy_texture_frame);
performance_counter_stop(copy_texture_frame);
}
}

View File

@ -353,8 +353,8 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
if (SDL_MUSTLOCK(vid->screen))
SDL_LockSurface(vid->screen);
performance_counter_init(&sdl_scale, "sdl_scale");
performance_counter_start(&sdl_scale);
performance_counter_init(sdl_scale, "sdl_scale");
performance_counter_start_plus(video_info->is_perfcnt_enable, sdl_scale);
video_frame_scale(
&vid->scaler,
@ -367,7 +367,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
width,
height,
pitch);
performance_counter_stop(&sdl_scale);
performance_counter_stop_plus(video_info->is_perfcnt_enable, sdl_scale);
#ifdef HAVE_MENU
menu_driver_frame(video_info);

View File

@ -390,8 +390,8 @@ static bool vg_frame(void *data, const void *frame,
unsigned width = video_info->width;
unsigned height = video_info->height;
performance_counter_init(&vg_fr, "vg_fr");
performance_counter_start(&vg_fr);
performance_counter_init(vg_fr, "vg_fr");
performance_counter_start_plus(video_info->is_perfcnt_enable, vg_fr);
if ( frame_width != vg->mRenderWidth
|| frame_height != vg->mRenderHeight
@ -415,10 +415,10 @@ static bool vg_frame(void *data, const void *frame,
vgClear(0, 0, width, height);
vgSeti(VG_SCISSORING, VG_TRUE);
performance_counter_init(&vg_image, "vg_image");
performance_counter_start(&vg_image);
performance_counter_init(vg_image, "vg_image");
performance_counter_start_plus(video_info->is_perfcnt_enable, vg_image);
vg_copy_frame(vg, frame, frame_width, frame_height, pitch);
performance_counter_stop(&vg_image);
performance_counter_stop_plus(video_info->is_perfcnt_enable, vg_image);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
@ -433,7 +433,7 @@ static bool vg_frame(void *data, const void *frame,
video_context_driver_update_window_title(video_info);
performance_counter_stop(&vg_fr);
performance_counter_stop_plus(video_info->is_perfcnt_enable, vg_fr);
video_context_driver_swap_buffers(video_info);

View File

@ -1547,14 +1547,15 @@ static bool vulkan_frame(void *data, const void *frame,
unsigned frame_index =
vk->context->current_swapchain_index;
performance_counter_init(&frame_run, "frame_run");
performance_counter_init(&copy_frame, "copy_frame");
performance_counter_init(&swapbuffers, "swapbuffers");
performance_counter_init(&queue_submit, "queue_submit");
performance_counter_init(&begin_cmd, "begin_command");
performance_counter_init(&build_cmd, "build_command");
performance_counter_init(&end_cmd, "end_command");
performance_counter_start(&frame_run);
performance_counter_init(frame_run, "frame_run");
performance_counter_init(copy_frame, "copy_frame");
performance_counter_init(swapbuffers, "swapbuffers");
performance_counter_init(queue_submit, "queue_submit");
performance_counter_init(begin_cmd, "begin_command");
performance_counter_init(build_cmd, "build_command");
performance_counter_init(end_cmd, "end_command");
performance_counter_start_plus(video_info->is_perfcnt_enable, frame_run);
/* Bookkeeping on start of frame. */
chain = &vk->swapchain[frame_index];
@ -1564,14 +1565,14 @@ static bool vulkan_frame(void *data, const void *frame,
vulkan_buffer_chain_discard(&chain->vbo);
vulkan_buffer_chain_discard(&chain->ubo);
performance_counter_start(&begin_cmd);
performance_counter_start_plus(video_info->is_perfcnt_enable, begin_cmd);
/* Start recording the command buffer. */
vk->cmd = chain->cmd;
begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
vkResetCommandBuffer(vk->cmd, 0);
vkBeginCommandBuffer(vk->cmd, &begin_info);
performance_counter_stop(&begin_cmd);
performance_counter_stop_plus(video_info->is_perfcnt_enable, begin_cmd);
memset(&vk->tracker, 0, sizeof(vk->tracker));
@ -1596,7 +1597,7 @@ static bool vulkan_frame(void *data, const void *frame,
}
/* Upload texture */
performance_counter_start(&copy_frame);
performance_counter_start_plus(video_info->is_perfcnt_enable, copy_frame);
if (frame && !vk->hw.enable)
{
unsigned y;
@ -1647,13 +1648,13 @@ static bool vulkan_frame(void *data, const void *frame,
vk->last_valid_index = frame_index;
}
performance_counter_stop(&copy_frame);
performance_counter_stop_plus(video_info->is_perfcnt_enable, copy_frame);
/* Notify filter chain about the new sync index. */
vulkan_filter_chain_notify_sync_index((vulkan_filter_chain_t*)vk->filter_chain, frame_index);
vulkan_filter_chain_set_frame_count((vulkan_filter_chain_t*)vk->filter_chain, frame_count);
performance_counter_start(&build_cmd);
performance_counter_start_plus(video_info->is_perfcnt_enable, build_cmd);
/* Render offscreen filter chain passes. */
{
/* Set the source texture in the filter chain */
@ -1781,7 +1782,7 @@ static bool vulkan_frame(void *data, const void *frame,
if (vk->overlay.enable)
vulkan_render_overlay(vk, video_info);
#endif
performance_counter_stop(&build_cmd);
performance_counter_stop_plus(video_info->is_perfcnt_enable, build_cmd);
/* End the render pass. We're done rendering to backbuffer now. */
vkCmdEndRenderPass(vk->cmd);
@ -1850,9 +1851,9 @@ static bool vulkan_frame(void *data, const void *frame,
vk->context->graphics_queue_index, vk->hw.src_queue_family);
}
performance_counter_start(&end_cmd);
performance_counter_start_plus(video_info->is_perfcnt_enable, end_cmd);
vkEndCommandBuffer(vk->cmd);
performance_counter_stop(&end_cmd);
performance_counter_stop_plus(video_info->is_perfcnt_enable, end_cmd);
/* Submit command buffers to GPU. */
@ -1894,9 +1895,9 @@ static bool vulkan_frame(void *data, const void *frame,
}
submit_info.pSignalSemaphores = submit_info.signalSemaphoreCount ? signal_semaphores : NULL;
performance_counter_stop(&frame_run);
performance_counter_stop_plus(video_info->is_perfcnt_enable, frame_run);
performance_counter_start(&queue_submit);
performance_counter_start_plus(video_info->is_perfcnt_enable, queue_submit);
#ifdef HAVE_THREADS
slock_lock(vk->context->queue_lock);
@ -1906,11 +1907,11 @@ static bool vulkan_frame(void *data, const void *frame,
#ifdef HAVE_THREADS
slock_unlock(vk->context->queue_lock);
#endif
performance_counter_stop(&queue_submit);
performance_counter_stop_plus(video_info->is_perfcnt_enable, queue_submit);
performance_counter_start(&swapbuffers);
performance_counter_start_plus(video_info->is_perfcnt_enable, swapbuffers);
video_context_driver_swap_buffers(video_info);
performance_counter_stop(&swapbuffers);
performance_counter_stop_plus(video_info->is_perfcnt_enable, swapbuffers);
if (!vk->context->swap_interval_emulation_lock)
video_context_driver_update_window_title(video_info);
@ -2279,8 +2280,8 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer, bool is_idle)
if (staging->memory == VK_NULL_HANDLE)
return false;
performance_counter_init(&stream_readback, "stream_readback");
performance_counter_start(&stream_readback);
performance_counter_init(stream_readback, "stream_readback");
performance_counter_start(stream_readback);
buffer += 3 * (vk->vp.height - 1) * vk->vp.width;
vkMapMemory(vk->context->device, staging->memory,
@ -2294,7 +2295,7 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer, bool is_idle)
vkUnmapMemory(vk->context->device, staging->memory);
performance_counter_stop(&stream_readback);
performance_counter_stop(stream_readback);
}
else
{

View File

@ -617,8 +617,8 @@ static bool wiiu_gfx_frame(void* data, const void* frame,
fflush(stdout);
static struct retro_perf_counter gfx_frame_perf = {0};
performance_counter_init(&gfx_frame_perf, "gfx_frame");
performance_counter_start(&gfx_frame_perf);
performance_counter_init(gfx_frame_perf, "gfx_frame");
performance_counter_start_plus(video_info->is_perfcnt_enable, gfx_frame_perf);
if (wiiu->should_resize)
wiiu_gfx_update_viewport(wiiu);
@ -702,7 +702,7 @@ static bool wiiu_gfx_frame(void* data, const void* frame,
GX2SwapScanBuffers();
GX2Flush();
performance_counter_stop(&gfx_frame_perf);
performance_counter_stop_plus(video_info->is_perfcnt_enable, gfx_frame_perf);
return true;
}

View File

@ -962,10 +962,11 @@ void video_driver_set_filtering(unsigned index, bool smooth)
void video_driver_cached_frame_set(const void *data, unsigned width,
unsigned height, size_t pitch)
{
video_driver_set_cached_frame_ptr(data);
frame_cache_width = width;
frame_cache_height = height;
frame_cache_pitch = pitch;
if (data)
frame_cache_data = data;
frame_cache_width = width;
frame_cache_height = height;
frame_cache_pitch = pitch;
}
void video_driver_cached_frame_get(const void **data, unsigned *width,
@ -1094,18 +1095,18 @@ static bool video_driver_frame_filter(
{
static struct retro_perf_counter softfilter_process = {0};
performance_counter_init(&softfilter_process, "softfilter_process");
performance_counter_init(softfilter_process, "softfilter_process");
rarch_softfilter_get_output_size(video_driver_state_filter,
output_width, output_height, width, height);
*output_pitch = (*output_width) * video_driver_state_out_bpp;
performance_counter_start(&softfilter_process);
performance_counter_start_plus(video_info->is_perfcnt_enable, softfilter_process);
rarch_softfilter_process(video_driver_state_filter,
video_driver_state_buffer, *output_pitch,
data, width, height, pitch);
performance_counter_stop(&softfilter_process);
performance_counter_stop_plus(video_info->is_perfcnt_enable, softfilter_process);
if (video_info->post_filter_record && recording_data)
recording_dump_frame(video_driver_state_buffer,
@ -2018,89 +2019,6 @@ unsigned video_pixel_get_alignment(unsigned pitch)
return 8;
}
/**
* video_monitor_get_fps:
*
* Get the amount of frames per seconds.
**/
static void video_monitor_get_fps(video_frame_info_t *video_info)
{
static retro_time_t curr_time;
static retro_time_t fps_time;
static float last_fps;
unsigned write_index = 0;
retro_time_t new_time = cpu_features_get_time_usec();
if (!video_info->frame_count)
{
curr_time = fps_time = new_time;
strlcpy(video_driver_window_title,
video_driver_title_buf,
sizeof(video_driver_window_title));
if (video_info->fps_show)
strlcpy(video_info->fps_text,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(video_info->fps_text));
video_driver_window_title_update = true;
return;
}
write_index =
video_driver_frame_time_count++ &
(MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);
video_driver_frame_time_samples[write_index] = new_time - fps_time;
fps_time = new_time;
if ((video_info->frame_count % FPS_UPDATE_INTERVAL) == 0)
{
char frames_text[64];
fill_pathname_noext(video_driver_window_title,
video_driver_title_buf,
" || ",
sizeof(video_driver_window_title));
if (video_info->fps_show)
{
last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL);
snprintf(video_info->fps_text,
sizeof(video_info->fps_text),
" FPS: %6.1f || ", last_fps);
strlcat(video_driver_window_title,
video_info->fps_text,
sizeof(video_driver_window_title));
}
curr_time = new_time;
strlcat(video_driver_window_title,
"Frames: ",
sizeof(video_driver_window_title));
snprintf(frames_text,
sizeof(frames_text),
STRING_REP_UINT64,
(unsigned long long)video_info->frame_count);
strlcat(video_driver_window_title,
frames_text,
sizeof(video_driver_window_title));
video_driver_window_title_update = true;
}
if (video_info->fps_show)
snprintf(
video_info->fps_text,
sizeof(video_info->fps_text),
"FPS: %6.1f || %s: " STRING_REP_UINT64,
last_fps,
msg_hash_to_str(MSG_FRAMES),
(unsigned long long)video_info->frame_count);
}
/**
* video_driver_frame:
* @data : pointer to data of the video frame.
@ -2115,31 +2033,39 @@ void video_driver_frame(const void *data, unsigned width,
{
static char video_driver_msg[256];
video_frame_info_t video_info;
static struct retro_perf_counter video_frame_conv = {0};
static retro_time_t curr_time;
static retro_time_t fps_time;
static float last_fps;
unsigned output_width = 0;
unsigned output_height = 0;
unsigned output_pitch = 0;
const char *msg = NULL;
retro_time_t new_time =
cpu_features_get_time_usec();
if (!video_driver_active)
return;
performance_counter_init(&video_frame_conv, "video_frame_conv");
performance_counter_start(&video_frame_conv);
if (video_driver_scaler_ptr && data &&
(video_driver_pix_fmt == RETRO_PIXEL_FORMAT_0RGB1555) &&
(data != RETRO_HW_FRAME_BUFFER_VALID) &&
video_pixel_frame_scale(
video_driver_scaler_ptr->scaler,
video_driver_scaler_ptr->scaler_out,
data, width, height, pitch))
(data != RETRO_HW_FRAME_BUFFER_VALID))
{
data = video_driver_scaler_ptr->scaler_out;
pitch = video_driver_scaler_ptr->scaler->out_stride;
static struct retro_perf_counter video_frame_conv = {0};
performance_counter_init(video_frame_conv, "video_frame_conv");
performance_counter_start(video_frame_conv);
if (video_pixel_frame_scale(
video_driver_scaler_ptr->scaler,
video_driver_scaler_ptr->scaler_out,
data, width, height, pitch))
{
data = video_driver_scaler_ptr->scaler_out;
pitch = video_driver_scaler_ptr->scaler->out_stride;
}
performance_counter_stop(video_frame_conv);
}
performance_counter_stop(&video_frame_conv);
if (data)
frame_cache_data = data;
@ -2154,7 +2080,78 @@ void video_driver_frame(const void *data, unsigned width,
video_driver_frame_count++;
video_driver_threaded_unlock();
video_monitor_get_fps(&video_info);
/* Get the amount of frames per seconds. */
if (video_info.frame_count)
{
unsigned write_index =
video_driver_frame_time_count++ &
(MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);
video_driver_frame_time_samples[write_index] = new_time - fps_time;
fps_time = new_time;
if ((video_info.frame_count % FPS_UPDATE_INTERVAL) == 0)
{
char frames_text[64];
fill_pathname_noext(video_driver_window_title,
video_driver_title_buf,
" || ",
sizeof(video_driver_window_title));
if (video_info.fps_show)
{
last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL);
snprintf(video_info.fps_text,
sizeof(video_info.fps_text),
" FPS: %6.1f || ", last_fps);
strlcat(video_driver_window_title,
video_info.fps_text,
sizeof(video_driver_window_title));
}
curr_time = new_time;
strlcat(video_driver_window_title,
"Frames: ",
sizeof(video_driver_window_title));
snprintf(frames_text,
sizeof(frames_text),
STRING_REP_UINT64,
(unsigned long long)video_info.frame_count);
strlcat(video_driver_window_title,
frames_text,
sizeof(video_driver_window_title));
video_driver_window_title_update = true;
}
if (video_info.fps_show)
snprintf(
video_info.fps_text,
sizeof(video_info.fps_text),
"FPS: %6.1f || %s: " STRING_REP_UINT64,
last_fps,
msg_hash_to_str(MSG_FRAMES),
(unsigned long long)video_info.frame_count);
}
else
{
curr_time = fps_time = new_time;
strlcpy(video_driver_window_title,
video_driver_title_buf,
sizeof(video_driver_window_title));
if (video_info.fps_show)
strlcpy(video_info.fps_text,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(video_info.fps_text));
video_driver_window_title_update = true;
}
/* Slightly messy code,
* but we really need to do processing before blocking on VSync
@ -2253,6 +2250,7 @@ bool video_driver_texture_unload(uintptr_t *id)
void video_driver_build_info(video_frame_info_t *video_info)
{
bool is_perfcnt_enable = false;
bool is_paused = false;
bool is_idle = false;
bool is_slowmotion = false;
@ -2321,8 +2319,9 @@ void video_driver_build_info(video_frame_info_t *video_info)
video_info->menu_wallpaper_opacity = 0.0f;
#endif
runloop_get_status(&is_paused, &is_idle, &is_slowmotion);
runloop_get_status(&is_paused, &is_idle, &is_slowmotion, &is_perfcnt_enable);
video_info->is_perfcnt_enable = is_perfcnt_enable;
video_info->runloop_is_paused = is_paused;
video_info->runloop_is_idle = is_idle;
video_info->runloop_is_slowmotion = is_slowmotion;

View File

@ -131,6 +131,7 @@ typedef struct video_frame_info
bool runloop_is_slowmotion;
bool runloop_is_idle;
bool runloop_is_paused;
bool is_perfcnt_enable;
bool menu_is_alive;
} video_frame_info_t;

View File

@ -729,8 +729,8 @@ static bool video_thread_frame(void *data, const void *frame_,
return false;
}
performance_counter_init(&thr_frame, "thr_frame");
performance_counter_start(&thr_frame);
performance_counter_init(thr_frame, "thr_frame");
performance_counter_start_plus(video_info->is_perfcnt_enable, thr_frame);
copy_stride = width * (thr->info.rgb32
? sizeof(uint32_t) : sizeof(uint16_t));
@ -799,7 +799,7 @@ static bool video_thread_frame(void *data, const void *frame_,
slock_unlock(thr->lock);
performance_counter_stop(&thr_frame);
performance_counter_stop_plus(video_info->is_perfcnt_enable, thr_frame);
thr->last_time = cpu_features_get_time_usec();
return true;

View File

@ -563,8 +563,8 @@ recheckcapacity:;
goto recheckcapacity;
}
performance_counter_init(&gen_deltas, "gen_deltas");
performance_counter_start(&gen_deltas);
performance_counter_init(gen_deltas, "gen_deltas");
performance_counter_start(gen_deltas);
oldb = state->thisblock;
newb = state->nextblock;
@ -584,7 +584,7 @@ recheckcapacity:;
write_size_t(state->head, compressed-state->data);
state->head = compressed;
performance_counter_stop(&gen_deltas);
performance_counter_stop(gen_deltas);
}
else
state->thisblock_valid = true;
@ -765,15 +765,15 @@ bool state_manager_check_rewind(bool pressed,
state_manager_push_where(rewind_state.state, &state);
performance_counter_init(&rewind_serialize, "rewind_serialize");
performance_counter_start(&rewind_serialize);
performance_counter_init(rewind_serialize, "rewind_serialize");
performance_counter_start(rewind_serialize);
serial_info.data = state;
serial_info.size = rewind_state.size;
core_serialize(&serial_info);
performance_counter_stop(&rewind_serialize);
performance_counter_stop(rewind_serialize);
state_manager_push_do(rewind_state.state);
}

View File

@ -24,7 +24,6 @@
#endif
#include <compat/strl.h>
#include <features/features_cpu.h>
#include "performance_counters.h"
@ -121,33 +120,6 @@ void retro_perf_log(void)
log_counters(perf_counters_libretro, perf_ptr_libretro);
}
int performance_counter_init(struct retro_perf_counter *perf, const char *name)
{
perf->ident = name;
if (!perf->registered)
rarch_perf_register(perf);
return 0;
}
void performance_counter_start(struct retro_perf_counter *perf)
{
if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf)
return;
perf->call_cnt++;
perf->start = cpu_features_get_perf_counter();
}
void performance_counter_stop(struct retro_perf_counter *perf)
{
if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf)
return;
perf->total += cpu_features_get_perf_counter() - perf->start;
}
void rarch_timer_tick(rarch_timer_t *timer)
{
if (!timer)

View File

@ -22,6 +22,9 @@
#include <retro_common_api.h>
#include <libretro.h>
#include <features/features_cpu.h>
#include "runloop.h"
RETRO_BEGIN_DECLS
@ -54,7 +57,23 @@ void retro_perf_log(void);
void rarch_perf_log(void);
int performance_counter_init(struct retro_perf_counter *perf, const char *name);
void rarch_perf_register(struct retro_perf_counter *perf);
#define performance_counter_init(perf, name) \
perf.ident = name; \
if (!perf.registered) \
rarch_perf_register(&perf)
#define performance_counter_start_internal(is_perfcnt_enable, perf) \
if ((is_perfcnt_enable)) \
{ \
perf.call_cnt++; \
perf.start = cpu_features_get_perf_counter(); \
}
#define performance_counter_stop_internal(is_perfcnt_enable, perf) \
if ((is_perfcnt_enable)) \
perf.total += cpu_features_get_perf_counter() - perf.start
/**
* performance_counter_start:
@ -62,7 +81,8 @@ int performance_counter_init(struct retro_perf_counter *perf, const char *name);
*
* Start performance counter.
**/
void performance_counter_start(struct retro_perf_counter *perf);
#define performance_counter_start(perf) performance_counter_start_internal(runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL), perf)
#define performance_counter_start_plus(is_perfcnt_enable, perf) performance_counter_start_internal(is_perfcnt_enable, perf)
/**
* performance_counter_stop:
@ -70,7 +90,8 @@ void performance_counter_start(struct retro_perf_counter *perf);
*
* Stop performance counter.
**/
void performance_counter_stop(struct retro_perf_counter *perf);
#define performance_counter_stop(perf) performance_counter_stop_internal(runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL), perf)
#define performance_counter_stop_plus(is_perfcnt_enable, perf) performance_counter_stop_internal(is_perfcnt_enable, perf)
void rarch_timer_tick(rarch_timer_t *timer);

View File

@ -205,11 +205,12 @@ static bool rarch_game_specific_options(char **output)
}
void runloop_get_status(bool *is_paused, bool *is_idle,
bool *is_slowmotion)
bool *is_slowmotion, bool *is_perfcnt_enable)
{
*is_paused = runloop_paused;
*is_idle = runloop_idle;
*is_slowmotion = runloop_slowmotion;
*is_paused = runloop_paused;
*is_idle = runloop_idle;
*is_slowmotion = runloop_slowmotion;
*is_perfcnt_enable = runloop_perfcnt_enable;
}
bool runloop_msg_queue_pull(const char **ret)

View File

@ -204,7 +204,8 @@ void runloop_msg_queue_push(const char *msg, unsigned prio,
bool runloop_msg_queue_pull(const char **ret);
void runloop_get_status(bool *is_paused, bool *is_idle, bool *is_slowmotion);
void runloop_get_status(bool *is_paused, bool *is_idle, bool *is_slowmotion,
bool *is_perfcnt_enable);
bool runloop_ctl(enum runloop_ctl_state state, void *data);

View File

@ -389,12 +389,13 @@ static bool take_screenshot_choice(const char *name_base, bool savestate,
bool take_screenshot(const char *name_base, bool silence)
{
bool is_paused = false;
bool is_idle = false;
bool is_slowmotion = false;
bool ret = false;
bool is_paused = false;
bool is_idle = false;
bool is_slowmotion = false;
bool is_perfcnt_enable = false;
bool ret = false;
runloop_get_status(&is_paused, &is_idle, &is_slowmotion);
runloop_get_status(&is_paused, &is_idle, &is_slowmotion, &is_perfcnt_enable);
ret = take_screenshot_choice(name_base, silence, is_paused, is_idle);