From f72a33d2cb223df921967cfe7ae203f882ba6921 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Aug 2017 13:48:46 +0200 Subject: vo_opengl: organize ra PBO flag slightly differently Instead of having a mutable ra_tex field (and the only one), move the flag to struct ra, since we have only 2 tex_upload user calls anyway, and both want the same PBO behavior. (At first I considered making it a RA_TEX_UPLOAD_ flag, but why bother. PBOs are a terribly GL-specific thing, so we can't expect a reasonable abstraction of it anyway.) --- video/out/opengl/osd.c | 8 -------- video/out/opengl/osd.h | 2 -- video/out/opengl/ra.h | 7 +++++-- video/out/opengl/ra_gl.c | 2 +- video/out/opengl/video.c | 8 ++------ 5 files changed, 8 insertions(+), 19 deletions(-) (limited to 'video') diff --git a/video/out/opengl/osd.c b/video/out/opengl/osd.c index 8b178f212d..89820693ab 100644 --- a/video/out/opengl/osd.c +++ b/video/out/opengl/osd.c @@ -66,7 +66,6 @@ struct mpgl_osd { struct osd_state *osd; struct ra *ra; GL *gl; - bool use_pbo; struct mpgl_osd_part *parts[MAX_OSD_PARTS]; const struct ra_format *fmt_table[SUBBITMAP_COUNT]; bool formats[SUBBITMAP_COUNT]; @@ -115,11 +114,6 @@ void mpgl_osd_destroy(struct mpgl_osd *ctx) talloc_free(ctx); } -void mpgl_osd_set_options(struct mpgl_osd *ctx, bool pbo) -{ - ctx->use_pbo = pbo; -} - static int next_pow2(int v) { for (int x = 0; x < 30; x++) { @@ -175,8 +169,6 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd, goto done; } - osd->texture->use_pbo = ctx->use_pbo; - struct mp_rect rc = {0, 0, imgs->packed_w, imgs->packed_h}; ra->fns->tex_upload(ra, osd->texture, imgs->packed->planes[0], imgs->packed->stride[0], &rc, RA_TEX_UPLOAD_DISCARD, diff --git a/video/out/opengl/osd.h b/video/out/opengl/osd.h index 89d52f313e..a0aa104a48 100644 --- a/video/out/opengl/osd.h +++ b/video/out/opengl/osd.h @@ -13,8 +13,6 @@ struct mpgl_osd *mpgl_osd_init(struct ra *ra, struct mp_log *log, struct osd_state *osd); void mpgl_osd_destroy(struct mpgl_osd *ctx); -void mpgl_osd_set_options(struct mpgl_osd *ctx, bool pbo); - void mpgl_osd_generate(struct mpgl_osd *ctx, struct mp_osd_res res, double pts, int stereo_mode, int draw_flags); void mpgl_osd_resize(struct mpgl_osd *ctx, struct mp_osd_res res, int stereo_mode); diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h index 3249bc7448..ab3027b78a 100644 --- a/video/out/opengl/ra.h +++ b/video/out/opengl/ra.h @@ -20,6 +20,11 @@ struct ra { // Set of supported texture formats. Must be added by RA backend at init time. struct ra_format **formats; int num_formats; + + // GL-specific: if set, accelerate texture upload by using an additional + // buffer (i.e. uses more memory). Does not affect uploads done by + // ra_tex_create (if initial_data is set). Set by the RA user. + bool use_pbo; }; enum { @@ -92,8 +97,6 @@ struct ra_tex { // All fields are read-only after creation. struct ra_tex_params params; void *priv; - // Set by user, GL only: attempt to accelerate upload with PBOs. - bool use_pbo; }; // A persistent mapping, which can be used for texture upload. diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index 411adddec6..e1ecd337e4 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -338,7 +338,7 @@ static void gl_tex_upload(struct ra *ra, struct ra_tex *tex, case 2: if (!rc) rc = &full; - gl_pbo_upload_tex(&tex_gl->pbo, gl, tex->use_pbo && !buf, + gl_pbo_upload_tex(&tex_gl->pbo, gl, ra->use_pbo && !buf, tex_gl->target, tex_gl->format, tex_gl->type, tex->params.w, tex->params.h, src, stride, rc->x0, rc->y0, rc->x1 - rc->x0, rc->y1 - rc->y0); diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 3442e9fb59..b9d91936e7 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -505,10 +505,8 @@ static void reinit_osd(struct gl_video *p) { mpgl_osd_destroy(p->osd); p->osd = NULL; - if (p->osd_state) { + if (p->osd_state) p->osd = mpgl_osd_init(p->ra, p->log, p->osd_state); - mpgl_osd_set_options(p->osd, p->opts.pbo); - } } static void uninit_rendering(struct gl_video *p) @@ -3320,9 +3318,6 @@ static bool pass_upload_image(struct gl_video *p, struct mp_image *mpi, uint64_t plane->flipped = mpi->stride[0] < 0; - // (It's unclear whether this should be changeable on the fly.) - plane->tex->use_pbo = p->opts.pbo; - struct dr_buffer *mapped = gl_find_dr_buffer(p, mpi->planes[n]); p->ra->fns->tex_upload(p->ra, plane->tex, mpi->planes[n], @@ -3709,6 +3704,7 @@ static void reinit_from_options(struct gl_video *p) check_gl_features(p); uninit_rendering(p); gl_sc_set_cache_dir(p->sc, p->global, p->opts.shader_cache_dir); + p->ra->use_pbo = p->opts.pbo; gl_video_setup_hooks(p); reinit_osd(p); -- cgit v1.2.3