Browse Source

libobs-opengl: Fix bug with texelFetch shader intrinsic

This is supposed to assign -1 to the sampler_id to indicate that no
sampler need be assigned for the texture, but instead it was leaving the
variable with uninitialized data, resulting in a crash when used.
jp9000 9 years ago
parent
commit
92af243a27
1 changed files with 2 additions and 1 deletions
  1. 2 1
      libobs-opengl/gl-shaderparser.c

+ 2 - 1
libobs-opengl/gl-shaderparser.c

@@ -312,11 +312,12 @@ static inline bool gl_write_texture_call(struct gl_shader_parser *glsp,
 		if (!cf_next_token(cfp))    return false;
 		sampler_id = sp_getsampler(glsp, cfp->cur_token);
 		if (sampler_id == (size_t) -1) return false;
-		var->gl_sampler_id = sampler_id;
 		if (!cf_next_token(cfp))    return false;
 		if (!cf_token_is(cfp, ",")) return false;
 	}
 
+	var->gl_sampler_id = sampler_id;
+
 	dstr_cat(&glsp->gl_string, call);
 	dstr_cat(&glsp->gl_string, "(");
 	dstr_cat(&glsp->gl_string, var->name);