Skip to content

Commit

Permalink
vo_gpu: fix possible segfault on shader miscompile
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
haasn committed Sep 23, 2017
1 parent 365b1d4 commit 89cdccf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions video/out/gpu/shader_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params);
if (!entry->pass)
goto error;

if (sc->ubo_size) {
struct ra_buf_params ubo_params = {
.type = RA_BUF_TYPE_UNIFORM,
Expand All @@ -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, &params);
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)) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 89cdccf

Please sign in to comment.