summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Jin <bjin@ctrl-d.org>2016-06-11 23:42:59 +0000
committerwm4 <wm4@nowhere>2016-06-12 17:51:50 +0200
commit3d844cddf8179c0a6d1d65ed9c2b13b15f70180e (patch)
treed8862aa13ee69b2b7fcf566deaac1f06a44bcf0d
parent0b082b2086d69019edf116bb162a46d3932aefcb (diff)
downloadmpv-3d844cddf8179c0a6d1d65ed9c2b13b15f70180e.tar.bz2
mpv-3d844cddf8179c0a6d1d65ed9c2b13b15f70180e.tar.xz
vo_opengl: make size of OUTPUT available to user shaders
-rw-r--r--DOCS/man/vo.rst6
-rw-r--r--video/out/opengl/video.c9
2 files changed, 12 insertions, 3 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index 7eaf2d6636..8a7d235ca3 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -747,9 +747,9 @@ Available video output drivers are:
Specifies the size of the resulting texture for this pass.
``szexpr`` refers to an expression in RPN (reverse polish
notation), using the operators + - * / > < !, floating point
- literals, and references to existing texture sizes such as
- MAIN.width or CHROMA.height. By default, these are set to HOOKED.w
- and HOOKED.h, respectively.
+ literals, and references to sizes of existing texture and OUTPUT
+ (such as MAIN.width or CHROMA.height). By default, these are set to
+ HOOKED.w and HOOKED.h, respectively.
WHEN <szexpr>
Specifies a condition that needs to be true (non-zero) for the
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 21eda6bc7d..c9179c7800 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1688,6 +1688,15 @@ static bool eval_szexpr(struct gl_video *p, struct img_tex tex,
struct bstr name = expr[i].val.varname;
struct img_tex var_tex;
+ // The size of OUTPUT is determined. It could be useful for certain
+ // user shaders to skip passes.
+ if (bstr_equals0(name, "OUTPUT")) {
+ int vp_w = p->dst_rect.x1 - p->dst_rect.x0;
+ int vp_h = p->dst_rect.y1 - p->dst_rect.y0;
+ stack[idx++] = (expr[i].tag == SZEXP_VAR_W) ? vp_w : vp_h;
+ continue;
+ }
+
// HOOKED is a special case
if (bstr_equals0(name, "HOOKED")) {
var_tex = tex;