Skip to content

Commit

Permalink
Revert "vo_gpu_next: use pl_dispatch_info_move to avoid useless data …
Browse files Browse the repository at this point in the history
…copy"

We wanted to preserve the libplacebo v5.264.0 requirement for gpu_next
for this release, since this is the what most Linux distributions are shipping.
The VLC 3 <-> libplacebo v6 situation is an additional reason distros are not
likely to ship the newest libplacebo release soon.
This reverts commit b73d967.
  • Loading branch information
sfan5 committed Jul 23, 2023
1 parent 007019a commit 5236003
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 48 deletions.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ if features['libplacebo']
endif

libplacebo_next = get_option('libplacebo-next').require(
features['libplacebo'] and libplacebo.version().version_compare('>=5.266.0'),
error_message: 'libplacebo v5.266.0+ was not found!',
features['libplacebo'] and libplacebo.version().version_compare('>=5.264.0'),
error_message: 'libplacebo v5.264.0+ was not found!',
)
features += {'libplacebo-next': libplacebo_next.allowed()}
if features['libplacebo-next']
Expand Down
67 changes: 21 additions & 46 deletions video/out/vo_gpu_next.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ struct user_lut {
struct pl_custom_lut *lut;
};

struct frame_info {
int count;
struct pl_dispatch_info info[VO_PASS_PERF_MAX];
};

struct priv {
struct mp_log *log;
struct mpv_global *global;
Expand Down Expand Up @@ -151,8 +146,7 @@ struct priv {
int num_user_hooks;

// Performance data of last frame
struct frame_info perf_fresh;
struct frame_info perf_redraw;
struct voctrl_performance_data perf;

bool delayed_peak;
bool inter_preserve;
Expand Down Expand Up @@ -756,15 +750,28 @@ static void info_callback(void *priv, const struct pl_render_info *info)
if (info->index >= VO_PASS_PERF_MAX)
return; // silently ignore clipped passes, whatever

struct frame_info *frame;
struct mp_frame_perf *frame;
switch (info->stage) {
case PL_RENDER_STAGE_FRAME: frame = &p->perf_fresh; break;
case PL_RENDER_STAGE_BLEND: frame = &p->perf_redraw; break;
case PL_RENDER_STAGE_FRAME: frame = &p->perf.fresh; break;
case PL_RENDER_STAGE_BLEND: frame = &p->perf.redraw; break;
default: abort();
}

frame->count = info->index + 1;
pl_dispatch_info_move(&frame->info[info->index], info->pass);
int index = info->index;
struct mp_pass_perf *perf = &frame->perf[index];
const struct pl_dispatch_info *pass = info->pass;
static_assert(VO_PERF_SAMPLE_COUNT >= MP_ARRAY_SIZE(pass->samples), "");
assert(pass->num_samples <= MP_ARRAY_SIZE(pass->samples));

perf->count = MPMIN(pass->num_samples, VO_PERF_SAMPLE_COUNT);
memcpy(perf->samples, pass->samples, perf->count * sizeof(pass->samples[0]));
perf->last = pass->last;
perf->peak = pass->peak;
perf->avg = pass->average;

strncpy(frame->desc[index], pass->shader->description, sizeof(frame->desc[index]) - 1);
frame->desc[index][sizeof(frame->desc[index]) - 1] = '\0';
frame->count = index + 1;
}

static void update_options(struct vo *vo)
Expand Down Expand Up @@ -1292,30 +1299,6 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
pl_tex_destroy(gpu, &fbo);
}

static inline void copy_frame_info_to_mp(struct frame_info *pl,
struct mp_frame_perf *mp) {
static_assert(MP_ARRAY_SIZE(pl->info) == MP_ARRAY_SIZE(mp->perf), "");
assert(pl->count <= VO_PASS_PERF_MAX);
mp->count = MPMIN(pl->count, VO_PASS_PERF_MAX);

for (int i = 0; i < mp->count; ++i) {
const struct pl_dispatch_info *pass = &pl->info[i];

static_assert(VO_PERF_SAMPLE_COUNT >= MP_ARRAY_SIZE(pass->samples), "");
assert(pass->num_samples <= MP_ARRAY_SIZE(pass->samples));

struct mp_pass_perf *perf = &mp->perf[i];
perf->count = MPMIN(pass->num_samples, VO_PERF_SAMPLE_COUNT);
memcpy(perf->samples, pass->samples, perf->count * sizeof(pass->samples[0]));
perf->last = pass->last;
perf->peak = pass->peak;
perf->avg = pass->average;

strncpy(mp->desc[i], pass->shader->description, sizeof(mp->desc[i]) - 1);
mp->desc[i][sizeof(mp->desc[i]) - 1] = '\0';
}
}

static int control(struct vo *vo, uint32_t request, void *data)
{
struct priv *p = vo->priv;
Expand Down Expand Up @@ -1357,12 +1340,9 @@ static int control(struct vo *vo, uint32_t request, void *data)
p->want_reset = true;
return VO_TRUE;

case VOCTRL_PERFORMANCE_DATA: {
struct voctrl_performance_data *perf = data;
copy_frame_info_to_mp(&p->perf_fresh, &perf->fresh);
copy_frame_info_to_mp(&p->perf_redraw, &perf->redraw);
case VOCTRL_PERFORMANCE_DATA:
*(struct voctrl_performance_data *) data = p->perf;
return true;
}

case VOCTRL_SCREENSHOT:
video_screenshot(vo, data);
Expand Down Expand Up @@ -1468,11 +1448,6 @@ static void uninit(struct vo *vo)

pl_renderer_destroy(&p->rr);

for (int i = 0; i < VO_PASS_PERF_MAX; ++i) {
pl_shader_info_deref(&p->perf_fresh.info[i].shader);
pl_shader_info_deref(&p->perf_redraw.info[i].shader);
}

p->ra_ctx = NULL;
p->pllog = NULL;
p->gpu = NULL;
Expand Down

0 comments on commit 5236003

Please sign in to comment.