From 20490010e91cbb883746170167951fa9ef1327a0 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 9 Oct 2013 21:38:55 -0700 Subject: [PATCH] fix effect parser to properly parse and output uniform variables --- libobs/graphics/effect-parser.c | 7 +++++-- libobs/graphics/effect-parser.h | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libobs/graphics/effect-parser.c b/libobs/graphics/effect-parser.c index 56c462a51..6f4d71578 100644 --- a/libobs/graphics/effect-parser.c +++ b/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(¶m, type, name, is_property, is_const); + ep_param_init(¶m, 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), diff --git a/libobs/graphics/effect-parser.h b/libobs/graphics/effect-parser.h index f2f177d5c..297f8ee1c 100644 --- a/libobs/graphics/effect-parser.h +++ b/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; -- GitLab