summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-09 16:24:01 +0100
committerwm4 <wm4@nowhere>2015-11-09 16:24:01 +0100
commiteeb5f987585b47b2d5828cac0f2d90e0c503ce4c (patch)
tree5b359aa42f70f15811d74272af735fb3f127df27 /video/out/opengl/utils.c
parentcaa497ee8af7ceab2a1e0a1df4e06ff467e5fd1d (diff)
downloadmpv-eeb5f987585b47b2d5828cac0f2d90e0c503ce4c.tar.bz2
mpv-eeb5f987585b47b2d5828cac0f2d90e0c503ce4c.tar.xz
vo_opengl: handle GL_ARB_uniform_buffer_object with low GLSL versions
Why is this stupid crap being so much a pain for no reason.
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r--video/out/opengl/utils.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c
index 6ddb333e47..83bed06498 100644
--- a/video/out/opengl/utils.c
+++ b/video/out/opengl/utils.c
@@ -513,8 +513,9 @@ struct gl_shader_cache {
struct mp_log *log;
// this is modified during use (gl_sc_add() etc.)
- char *text;
+ char *prelude_text;
char *header_text;
+ char *text;
struct gl_vao *vao;
struct sc_entry entries[SC_ENTRIES];
@@ -530,16 +531,18 @@ struct gl_shader_cache *gl_sc_create(GL *gl, struct mp_log *log)
*sc = (struct gl_shader_cache){
.gl = gl,
.log = log,
- .text = talloc_strdup(sc, ""),
+ .prelude_text = talloc_strdup(sc, ""),
.header_text = talloc_strdup(sc, ""),
+ .text = talloc_strdup(sc, ""),
};
return sc;
}
void gl_sc_reset(struct gl_shader_cache *sc)
{
- sc->text[0] = '\0';
+ sc->prelude_text[0] = '\0';
sc->header_text[0] = '\0';
+ sc->text[0] = '\0';
for (int n = 0; n < sc->num_uniforms; n++) {
talloc_free(sc->uniforms[n].name);
if (sc->uniforms[n].type == UT_buffer)
@@ -567,6 +570,12 @@ void gl_sc_destroy(struct gl_shader_cache *sc)
talloc_free(sc);
}
+void gl_sc_enable_extension(struct gl_shader_cache *sc, char *name)
+{
+ sc->prelude_text = talloc_asprintf_append(sc->prelude_text,
+ "#extension %s : enable\n", name);
+}
+
void gl_sc_add(struct gl_shader_cache *sc, const char *text)
{
sc->text = talloc_strdup_append(sc->text, text);
@@ -867,6 +876,7 @@ void gl_sc_gen_shader_and_reset(struct gl_shader_cache *sc)
gl->es >= 300 ? " es" : "");
if (gl->es)
ADD(header, "precision mediump float;\n");
+ ADD(header, "%s", sc->prelude_text);
char *vert_in = gl->glsl_version >= 130 ? "in" : "attribute";
char *vert_out = gl->glsl_version >= 130 ? "out" : "varying";
char *frag_in = gl->glsl_version >= 130 ? "in" : "varying";