libobs: Default sampler sometimes unset for GL

When mixing sampling with raw loads in a shader, ending a shader with a
load would case the default sampler to become unset for OpenGL. Instead,
initialize with no sampler, and only set if there is a sampler.
This commit is contained in:
jpark37 2019-07-25 21:08:47 -07:00
parent 2c6aac32c8
commit 2f286b81d9
2 changed files with 4 additions and 4 deletions

View File

@ -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, "(");

View File

@ -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);
}