diff options
author | Niklas Haas <git@haasn.xyz> | 2017-09-23 15:15:51 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-09-23 16:36:58 +0200 |
commit | 89cdccfa6c757a2cb0cdc5cd04f99237cf175a16 (patch) | |
tree | 3738e0c71e2636e2e0553f5887f093916a406d0a | |
parent | 365b1d4f3d3f3d521002aeb9c4c91c1df1cf0814 (diff) | |
download | mpv-89cdccfa6c757a2cb0cdc5cd04f99237cf175a16.tar.bz2 mpv-89cdccfa6c757a2cb0cdc5cd04f99237cf175a16.tar.xz |
vo_gpu: fix possible segfault on shader miscompile
Iterations after the first time will fail to realize that the pass was
never created. This function's logic and control flow is so annoying...
-rw-r--r-- | video/out/gpu/shader_cache.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c index 86939083db..28490fda2f 100644 --- a/video/out/gpu/shader_cache.c +++ b/video/out/gpu/shader_cache.c @@ -571,10 +571,6 @@ static bool create_pass(struct gl_shader_cache *sc, struct sc_entry *entry) MP_TARRAY_APPEND(sc, params.inputs, params.num_inputs, ubo_input); } - entry->pass = sc->ra->fns->renderpass_create(sc->ra, ¶ms); - if (!entry->pass) - goto error; - if (sc->ubo_size) { struct ra_buf_params ubo_params = { .type = RA_BUF_TYPE_UNIFORM, @@ -589,6 +585,10 @@ static bool create_pass(struct gl_shader_cache *sc, struct sc_entry *entry) } } + entry->pass = sc->ra->fns->renderpass_create(sc->ra, ¶ms); + if (!entry->pass) + goto error; + if (entry->pass && cache_filename) { bstr nc = entry->pass->params.cached_program; if (nc.len && !bstr_equals(params.cached_program, nc)) { @@ -869,7 +869,8 @@ static void gl_sc_generate(struct gl_shader_cache *sc, sc->error_state = true; MP_TARRAY_APPEND(sc, sc->entries, sc->num_entries, entry); } - if (sc->error_state) { + + if (!entry->pass) { sc->current_shader = NULL; return; } |