summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_preprocess.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/slang/slang_preprocess.c')
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index 0e95cdb525..15cd1ece7d 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -1012,8 +1012,6 @@ preprocess_source (slang_string *output, const char *source,
case TOKEN_DEFINE:
{
pp_symbol *symbol = NULL;
- slang_string replacement;
- expand_state es;
/* Parse macro name. */
id = (const char *) (&prod[i]);
@@ -1055,21 +1053,25 @@ preprocess_source (slang_string *output, const char *source,
id = (const char *) (&prod[i]);
idlen = _mesa_strlen (id);
if (state.cond.top->effective) {
+ slang_string replacement;
+ expand_state es;
+
pp_annotate (output, ") %s", id);
- }
- slang_string_init(&replacement);
- slang_string_pushs(&replacement, id, idlen);
- i += idlen + 1;
- /* Expand macro replacement. */
- es.output = &symbol->replacement;
- es.input = slang_string_cstr(&replacement);
- es.state = &state;
- if (!expand(&es, &state.symbols)) {
+ slang_string_init(&replacement);
+ slang_string_pushs(&replacement, id, idlen);
+
+ /* Expand macro replacement. */
+ es.output = &symbol->replacement;
+ es.input = slang_string_cstr(&replacement);
+ es.state = &state;
+ if (!expand(&es, &state.symbols)) {
+ slang_string_free(&replacement);
+ goto error;
+ }
slang_string_free(&replacement);
- goto error;
}
- slang_string_free(&replacement);
+ i += idlen + 1;
}
break;
@@ -1332,6 +1334,11 @@ _slang_preprocess_directives(slang_string *output,
success = preprocess_source (output, input, pid, eid, elog, extensions, pragmas);
grammar_destroy (eid);
grammar_destroy (pid);
+ if (0) {
+ _mesa_printf("Post-processed shader:\n");
+ _mesa_printf("%s", output->data);
+ _mesa_printf("----------------------\n");
+ }
return success;
}