summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-07-20 11:26:01 +0200
committerNiklas Haas <git@haasn.xyz>2017-07-24 17:19:34 +0200
commit0c84ee01d5387e7c59d97de71046d173e4c3461a (patch)
tree6919885f0481f5927a8e69fe482a5fdce9e805d1 /video
parentf338ec45912846a75dbb4217cad000ceb9b33d40 (diff)
downloadmpv-0c84ee01d5387e7c59d97de71046d173e4c3461a.tar.bz2
mpv-0c84ee01d5387e7c59d97de71046d173e4c3461a.tar.xz
vo_opengl: support user compute shaders
These are identical to regular fragment shader hooks, but with extra metadata indicating the preferred block size.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/user_shaders.c8
-rw-r--r--video/out/opengl/user_shaders.h2
-rw-r--r--video/out/opengl/video.c2
3 files changed, 12 insertions, 0 deletions
diff --git a/video/out/opengl/user_shaders.c b/video/out/opengl/user_shaders.c
index 427295b0ad..718034fa2d 100644
--- a/video/out/opengl/user_shaders.c
+++ b/video/out/opengl/user_shaders.c
@@ -269,6 +269,14 @@ bool parse_user_shader_pass(struct mp_log *log, struct bstr *body,
continue;
}
+ if (bstr_eatstart0(&line, "COMPUTE")) {
+ if (bstr_sscanf(line, "%d %d", &out->compute_w, &out->compute_h) != 2) {
+ mp_err(log, "Error while parsing COMPUTE!\n");
+ return false;
+ }
+ continue;
+ }
+
// Unknown command type
mp_err(log, "Unrecognized command '%.*s'!\n", BSTR_P(line));
return false;
diff --git a/video/out/opengl/user_shaders.h b/video/out/opengl/user_shaders.h
index 458e925bc4..3b7913f236 100644
--- a/video/out/opengl/user_shaders.h
+++ b/video/out/opengl/user_shaders.h
@@ -66,6 +66,8 @@ struct gl_user_shader {
struct szexp height[MAX_SZEXP_SIZE];
struct szexp cond[MAX_SZEXP_SIZE];
int components;
+ int compute_w;
+ int compute_h;
};
// Parse the next shader pass from 'body'. Returns false if the end of the
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 5a4d17e454..d4f746e3a2 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1339,6 +1339,7 @@ static void hook_prelude(struct gl_video *p, const char *name, int id,
GLSLHF("#define %s_size texture_size%d\n", name, id);
GLSLHF("#define %s_rot texture_rot%d\n", name, id);
GLSLHF("#define %s_pt pixel_size%d\n", name, id);
+ GLSLHF("#define %s_map texmap%d\n", name, id);
GLSLHF("#define %s_mul %f\n", name, tex.multiplier);
// Set up the sampling functions
@@ -1903,6 +1904,7 @@ static void user_hook(struct gl_video *p, struct img_tex tex,
pass_describe(p, "user shader: %.*s (%s)", BSTR_P(shader->desc),
plane_names[tex.type]);
+ compute_size_minimum(p, shader->compute_w, shader->compute_h);
load_shader(p, shader->pass_body);
GLSLF("color = hook();\n");