mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
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.)
This commit is contained in:
parent
dd096863fa
commit
f72a33d2cb
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user