summaryrefslogtreecommitdiffstats
path: root/video/out/vo_opengl_cb.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-12 21:57:54 +0100
committerwm4 <wm4@nowhere>2015-03-12 23:20:20 +0100
commite74a4d5bc0b101fbfb371942c00d3a77267dc4a6 (patch)
treea9cc46910567eaf32ba0b47c9539f47418565d41 /video/out/vo_opengl_cb.c
parentae6019cbc98cfad2613e89a80bee79ce6b2f1319 (diff)
downloadmpv-e74a4d5bc0b101fbfb371942c00d3a77267dc4a6.tar.bz2
mpv-e74a4d5bc0b101fbfb371942c00d3a77267dc4a6.tar.xz
vo_opengl: refactor shader generation (part 1)
The basic idea is to use dynamically generated shaders instead of a single monolithic file + a ton of ifdefs. Instead of having to setup every aspect of it separately (like compiling shaders, setting uniforms, perfoming the actual rendering steps, the GLSL parts), we generate the GLSL on the fly, and perform the rendering at the same time. The GLSL is regenerated every frame, but the actual compiled OpenGL-level shaders are cached, which makes it fast again. Almost all logic can be in a single place. The new code is significantly more flexible, which allows us to improve the code clarity, performance and add more features easily. This commit is incomplete. It drops almost all previous code, and readds only the most important things (some of them actually buggy). The next commit will complete it - it's separate to preserve authorship information.
Diffstat (limited to 'video/out/vo_opengl_cb.c')
-rw-r--r--video/out/vo_opengl_cb.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index cd04f5219b..e20be8dd67 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -66,7 +66,7 @@ struct mpv_opengl_cb_context {
int queued_frames;
struct mp_image_params img_params;
bool reconfigured;
- struct mp_rect wnd;
+ int vp_w, vp_h;
bool flip;
bool force_update;
bool imgfmt_supported[IMGFMT_END - IMGFMT_START];
@@ -282,28 +282,22 @@ int mpv_opengl_cb_render(struct mpv_opengl_cb_context *ctx, int fbo, int vp[4])
ctx->force_update |= ctx->reconfigured;
- int h = vp[3];
- bool flip = h < 0 && h > INT_MIN;
- if (flip)
- h = -h;
- struct mp_rect wnd = {vp[0], vp[1], vp[0] + vp[2], vp[1] + h};
- if (wnd.x0 != ctx->wnd.x0 || wnd.y0 != ctx->wnd.y0 ||
- wnd.x1 != ctx->wnd.x1 || wnd.y1 != ctx->wnd.y1 ||
- ctx->flip != flip)
+ int vp_w = vp[2], vp_h = vp[3];
+ if (ctx->vp_w != vp_w || ctx->vp_h != vp_h)
ctx->force_update = true;
if (ctx->force_update && vo) {
ctx->force_update = false;
- ctx->wnd = wnd;
- ctx->flip = flip;
+ ctx->vp_w = vp_w;
+ ctx->vp_h = vp_h;
struct mp_rect src, dst;
struct mp_osd_res osd;
mp_get_src_dst_rects(ctx->log, &ctx->vo_opts, vo->driver->caps,
- &ctx->img_params, wnd.x1 - wnd.x0, wnd.y1 - wnd.y0,
+ &ctx->img_params, vp_w, abs(vp_h),
1.0, &src, &dst, &osd);
- gl_video_resize(ctx->renderer, &wnd, &src, &dst, &osd, !ctx->flip);
+ gl_video_resize(ctx->renderer, vp_w, vp_h, &src, &dst, &osd);
}
if (ctx->reconfigured)