diff options
author | Niklas Haas <git@haasn.xyz> | 2017-08-07 17:42:50 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-08-07 17:47:04 +0200 |
commit | bed421d4832179fc6254a6f54e2f779afe40ad63 (patch) | |
tree | 625709da3fd1c2b5aefb5fc1f9be0e6e3a4431d7 /video/out/opengl/ra_gl.c | |
parent | ecbb02148b2f5afb6920c33a8d5bb8d3cd44b3a8 (diff) | |
download | mpv-bed421d4832179fc6254a6f54e2f779afe40ad63.tar.bz2 mpv-bed421d4832179fc6254a6f54e2f779afe40ad63.tar.xz |
vo_opengl: nuke ra_gl->first_run
Completely unnecessary, we can just update the uniforms immediately
after creating the program. In theory, for GLSL 4.20+, we could even
skip this, but oh well.
Diffstat (limited to 'video/out/opengl/ra_gl.c')
-rw-r--r-- | video/out/opengl/ra_gl.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index bc38a60e53..8c36fa11ff 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -690,18 +690,28 @@ static struct ra_renderpass *gl_renderpass_create(struct ra *ra, talloc_steal(pass, cached.start); pass->params.cached_program = cached; + gl->UseProgram(pass_gl->program); for (int n = 0; n < params->num_inputs; n++) { GLint loc = gl->GetUniformLocation(pass_gl->program, params->inputs[n].name); MP_TARRAY_APPEND(pass_gl, pass_gl->uniform_loc, pass_gl->num_uniform_loc, loc); + + // For compatibility with older OpenGL, we need to explicitly update + // the texture/image unit bindings after creating the shader program, + // since specifying it directly requires GLSL 4.20+ + switch (params->inputs[n].type) { + case RA_VARTYPE_TEX: + case RA_VARTYPE_IMG_W: + gl->Uniform1i(loc, params->inputs[n].binding); + break; + } } + gl->UseProgram(0); gl_vao_init(&pass_gl->vao, gl, params->vertex_stride, params->vertex_attribs, params->num_vertex_attribs); - pass_gl->first_run = true; - return pass; } @@ -761,8 +771,6 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass, struct ra_tex *tex = *(struct ra_tex **)val->data; struct ra_tex_gl *tex_gl = tex->priv; assert(tex->params.render_src); - if (pass_gl->first_run) - gl->Uniform1i(loc, input->binding); if (input->type == RA_VARTYPE_TEX) { gl->ActiveTexture(GL_TEXTURE0 + input->binding); gl->BindTexture(tex_gl->target, tex_gl->texture); @@ -867,8 +875,6 @@ static void gl_renderpass_run(struct ra *ra, gl->ActiveTexture(GL_TEXTURE0); gl->UseProgram(0); - - pass_gl->first_run = false; } // Timers in GL use query objects, and are asynchronous. So pool a few of |