diff options
author | wm4 <wm4@nowhere> | 2016-05-19 11:57:41 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-05-19 12:01:59 +0200 |
commit | b0d3c2ede7591ed5a0f4183b815573179a00c1fd (patch) | |
tree | 90064559ba6251a2fd727554729a3c89541e770b /video/out/opengl | |
parent | b46eaa3b439f0db4bf4abffaa343497355f25224 (diff) |
vo_opengl: make gl_sc_enable_extension() permanent/idempotent
No reason not to, and makes the following commit slightly simpler.
In fact, this makes the shaders more correct too. Normally, "#extension"
must come before any normal shader text, including the "precision"
directive. Not sure why this worked before. (Probably didn't.)
Diffstat (limited to 'video/out/opengl')
-rw-r--r-- | video/out/opengl/utils.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index dd23e9724e..199895e4ec 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -478,7 +478,11 @@ struct gl_shader_cache { GL *gl; struct mp_log *log; - // this is modified during use (gl_sc_add() etc.) + // permanent + char **exts; + int num_exts; + + // this is modified during use (gl_sc_add() etc.) and reset for each shader bstr prelude_text; bstr header_text; bstr text; @@ -554,7 +558,11 @@ void gl_sc_reset_error(struct gl_shader_cache *sc) void gl_sc_enable_extension(struct gl_shader_cache *sc, char *name) { - bstr_xappend_asprintf(sc, &sc->prelude_text, "#extension %s : enable\n", name); + for (int n = 0; n < sc->num_exts; n++) { + if (strcmp(sc->exts[n], name) == 0) + return; + } + MP_TARRAY_APPEND(sc, sc->exts, sc->num_exts, talloc_strdup(sc, name)); } #define bstr_xappend0(sc, b, s) bstr_xappend(sc, b, bstr0(s)) @@ -905,6 +913,8 @@ void gl_sc_gen_shader_and_reset(struct gl_shader_cache *sc) // set up shader text (header + uniforms + body) bstr *header = &sc->tmp[0]; ADD(header, "#version %d%s\n", gl->glsl_version, gl->es >= 300 ? " es" : ""); + for (int n = 0; n < sc->num_exts; n++) + ADD(header, "#extension %s : enable\n", sc->exts[n]); if (gl->es) ADD(header, "precision mediump float;\n"); ADD_BSTR(header, sc->prelude_text); |