summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-23 22:13:03 +0200
committerwm4 <wm4@nowhere>2015-09-23 22:13:03 +0200
commit17cd6798a69ca2fea1d7e7df692c71172183731f (patch)
tree9708d64e0d52379ad80b489c45c145194033e33a /video/out/opengl/utils.c
parentd8d4e188352160a2eac0e004d341ab5c3f997e6e (diff)
downloadmpv-17cd6798a69ca2fea1d7e7df692c71172183731f.tar.bz2
mpv-17cd6798a69ca2fea1d7e7df692c71172183731f.tar.xz
vo_opengl: move shader file caching to video.c
It's just about loading and cachign small files, not does not necessarily have anything to do with shaders. Move it to video.c where it's used.
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r--video/out/opengl/utils.c44
1 files changed, 1 insertions, 43 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c
index b5d33b15c3..ac36bdffc4 100644
--- a/video/out/opengl/utils.c
+++ b/video/out/opengl/utils.c
@@ -28,7 +28,6 @@
#include <stdarg.h>
#include <assert.h>
-#include "stream/stream.h"
#include "common/common.h"
#include "utils.h"
@@ -465,7 +464,6 @@ void gl_set_debug_logger(GL *gl, struct mp_log *log)
#define SC_ENTRIES 16
#define SC_UNIFORM_ENTRIES 20
-#define SC_FILE_ENTRIES 10
enum uniform_type {
UT_invalid,
@@ -486,11 +484,6 @@ struct sc_uniform {
} v;
};
-struct sc_file {
- char *path;
- char *body;
-};
-
struct sc_entry {
GLuint gl_shader;
// the following fields define the shader's contents
@@ -501,7 +494,6 @@ struct sc_entry {
struct gl_shader_cache {
GL *gl;
struct mp_log *log;
- struct mpv_global *global;
// this is modified during use (gl_sc_add() etc.)
char *text;
@@ -513,19 +505,14 @@ struct gl_shader_cache {
struct sc_uniform uniforms[SC_UNIFORM_ENTRIES];
int num_uniforms;
-
- struct sc_file files[SC_FILE_ENTRIES];
- int num_files;
};
-struct gl_shader_cache *gl_sc_create(GL *gl, struct mp_log *log,
- struct mpv_global *global)
+struct gl_shader_cache *gl_sc_create(GL *gl, struct mp_log *log)
{
struct gl_shader_cache *sc = talloc_ptrtype(NULL, sc);
*sc = (struct gl_shader_cache){
.gl = gl,
.log = log,
- .global = global,
.text = talloc_strdup(sc, ""),
.header_text = talloc_strdup(sc, ""),
};
@@ -586,35 +573,6 @@ void gl_sc_haddf(struct gl_shader_cache *sc, const char *textf, ...)
va_end(ap);
}
-const char *gl_sc_loadfile(struct gl_shader_cache *sc, const char *path)
-{
- if (!path || !path[0] || !sc->global)
- return NULL;
- for (int n = 0; n < sc->num_files; n++) {
- if (strcmp(sc->files[n].path, path) == 0)
- return sc->files[n].body;
- }
- // not found -> load it
- if (sc->num_files == SC_FILE_ENTRIES) {
- // empty cache when it overflows
- for (int n = 0; n < sc->num_files; n++) {
- talloc_free(sc->files[n].path);
- talloc_free(sc->files[n].body);
- }
- sc->num_files = 0;
- }
- struct bstr s = stream_read_file(path, sc, sc->global, 100000); // 100 kB
- if (s.len) {
- struct sc_file *new = &sc->files[sc->num_files++];
- *new = (struct sc_file) {
- .path = talloc_strdup(sc, path),
- .body = s.start
- };
- return new->body;
- }
- return NULL;
-}
-
static struct sc_uniform *find_uniform(struct gl_shader_cache *sc,
const char *name)
{