From 001271309c18c37babd6934fbd3875890d1a312d Mon Sep 17 00:00:00 2001 From: Niklas Haas <git@haasn.xyz> Date: Wed, 20 May 2020 07:44:46 +0200 Subject: [PATCH] shaders: make sh_subpass slightly stricter The current logic allows resizeable parents to become non-resizeable, which is a big no-no since resizeable parents are almost definitely intended for a framebuffer size that has nothing at all to do with the subpass. To fix this, only allow merging resizeable shaders with subpasses that are also resizeable. --- src/shaders.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/shaders.c b/src/shaders.c index 58c2ab341..2584c49f4 100644 --- a/src/shaders.c +++ b/src/shaders.c @@ -369,13 +369,11 @@ ident_t sh_subpass(struct pl_shader *sh, const struct pl_shader *sub) return NULL; } - // Check for shader compatibility - int res_w = PL_DEF(sh->output_w, sub->output_w), - res_h = PL_DEF(sh->output_h, sub->output_h); + int sub_w = PL_DEF(sub->output_w, sh->output_w), + sub_h = PL_DEF(sub->output_h, sh->output_h); - if ((sub->output_w && res_w != sub->output_w) || - (sub->output_h && res_h != sub->output_h)) - { + // Check for shader compatibility + if (sh->output_w != sub_w || sh->output_h != sub_h) { PL_TRACE(sh, "Can't merge shaders: incompatible sizes: %dx%d and %dx%d", sh->output_w, sh->output_h, sub->output_w, sub->output_h); return NULL; @@ -393,9 +391,6 @@ ident_t sh_subpass(struct pl_shader *sh, const struct pl_shader *sub) } } - sh->output_w = res_w; - sh->output_h = res_h; - // Append the prelude and header bstr_xappend(sh, &sh->buffers[SH_BUF_PRELUDE], sub->buffers[SH_BUF_PRELUDE]); bstr_xappend(sh, &sh->buffers[SH_BUF_HEADER], sub->buffers[SH_BUF_HEADER]); -- GitLab