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>
This commit is contained in:
Juan A. Suarez Romero
2016-05-11 13:48:18 +02:00
committed by Antia Puentes
parent 2c1c060b03
commit 9bea018994
3 changed files with 20 additions and 22 deletions

View File

@@ -100,6 +100,11 @@ struct glsl_symbol_table {
*/
void disable_variable(const char *name);
/**
* Replaces the variable in the entry by the new variable.
*/
void replace_variable(const char *name, ir_variable *v);
private:
symbol_table_entry *get_entry(const char *name);