diff --git a/libobs-opengl/gl-shaderparser.c b/libobs-opengl/gl-shaderparser.c index abf349e1b..5e4291ad5 100644 --- a/libobs-opengl/gl-shaderparser.c +++ b/libobs-opengl/gl-shaderparser.c @@ -325,7 +325,6 @@ static inline bool gl_write_texture_call(struct gl_shader_parser *glsp, const char *call, bool sampler) { struct cf_parser *cfp = &glsp->parser.cfp; - size_t sampler_id = (size_t)-1; if (!cf_next_token(cfp)) return false; @@ -335,16 +334,16 @@ static inline bool gl_write_texture_call(struct gl_shader_parser *glsp, if (sampler) { if (!cf_next_token(cfp)) return false; - sampler_id = sp_getsampler(glsp, cfp->cur_token); + const size_t sampler_id = sp_getsampler(glsp, cfp->cur_token); if (sampler_id == (size_t)-1) return false; if (!cf_next_token(cfp)) return false; if (!cf_token_is(cfp, ",")) return false; - } - var->gl_sampler_id = sampler_id; + var->gl_sampler_id = sampler_id; + } dstr_cat(&glsp->gl_string, call); dstr_cat(&glsp->gl_string, "("); diff --git a/libobs/graphics/shader-parser.h b/libobs/graphics/shader-parser.h index ff7343aa8..3776734e3 100644 --- a/libobs/graphics/shader-parser.h +++ b/libobs/graphics/shader-parser.h @@ -76,6 +76,7 @@ static inline void shader_var_init_param(struct shader_var *sv, char *type, sv->name = name; sv->mapping = NULL; sv->array_count = 0; + sv->gl_sampler_id = (size_t)-1; da_init(sv->default_val); }