From dfc7b59909588985ee1be19f313f8bfb858ab8b0 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 12 May 2016 11:27:00 +0200 Subject: vo_opengl: make the screen blue on shader errors This helps visually signify that somthing went wrong, and prevents confusing shader compilation errors with other types of bugs. --- video/out/opengl/utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'video/out/opengl/utils.c') diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index d29d7b0bdb..5ef99ac599 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -485,6 +485,8 @@ struct gl_shader_cache { struct sc_uniform uniforms[SC_UNIFORM_ENTRIES]; int num_uniforms; + bool error_state; // true if an error occurred + // temporary buffers (avoids frequent reallocations) bstr tmp[5]; }; @@ -532,6 +534,16 @@ void gl_sc_destroy(struct gl_shader_cache *sc) talloc_free(sc); } +bool gl_sc_error_state(struct gl_shader_cache *sc) +{ + return sc->error_state; +} + +void gl_sc_reset_error(struct gl_shader_cache *sc) +{ + sc->error_state = false; +} + void gl_sc_enable_extension(struct gl_shader_cache *sc, char *name) { bstr_xappend_asprintf(sc, &sc->prelude_text, "#extension %s : enable\n", name); @@ -810,6 +822,9 @@ static void compile_attach_shader(struct gl_shader_cache *sc, GLuint program, gl->AttachShader(program, shader); gl->DeleteShader(shader); + + if (!status) + sc->error_state = true; } static void link_shader(struct gl_shader_cache *sc, GLuint program) @@ -828,6 +843,9 @@ static void link_shader(struct gl_shader_cache *sc, GLuint program) MP_MSG(sc, pri, "shader link log (status=%d): %s\n", status, logstr); talloc_free(logstr); } + + if (!status) + sc->error_state = true; } static GLuint create_program(struct gl_shader_cache *sc, const char *vertex, -- cgit v1.2.3