diff options
Diffstat (limited to 'src/mesa/shader/slang/slang_vartable.c')
-rw-r--r-- | src/mesa/shader/slang/slang_vartable.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c index cd6a081e04b..d4ec848a0a1 100644 --- a/src/mesa/shader/slang/slang_vartable.c +++ b/src/mesa/shader/slang/slang_vartable.c @@ -3,6 +3,7 @@ #include "slang_compile.h" #include "slang_compile_variable.h" #include "slang_vartable.h" +#include "slang_ir.h" static int dbg = 0; @@ -58,16 +59,28 @@ _slang_pop_var_table(slang_var_table *t) { slang_var_table *parent = t->parent; int i; + if (dbg) printf("Popping level %d\n", t->level); + + /* free the storage allocated for each variable */ + for (i = 0; i < t->num_entries; i++) { + slang_ir_storage *store = (slang_ir_storage *) t->vars[i]->aux; + if (dbg) printf(" Free var %s\n", (char*) t->vars[i]->a_name); + assert(t->temps[store->Index] == VAR); + t->temps[store->Index] = FREE; + store->Index = -1; + } if (t->parent) { + /* just verify that any remaining allocations in this scope + * were for temps + */ for (i = 0; i < MAX_PROGRAM_TEMPS; i++) { - if (t->temps[i] && !t->parent->temps[i]) + if (t->temps[i] && !t->parent->temps[i]) { if (dbg) printf(" Free reg %d\n", i); + assert(t->temps[i] == TEMP); + } } } - for (i = 0; i < t->num_entries; i++) { - if (dbg) printf(" Free var %s\n", (char*) t->vars[i]->a_name); - } if (t->vars) free(t->vars); @@ -84,6 +97,7 @@ void _slang_add_variable(slang_var_table *t, slang_variable *v) { assert(t); + if (dbg) printf("Adding var %s\n", (char *) v->a_name); t->vars = realloc(t->vars, (t->num_entries + 1) * sizeof(slang_variable *)); t->vars[t->num_entries] = v; t->num_entries++; |