diff options
author | 2016-05-27 16:51:01 +0200 | |
---|---|---|
committer | 2016-05-27 17:03:00 +0200 | |
commit | f8df0528b5b43bb148ceeb16732c96254e48c43e (patch) | |
tree | ddef0b6facebb66747113e0b750c3a69660730f8 /video/out/opengl/user_shaders.c | |
parent | 72e94941c9f417a7fd7f58955bc46a923b8fa02f (diff) |
vo_opengl: skip junk before first user shader pass
A lot of real-world shaders start off with comments explaining the usage
or license, generating lots of "empty" passes. This simply change allows
us to skip them, which silences the warning spam and prevents us from
having to store and copy around these empty passes.
It also adds a more useful failure check: Attempting to use a user
shader that doesn't define any passes at all.
Diffstat (limited to 'video/out/opengl/user_shaders.c')
-rw-r--r-- | video/out/opengl/user_shaders.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/video/out/opengl/user_shaders.c b/video/out/opengl/user_shaders.c index 226b9f69f6..4e9c1c89e8 100644 --- a/video/out/opengl/user_shaders.c +++ b/video/out/opengl/user_shaders.c @@ -82,6 +82,14 @@ bool parse_user_shader_pass(struct mp_log *log, struct bstr *body, int hook_idx = 0; int bind_idx = 0; + // Skip all garbage (e.g. comments) before the first header + int pos = bstr_find(*body, bstr0("//!")); + if (pos < 0) { + mp_warn(log, "Shader appears to contain no passes!\n"); + return false; + } + *body = bstr_cut(*body, pos); + // First parse all the headers while (true) { struct bstr rest; |