From 988d188d96d48ce7c78c09276982edb3c481b123 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 5 Aug 2017 19:38:43 +0200 Subject: vo_opengl: drop ra_gl.h from shader_cache.c Since the GL *gl is no longer needed for the timers, we can get rid of the sc->gl dependency. This requires moving a utility function (which is not GL-specific anyway) out of gl_utils.h and into utils.h --- video/out/opengl/gl_utils.c | 16 ---------------- video/out/opengl/gl_utils.h | 4 ---- video/out/opengl/ra_gl.c | 1 + video/out/opengl/shader_cache.c | 7 ++----- video/out/opengl/utils.c | 16 ++++++++++++++++ video/out/opengl/utils.h | 4 ++++ 6 files changed, 23 insertions(+), 25 deletions(-) (limited to 'video') diff --git a/video/out/opengl/gl_utils.c b/video/out/opengl/gl_utils.c index e042b56b4a..aa00e5c165 100644 --- a/video/out/opengl/gl_utils.c +++ b/video/out/opengl/gl_utils.c @@ -130,22 +130,6 @@ mp_image_t *gl_read_fbo_contents(GL *gl, int fbo, int w, int h) return image; } -void mp_log_source(struct mp_log *log, int lev, const char *src) -{ - int line = 1; - if (!src) - return; - while (*src) { - const char *end = strchr(src, '\n'); - const char *next = end + 1; - if (!end) - next = end = src + strlen(src); - mp_msg(log, lev, "[%3d] %.*s\n", line, (int)(end - src), src); - line++; - src = next; - } -} - static void gl_vao_enable_attribs(struct gl_vao *vao) { GL *gl = vao->gl; diff --git a/video/out/opengl/gl_utils.h b/video/out/opengl/gl_utils.h index 3d0abce54b..c7b478790a 100644 --- a/video/out/opengl/gl_utils.h +++ b/video/out/opengl/gl_utils.h @@ -34,10 +34,6 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, mp_image_t *gl_read_fbo_contents(GL *gl, int fbo, int w, int h); -// print a multi line string with line numbers (e.g. for shader sources) -// log, lev: module and log level, as in mp_msg() -void mp_log_source(struct mp_log *log, int lev, const char *src); - struct gl_vao { GL *gl; GLuint vao; // the VAO object, or 0 if unsupported by driver diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index 7b78f7d924..4c99fe0f59 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -1,6 +1,7 @@ #include #include "formats.h" +#include "utils.h" #include "ra_gl.h" static struct ra_fns ra_fns_gl; diff --git a/video/out/opengl/shader_cache.c b/video/out/opengl/shader_cache.c index f4be7a2de6..68d9d4cab2 100644 --- a/video/out/opengl/shader_cache.c +++ b/video/out/opengl/shader_cache.c @@ -15,7 +15,6 @@ #include "stream/stream.h" #include "shader_cache.h" #include "formats.h" -#include "ra_gl.h" #include "utils.h" // Force cache flush if more than this number of shaders is created. @@ -48,7 +47,6 @@ struct sc_entry { struct gl_shader_cache { struct ra *ra; - GL *gl; struct mp_log *log; // permanent @@ -97,7 +95,6 @@ struct gl_shader_cache *gl_sc_create(struct ra *ra, struct mpv_global *global, struct gl_shader_cache *sc = talloc_ptrtype(NULL, sc); *sc = (struct gl_shader_cache){ .ra = ra, - .gl = ra_gl_get(ra), .global = global, .log = log, }; @@ -105,8 +102,8 @@ struct gl_shader_cache *gl_sc_create(struct ra *ra, struct mpv_global *global, return sc; } -// Reset the previous pass. This must be called after -// Unbind all GL state managed by sc - the current program and texture units. +// Reset the previous pass. This must be called after gl_sc_generate and before +// starting a new shader. static void gl_sc_reset(struct gl_shader_cache *sc) { sc->prelude_text.len = 0; diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 097970890f..f4ea3d5472 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -221,3 +221,19 @@ struct mp_pass_perf timer_pool_measure(struct timer_pool *pool) return res; } + +void mp_log_source(struct mp_log *log, int lev, const char *src) +{ + int line = 1; + if (!src) + return; + while (*src) { + const char *end = strchr(src, '\n'); + const char *next = end + 1; + if (!end) + next = end = src + strlen(src); + mp_msg(log, lev, "[%3d] %.*s\n", line, (int)(end - src), src); + line++; + src = next; + } +} diff --git a/video/out/opengl/utils.h b/video/out/opengl/utils.h index 7ffffa6547..e053fba1ae 100644 --- a/video/out/opengl/utils.h +++ b/video/out/opengl/utils.h @@ -86,3 +86,7 @@ void timer_pool_destroy(struct timer_pool *pool); void timer_pool_start(struct timer_pool *pool); void timer_pool_stop(struct timer_pool *pool); struct mp_pass_perf timer_pool_measure(struct timer_pool *pool); + +// print a multi line string with line numbers (e.g. for shader sources) +// log, lev: module and log level, as in mp_msg() +void mp_log_source(struct mp_log *log, int lev, const char *src); -- cgit v1.2.3