summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-11-24 00:56:46 +0100
committersfan5 <sfan5@live.de>2023-11-28 10:46:16 +0100
commit281b1d89994e3e3a9950d32fc451dff990c2320d (patch)
tree4c978a78a24151561e638f0474d54f86eca178e6
parentf7402ff466d1426bd99eaac546d53708cc14c8b3 (diff)
downloadmpv-281b1d89994e3e3a9950d32fc451dff990c2320d.tar.bz2
mpv-281b1d89994e3e3a9950d32fc451dff990c2320d.tar.xz
vo_gpu: don't pass ra_fbo by value
Make it easier on compiler, no need to alloca and copy things around.
-rw-r--r--video/filter/vf_gpu.c2
-rw-r--r--video/out/gpu/libmpv_gpu.c2
-rw-r--r--video/out/gpu/osd.c4
-rw-r--r--video/out/gpu/osd.h2
-rw-r--r--video/out/gpu/utils.c6
-rw-r--r--video/out/gpu/utils.h2
-rw-r--r--video/out/gpu/video.c54
-rw-r--r--video/out/gpu/video.h2
-rw-r--r--video/out/vo_gpu.c2
-rw-r--r--video/out/vo_rpi.c2
10 files changed, 39 insertions, 39 deletions
diff --git a/video/filter/vf_gpu.c b/video/filter/vf_gpu.c
index fb11941379..dba4b3204f 100644
--- a/video/filter/vf_gpu.c
+++ b/video/filter/vf_gpu.c
@@ -212,7 +212,7 @@ static struct mp_image *gpu_render_frame(struct mp_filter *f, struct mp_image *i
// (it doesn't have access to the OSD though)
int flags = RENDER_FRAME_SUBS | RENDER_FRAME_VF_SUBS;
- gl_video_render_frame(priv->renderer, &frame, (struct ra_fbo){priv->target},
+ gl_video_render_frame(priv->renderer, &frame, &(struct ra_fbo){priv->target},
flags);
res = mp_image_alloc(IMGFMT_RGB0, w, h);
diff --git a/video/out/gpu/libmpv_gpu.c b/video/out/gpu/libmpv_gpu.c
index aae1d18eed..542db7f52c 100644
--- a/video/out/gpu/libmpv_gpu.c
+++ b/video/out/gpu/libmpv_gpu.c
@@ -185,7 +185,7 @@ static int render(struct render_backend *ctx, mpv_render_param *params,
&(int){0});
struct ra_fbo target = {.tex = tex, .flip = flip};
- gl_video_render_frame(p->renderer, frame, target, RENDER_FRAME_DEF);
+ gl_video_render_frame(p->renderer, frame, &target, RENDER_FRAME_DEF);
p->context->fns->done_frame(p->context, frame->display_synced);
return 0;
diff --git a/video/out/gpu/osd.c b/video/out/gpu/osd.c
index 91505a987d..7892904c74 100644
--- a/video/out/gpu/osd.c
+++ b/video/out/gpu/osd.c
@@ -286,7 +286,7 @@ static void get_3d_side_by_side(int stereo_mode, int div[2])
}
void mpgl_osd_draw_finish(struct mpgl_osd *ctx, int index,
- struct gl_shader_cache *sc, struct ra_fbo fbo)
+ struct gl_shader_cache *sc, const struct ra_fbo *fbo)
{
struct mpgl_osd_part *part = ctx->parts[index];
@@ -312,7 +312,7 @@ void mpgl_osd_draw_finish(struct mpgl_osd *ctx, int index,
const int *factors = &blend_factors[part->format][0];
gl_sc_blend(sc, factors[0], factors[1], factors[2], factors[3]);
- gl_sc_dispatch_draw(sc, fbo.tex, false, vertex_vao, MP_ARRAY_SIZE(vertex_vao),
+ gl_sc_dispatch_draw(sc, fbo->tex, false, vertex_vao, MP_ARRAY_SIZE(vertex_vao),
sizeof(struct vertex), part->vertices, part->num_vertices);
}
diff --git a/video/out/gpu/osd.h b/video/out/gpu/osd.h
index 00fbc4914f..1b05e254f8 100644
--- a/video/out/gpu/osd.h
+++ b/video/out/gpu/osd.h
@@ -18,7 +18,7 @@ void mpgl_osd_resize(struct mpgl_osd *ctx, struct mp_osd_res res, int stereo_mod
bool mpgl_osd_draw_prepare(struct mpgl_osd *ctx, int index,
struct gl_shader_cache *sc);
void mpgl_osd_draw_finish(struct mpgl_osd *ctx, int index,
- struct gl_shader_cache *sc, struct ra_fbo fbo);
+ struct gl_shader_cache *sc, const struct ra_fbo *fbo);
bool mpgl_osd_check_change(struct mpgl_osd *ctx, struct mp_osd_res *res,
double pts);
diff --git a/video/out/gpu/utils.c b/video/out/gpu/utils.c
index 8a1aacfff5..d18cf6e8e0 100644
--- a/video/out/gpu/utils.c
+++ b/video/out/gpu/utils.c
@@ -33,10 +33,10 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x)
gl_transform_vec(t, &x->t[0], &x->t[1]);
}
-void gl_transform_ortho_fbo(struct gl_transform *t, struct ra_fbo fbo)
+void gl_transform_ortho_fbo(struct gl_transform *t, const struct ra_fbo *fbo)
{
- int y_dir = fbo.flip ? -1 : 1;
- gl_transform_ortho(t, 0, fbo.tex->params.w, 0, fbo.tex->params.h * y_dir);
+ int y_dir = fbo->flip ? -1 : 1;
+ gl_transform_ortho(t, 0, fbo->tex->params.w, 0, fbo->tex->params.h * y_dir);
}
float gl_video_scale_ambient_lux(float lmin, float lmax,
diff --git a/video/out/gpu/utils.h b/video/out/gpu/utils.h
index 215873eec8..dd52c383b1 100644
--- a/video/out/gpu/utils.h
+++ b/video/out/gpu/utils.h
@@ -63,7 +63,7 @@ static inline bool gl_transform_eq(struct gl_transform a, struct gl_transform b)
void gl_transform_trans(struct gl_transform t, struct gl_transform *x);
-void gl_transform_ortho_fbo(struct gl_transform *t, struct ra_fbo fbo);
+void gl_transform_ortho_fbo(struct gl_transform *t, const struct ra_fbo *fbo);
float gl_video_scale_ambient_lux(float lmin, float lmax,
float rmin, float rmax, float lux);
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 852ee78cde..8c8cbea703 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -1216,7 +1216,7 @@ static void dispatch_compute(struct gl_video *p, int w, int h,
}
static struct mp_pass_perf render_pass_quad(struct gl_video *p,
- struct ra_fbo fbo, bool discard,
+ const struct ra_fbo *fbo, bool discard,
const struct mp_rect *dst)
{
// The first element is reserved for `vec2 position`
@@ -1274,11 +1274,11 @@ static struct mp_pass_perf render_pass_quad(struct gl_video *p,
&p->tmp_vertex[num_vertex_attribs * 1],
vertex_stride);
- return gl_sc_dispatch_draw(p->sc, fbo.tex, discard, p->vao, num_vertex_attribs,
+ return gl_sc_dispatch_draw(p->sc, fbo->tex, discard, p->vao, num_vertex_attribs,
vertex_stride, p->tmp_vertex, num_vertices);
}
-static void finish_pass_fbo(struct gl_video *p, struct ra_fbo fbo,
+static void finish_pass_fbo(struct gl_video *p, const struct ra_fbo *fbo,
bool discard, const struct mp_rect *dst)
{
pass_prepare_src_tex(p);
@@ -1319,7 +1319,7 @@ static void finish_pass_tex(struct gl_video *p, struct ra_tex **dst_tex,
debug_check_gl(p, "after dispatching compute shader");
} else {
struct ra_fbo fbo = { .tex = *dst_tex, };
- finish_pass_fbo(p, fbo, true, &(struct mp_rect){0, 0, w, h});
+ finish_pass_fbo(p, &fbo, true, &(struct mp_rect){0, 0, w, h});
}
}
@@ -2891,7 +2891,7 @@ static void pass_dither(struct gl_video *p)
// Draws the OSD, in scene-referred colors.. If cms is true, subtitles are
// instead adapted to the display's gamut.
static void pass_draw_osd(struct gl_video *p, int osd_flags, int frame_flags,
- double pts, struct mp_osd_res rect, struct ra_fbo fbo,
+ double pts, struct mp_osd_res rect, const struct ra_fbo *fbo,
bool cms)
{
if (frame_flags & RENDER_FRAME_VF_SUBS)
@@ -2916,7 +2916,7 @@ static void pass_draw_osd(struct gl_video *p, int osd_flags, int frame_flags,
.light = MP_CSP_LIGHT_DISPLAY,
};
- pass_colormanage(p, csp_srgb, fbo.color_space, frame_flags, true);
+ pass_colormanage(p, csp_srgb, fbo->color_space, frame_flags, true);
}
mpgl_osd_draw_finish(p->osd, n, p->sc, fbo);
}
@@ -3013,7 +3013,7 @@ static bool pass_render_frame(struct gl_video *p, struct mp_image *mpi,
};
finish_pass_tex(p, &p->blend_subs_tex, rect.w, rect.h);
struct ra_fbo fbo = { p->blend_subs_tex };
- pass_draw_osd(p, OSD_DRAW_SUB_ONLY, flags, vpts, rect, fbo, false);
+ pass_draw_osd(p, OSD_DRAW_SUB_ONLY, flags, vpts, rect, &fbo, false);
pass_read_tex(p, p->blend_subs_tex);
pass_describe(p, "blend subs video");
}
@@ -3045,7 +3045,7 @@ static bool pass_render_frame(struct gl_video *p, struct mp_image *mpi,
}
finish_pass_tex(p, &p->blend_subs_tex, p->texture_w, p->texture_h);
struct ra_fbo fbo = { p->blend_subs_tex };
- pass_draw_osd(p, OSD_DRAW_SUB_ONLY, flags, vpts, rect, fbo, false);
+ pass_draw_osd(p, OSD_DRAW_SUB_ONLY, flags, vpts, rect, &fbo, false);
pass_read_tex(p, p->blend_subs_tex);
pass_describe(p, "blend subs");
}
@@ -3055,7 +3055,7 @@ static bool pass_render_frame(struct gl_video *p, struct mp_image *mpi,
return true;
}
-static void pass_draw_to_screen(struct gl_video *p, struct ra_fbo fbo, int flags)
+static void pass_draw_to_screen(struct gl_video *p, const struct ra_fbo *fbo, int flags)
{
if (p->dumb_mode)
pass_render_frame_dumb(p);
@@ -3067,7 +3067,7 @@ static void pass_draw_to_screen(struct gl_video *p, struct ra_fbo fbo, int flags
GLSL(color.rgb = pow(color.rgb, vec3(user_gamma));)
}
- pass_colormanage(p, p->image_params.color, fbo.color_space, flags, false);
+ pass_colormanage(p, p->image_params.color, fbo->color_space, flags, false);
// Since finish_pass_fbo doesn't work with compute shaders, and neither
// does the checkerboard/dither code, we may need an indirection via
@@ -3134,7 +3134,7 @@ static bool update_surface(struct gl_video *p, struct mp_image *mpi,
// Draws an interpolate frame to fbo, based on the frame timing in t
// flags: bit set of RENDER_FRAME_* flags
static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t,
- struct ra_fbo fbo, int flags)
+ const struct ra_fbo *fbo, int flags)
{
bool is_new = false;
@@ -3306,11 +3306,11 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t,
}
void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
- struct ra_fbo fbo, int flags)
+ const struct ra_fbo *fbo, int flags)
{
gl_video_update_options(p);
- struct mp_rect target_rc = {0, 0, fbo.tex->params.w, fbo.tex->params.h};
+ struct mp_rect target_rc = {0, 0, fbo->tex->params.w, fbo->tex->params.h};
p->broken_frame = false;
@@ -3318,12 +3318,12 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
struct m_color c = p->clear_color;
float clear_color[4] = {c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0};
- p->ra->fns->clear(p->ra, fbo.tex, clear_color, &target_rc);
+ p->ra->fns->clear(p->ra, fbo->tex, clear_color, &target_rc);
if (p->hwdec_overlay) {
if (has_frame) {
float *color = p->hwdec_overlay->overlay_colorkey;
- p->ra->fns->clear(p->ra, fbo.tex, color, &p->dst_rect);
+ p->ra->fns->clear(p->ra, fbo->tex, color, &p->dst_rect);
}
p->hwdec_overlay->driver->overlay_frame(p->hwdec_overlay, frame->current,
@@ -3364,23 +3364,23 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
// For the non-interpolation case, we draw to a single "cache"
// texture to speed up subsequent re-draws (if any exist)
- struct ra_fbo dest_fbo = fbo;
+ const struct ra_fbo *dest_fbo = fbo;
bool repeats = frame->num_vsyncs > 1 && frame->display_synced;
if ((repeats || frame->still) && !p->dumb_mode &&
- (p->ra->caps & RA_CAP_BLIT) && fbo.tex->params.blit_dst)
+ (p->ra->caps & RA_CAP_BLIT) && fbo->tex->params.blit_dst)
{
// Attempt to use the same format as the destination FBO
// if possible. Some RAs use a wrapped dummy format here,
// so fall back to the fbo_format in that case.
- const struct ra_format *fmt = fbo.tex->params.format;
+ const struct ra_format *fmt = fbo->tex->params.format;
if (fmt->dummy_format)
fmt = p->fbo_format;
bool r = ra_tex_resize(p->ra, p->log, &p->output_tex,
- fbo.tex->params.w, fbo.tex->params.h,
+ fbo->tex->params.w, fbo->tex->params.h,
fmt);
if (r) {
- dest_fbo = (struct ra_fbo) { p->output_tex };
+ dest_fbo = &(struct ra_fbo) { p->output_tex };
p->output_tex_valid = true;
}
}
@@ -3388,17 +3388,17 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
}
// "output tex valid" and "output tex needed" are equivalent
- if (p->output_tex_valid && fbo.tex->params.blit_dst) {
+ if (p->output_tex_valid && fbo->tex->params.blit_dst) {
pass_info_reset(p, true);
pass_describe(p, "redraw cached frame");
struct mp_rect src = p->dst_rect;
struct mp_rect dst = src;
- if (fbo.flip) {
- dst.y0 = fbo.tex->params.h - src.y0;
- dst.y1 = fbo.tex->params.h - src.y1;
+ if (fbo->flip) {
+ dst.y0 = fbo->tex->params.h - src.y0;
+ dst.y1 = fbo->tex->params.h - src.y1;
}
timer_pool_start(p->blit_timer);
- p->ra->fns->blit(p->ra, fbo.tex, p->output_tex, &dst, &src);
+ p->ra->fns->blit(p->ra, fbo->tex, p->output_tex, &dst, &src);
timer_pool_stop(p->blit_timer);
pass_record(p, timer_pool_measure(p->blit_timer));
}
@@ -3431,7 +3431,7 @@ done:
// Make the screen solid blue to make it visually clear that an
// error has occurred
float color[4] = {0.0, 0.05, 0.5, 1.0};
- p->ra->fns->clear(p->ra, fbo.tex, color, &target_rc);
+ p->ra->fns->clear(p->ra, fbo->tex, color, &target_rc);
}
p->frames_rendered++;
@@ -3522,7 +3522,7 @@ void gl_video_screenshot(struct gl_video *p, struct vo_frame *frame,
flags |= RENDER_FRAME_OSD;
if (args->scaled)
flags |= RENDER_SCREEN_COLOR;
- gl_video_render_frame(p, nframe, (struct ra_fbo){target}, flags);
+ gl_video_render_frame(p, nframe, &(struct ra_fbo){target}, flags);
res = mp_image_alloc(mpfmt, params.w, params.h);
if (!res)
diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h
index 411d336a21..bbcf1c2695 100644
--- a/video/out/gpu/video.h
+++ b/video/out/gpu/video.h
@@ -195,7 +195,7 @@ void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd);
bool gl_video_check_format(struct gl_video *p, int mp_format);
void gl_video_config(struct gl_video *p, struct mp_image_params *params);
void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
- struct ra_fbo fbo, int flags);
+ const struct ra_fbo *fbo, int flags);
void gl_video_resize(struct gl_video *p,
struct mp_rect *src, struct mp_rect *dst,
struct mp_osd_res *osd);
diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c
index c02e6e730d..6abe20b0d7 100644
--- a/video/out/vo_gpu.c
+++ b/video/out/vo_gpu.c
@@ -80,7 +80,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
if (!sw->fns->start_frame(sw, &fbo))
return;
- gl_video_render_frame(p->renderer, frame, fbo, RENDER_FRAME_DEF);
+ gl_video_render_frame(p->renderer, frame, &fbo, RENDER_FRAME_DEF);
if (!sw->fns->submit_frame(sw, frame)) {
MP_ERR(vo, "Failed presenting frame!\n");
return;
diff --git a/video/out/vo_rpi.c b/video/out/vo_rpi.c
index 55f1a68edb..174b9df0b2 100644
--- a/video/out/vo_rpi.c
+++ b/video/out/vo_rpi.c
@@ -267,7 +267,7 @@ static void update_osd(struct vo *vo)
.flip = true,
};
gl_video_set_osd_pts(p->gl_video, p->osd_pts);
- gl_video_render_frame(p->gl_video, &frame, target, RENDER_FRAME_DEF);
+ gl_video_render_frame(p->gl_video, &frame, &target, RENDER_FRAME_DEF);
ra_tex_free(p->egl.ra, &target.tex);
MP_STATS(vo, "stop rpi_osd");