diff options
Diffstat (limited to 'video/out/gpu/shader_cache.c')
-rw-r--r-- | video/out/gpu/shader_cache.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c index bf0983f5f0..3e051730fd 100644 --- a/video/out/gpu/shader_cache.c +++ b/video/out/gpu/shader_cache.c @@ -17,7 +17,7 @@ #include "utils.h" // Force cache flush if more than this number of shaders is created. -#define SC_MAX_ENTRIES 48 +#define SC_MAX_ENTRIES 256 union uniform_val { float f[9]; // RA_VARTYPE_FLOAT @@ -339,7 +339,7 @@ void gl_sc_uniform_image2D_wo(struct gl_shader_cache *sc, const char *name, struct sc_uniform *u = find_uniform(sc, name); u->input.type = RA_VARTYPE_IMG_W; - u->glsl_type = "writeonly image2D"; + u->glsl_type = sc->ra->glsl_es ? "writeonly highp image2D" : "writeonly image2D"; u->input.binding = gl_sc_next_binding(sc, u->input.type); u->v.tex = tex; } @@ -486,7 +486,7 @@ static const char *vao_glsl_type(const struct ra_renderpass_input *e) case 2: return "vec2"; case 3: return "vec3"; case 4: return "vec4"; - default: abort(); + default: MP_ASSERT_UNREACHABLE(); } } @@ -553,14 +553,20 @@ static void update_uniform(struct gl_shader_cache *sc, struct sc_entry *e, assert(e->pushc); update_pushc(sc->ra, e->pushc, u); break; - default: abort(); + default: MP_ASSERT_UNREACHABLE(); } } -void gl_sc_set_cache_dir(struct gl_shader_cache *sc, const char *dir) +void gl_sc_set_cache_dir(struct gl_shader_cache *sc, char *dir) { talloc_free(sc->cache_dir); + if (dir && dir[0]) { + dir = mp_get_user_path(NULL, sc->global, dir); + } else { + dir = mp_find_user_file(NULL, sc->global, "cache", ""); + } sc->cache_dir = talloc_strdup(sc, dir); + talloc_free(dir); } static bool create_pass(struct gl_shader_cache *sc, struct sc_entry *entry) @@ -579,8 +585,7 @@ static bool create_pass(struct gl_shader_cache *sc, struct sc_entry *entry) cache_dir = mp_get_user_path(tmp, sc->global, sc->cache_dir); struct AVSHA *sha = av_sha_alloc(); - if (!sha) - abort(); + MP_HANDLE_OOM(sha); av_sha_init(sha, 256); av_sha_update(sha, entry->total.start, entry->total.len); @@ -700,7 +705,7 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst) case RA_VARTYPE_INT: case RA_VARTYPE_FLOAT: assert(sc->ra->caps & RA_CAP_GLOBAL_UNIFORM); - // fall through + MP_FALLTHROUGH; case RA_VARTYPE_TEX: // Vulkan requires explicitly assigning the bindings in the shader // source. For OpenGL it's optional, but requires higher GL version @@ -786,7 +791,7 @@ static void gl_sc_generate(struct gl_shader_cache *sc, ADD(header, "#else\n"); ADD(header, "precision mediump float;\n"); ADD(header, "#endif\n"); - + ADD(header, "precision mediump sampler2D;\n"); if (sc->ra->caps & RA_CAP_TEX_3D) ADD(header, "precision mediump sampler3D;\n"); |