Browse Source

fix effect parser to properly parse and output uniform variables

jp9000 12 years ago
parent
commit
20490010e9
2 changed files with 8 additions and 4 deletions
  1. 5 2
      libobs/graphics/effect-parser.c
  2. 3 2
      libobs/graphics/effect-parser.h

+ 5 - 2
libobs/graphics/effect-parser.c

@@ -819,7 +819,7 @@ static void ep_parse_param(struct effect_parser *ep,
 		bool is_property, bool is_const, bool is_uniform)
 {
 	struct ep_param param;
-	ep_param_init(&param, type, name, is_property, is_const);
+	ep_param_init(&param, type, name, is_property, is_const, is_uniform);
 
 	if (token_is(&ep->cfp, ";"))
 		goto complete;
@@ -967,10 +967,12 @@ static inline void ep_write_param(struct dstr *shader, struct ep_param *param,
 
 	if (param->is_const) {
 		dstr_cat(shader, "const ");
-	} else {
+	} else if (param->is_uniform) {
 		struct dstr new;
 		dstr_init_copy(&new, param->name);
 		darray_push_back(sizeof(struct dstr), used_params, &new);
+
+		dstr_cat(shader, "uniform ");
 	}
 
 	dstr_cat(shader, param->type);
@@ -1310,6 +1312,7 @@ static inline void ep_compile_pass_shaderparams(struct effect_parser *ep,
 	for (i = 0; i < pass_params->num; i++) {
 		struct dstr *param_name;
 		struct pass_shaderparam *param;
+		int test;
 
 		param_name = darray_item(sizeof(struct dstr), used_params, i);
 		param = darray_item(sizeof(struct pass_shaderparam),

+ 3 - 2
libobs/graphics/effect-parser.h

@@ -63,7 +63,7 @@ struct ep_param {
 	DARRAY(uint8_t)  default_val;
 	DARRAY(char*)    properties;
 	struct effect_param *param;
-	bool is_const, is_property, is_texture, written;
+	bool is_const, is_property, is_uniform, is_texture, written;
 	int writeorder, array_count;
 };
 
@@ -71,12 +71,13 @@ extern void ep_param_writevar(struct dstr *dst, struct darray *use_params);
 
 static inline void ep_param_init(struct ep_param *epp,
 		char *type, char *name,
-		bool is_property, bool is_const)
+		bool is_property, bool is_const, bool is_uniform)
 {
 	epp->type        = type;
 	epp->name        = name;
 	epp->is_property = is_property;
 	epp->is_const    = is_const;
+	epp->is_uniform  = is_uniform;
 	epp->is_texture  = (astrcmp_n(epp->type, "texture", 7) == 0);
 	epp->written     = false;
 	epp->writeorder  = false;