From 89cdccfa6c757a2cb0cdc5cd04f99237cf175a16 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 23 Sep 2017 15:15:51 +0200 Subject: 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... --- video/out/gpu/shader_cache.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'video') 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; } -- cgit v1.2.3