summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_symbol_table.cpp
diff options
context:
space:
mode:
authorJuan A. Suarez Romero <jasuarez@igalia.com>2016-05-11 13:48:18 +0200
committerAntia Puentes <apuentes@igalia.com>2016-05-11 13:50:04 +0200
commit9bea01899433ca6a8047b4172ffec6e89afe7625 (patch)
tree11289e1e3f2d32ee1aea7d4b5d702eb66d7e6eac /src/compiler/glsl/glsl_symbol_table.cpp
parent2c1c060b031a7c179653ee83f28f7325c47ebd04 (diff)
downloadexternal_mesa3d-9bea01899433ca6a8047b4172ffec6e89afe7625.zip
external_mesa3d-9bea01899433ca6a8047b4172ffec6e89afe7625.tar.gz
external_mesa3d-9bea01899433ca6a8047b4172ffec6e89afe7625.tar.bz2
glsl: use var with initializer on global var validation
Currently, when cross validating global variables, all global variables seen in the shaders that are part of a program are saved in a table. When checking a variable this already exist in the table, we check both are initialized to the same value. If the already saved variable does not have an initializer, we copy it from the new variable. Unfortunately this is wrong, as we are modifying something it is constant. Also, if this modified variable is used in another program, it will keep the initializer, when it should have none. Instead of copying the initializer, this commit replaces the old variable with the new one. So if we see again the same variable with an initializer, we can compare if both are the same or not. v2: convert tabs in whitespaces (Kenenth Graunke) Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/compiler/glsl/glsl_symbol_table.cpp')
-rw-r--r--src/compiler/glsl/glsl_symbol_table.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_symbol_table.cpp b/src/compiler/glsl/glsl_symbol_table.cpp
index 6c682ac..6d7baad 100644
--- a/src/compiler/glsl/glsl_symbol_table.cpp
+++ b/src/compiler/glsl/glsl_symbol_table.cpp
@@ -278,3 +278,13 @@ glsl_symbol_table::disable_variable(const char *name)
entry->v = NULL;
}
}
+
+void
+glsl_symbol_table::replace_variable(const char *name,
+ ir_variable *v)
+{
+ symbol_table_entry *entry = get_entry(name);
+ if (entry != NULL) {
+ entry->v = v;
+ }
+}