mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-28 23:13:18 +08:00
vo_gpu_next: add sw upload time to stats
Also fix lingering hw map stats.
This commit is contained in:
+23
-3
@@ -112,6 +112,8 @@ struct priv {
|
||||
struct ra_hwdec_mapper *hwdec_mapper;
|
||||
struct timer_pool *hwdec_timer;
|
||||
struct mp_pass_perf hwdec_perf;
|
||||
struct timer_pool *sw_upload_timer;
|
||||
struct mp_pass_perf sw_upload_perf;
|
||||
|
||||
// Allocated DR buffers
|
||||
mp_mutex dr_lock;
|
||||
@@ -719,6 +721,7 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
|
||||
}
|
||||
|
||||
if (fp->hwdec) {
|
||||
p->sw_upload_perf.count = 0;
|
||||
|
||||
struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(par.imgfmt);
|
||||
frame->acquire = hwdec_acquire;
|
||||
@@ -743,6 +746,10 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
|
||||
}
|
||||
|
||||
} else { // swdec
|
||||
p->hwdec_perf.count = 0;
|
||||
|
||||
if (!p->sw_upload_timer)
|
||||
p->sw_upload_timer = timer_pool_create(p->ra_ctx->ra);
|
||||
|
||||
struct pl_plane_data data[4] = {0};
|
||||
bool use_uint = false;
|
||||
@@ -753,6 +760,7 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
|
||||
use_uint = true;
|
||||
|
||||
frame->num_planes = plane_data_from_imgfmt(data, &frame->repr.bits, mpi->imgfmt, use_uint);
|
||||
timer_pool_start(p->sw_upload_timer);
|
||||
for (int n = 0; n < frame->num_planes; n++) {
|
||||
struct pl_plane *plane = &frame->planes[n];
|
||||
data[n].width = mp_image_plane_w(mpi, n);
|
||||
@@ -778,11 +786,14 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
|
||||
|
||||
if (!pl_upload_plane(gpu, plane, &tex[n], &data[n])) {
|
||||
MP_ERR(vo, "Failed uploading frame!\n");
|
||||
timer_pool_stop(p->sw_upload_timer);
|
||||
talloc_free(data[n].priv);
|
||||
talloc_free(mpi);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
timer_pool_stop(p->sw_upload_timer);
|
||||
p->sw_upload_perf = timer_pool_measure(p->sw_upload_timer);
|
||||
|
||||
}
|
||||
|
||||
@@ -1765,7 +1776,8 @@ done:
|
||||
|
||||
static inline void copy_frame_info_to_mp(struct frame_info *pl,
|
||||
struct mp_frame_perf *mp,
|
||||
struct mp_pass_perf *hwdec_perf)
|
||||
struct mp_pass_perf *hwdec_perf,
|
||||
struct mp_pass_perf *sw_upload_perf)
|
||||
{
|
||||
static_assert(MP_ARRAY_SIZE(pl->info) == MP_ARRAY_SIZE(mp->perf), "");
|
||||
mp_assert(pl->count <= VO_PASS_PERF_MAX);
|
||||
@@ -1780,6 +1792,12 @@ static inline void copy_frame_info_to_mp(struct frame_info *pl,
|
||||
desc++;
|
||||
}
|
||||
|
||||
if (sw_upload_perf && sw_upload_perf->count > 0) {
|
||||
*perf++ = *sw_upload_perf;
|
||||
snprintf(*desc, sizeof(*desc), "upload frame (swdec)");
|
||||
desc++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pl->count && perf < perf_end; ++i) {
|
||||
const struct pl_dispatch_info *pass = &pl->info[i];
|
||||
|
||||
@@ -1857,8 +1875,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
|
||||
case VOCTRL_PERFORMANCE_DATA: {
|
||||
struct voctrl_performance_data *perf = data;
|
||||
copy_frame_info_to_mp(&p->perf_fresh, &perf->fresh, &p->hwdec_perf);
|
||||
copy_frame_info_to_mp(&p->perf_redraw, &perf->redraw, NULL);
|
||||
copy_frame_info_to_mp(&p->perf_fresh, &perf->fresh, &p->hwdec_perf, &p->sw_upload_perf);
|
||||
copy_frame_info_to_mp(&p->perf_redraw, &perf->redraw, NULL, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2108,6 +2126,8 @@ static void uninit(struct vo *vo)
|
||||
for (int i = 0; i < p->num_user_hooks; i++)
|
||||
pl_mpv_user_shader_destroy(&p->user_hooks[i].hook);
|
||||
|
||||
timer_pool_destroy(p->sw_upload_timer);
|
||||
|
||||
if (vo->hwdec_devs) {
|
||||
ra_hwdec_mapper_free(&p->hwdec_mapper);
|
||||
timer_pool_destroy(p->hwdec_timer);
|
||||
|
||||
Reference in New Issue
Block a user