aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out/opengl
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-09-12 19:47:26 +0200
committerGravatar wm4 <wm4@nowhere>2016-09-12 20:05:43 +0200
commite8cdc22245835cb17c82a9dc1525ffa793e34541 (patch)
treeb797253c3dfac14b2df2536ed5c8e2c9e578dea8 /video/out/opengl
parentb261e1e782cfa12b70b4601b136e07df16bdd651 (diff)
vo_opengl: better behavior in GL error corner cases
If the shader fails to compile, and assertion could trigger in gl_sc_gen_shader_and_reset() due to the code trying to recreate the shader every time, and re-appending the uniforms every time. Just reset the uniform array to fix this. Some disturbed GL drivers might not return anything for glGetShaderiv() if the GL state got "lost", so initialize variables just for additional robustness.
Diffstat (limited to 'video/out/opengl')
-rw-r--r--video/out/opengl/utils.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c
index 72a748a82d..c97aebaa88 100644
--- a/video/out/opengl/utils.c
+++ b/video/out/opengl/utils.c
@@ -780,9 +780,9 @@ static void compile_attach_shader(struct gl_shader_cache *sc, GLuint program,
GLuint shader = gl->CreateShader(type);
gl->ShaderSource(shader, 1, &source, NULL);
gl->CompileShader(shader);
- GLint status;
+ GLint status = 0;
gl->GetShaderiv(shader, GL_COMPILE_STATUS, &status);
- GLint log_length;
+ GLint log_length = 0;
gl->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DEBUG) : MSGL_ERR;
@@ -820,9 +820,9 @@ static void link_shader(struct gl_shader_cache *sc, GLuint program)
{
GL *gl = sc->gl;
gl->LinkProgram(program);
- GLint status;
+ GLint status = 0;
gl->GetProgramiv(program, GL_LINK_STATUS, &status);
- GLint log_length;
+ GLint log_length = 0;
gl->GetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DEBUG) : MSGL_ERR;
@@ -980,6 +980,7 @@ void gl_sc_gen_shader_and_reset(struct gl_shader_cache *sc)
// build vertex shader from vao and cache the locations of the uniform variables
if (!entry->gl_shader) {
entry->gl_shader = create_program(sc, vert->start, frag->start);
+ entry->num_uniforms = 0;
for (int n = 0; n < sc->num_uniforms; n++) {
struct sc_cached_uniform un = {
.loc = gl->GetUniformLocation(entry->gl_shader,