if (!error_emitted) {
var->constant_initializer = rhs->constant_expression_value(mem_ctx);
var->data.has_initializer = true;
+ var->data.is_implicit_initializer = false;
/* If the declared variable is an unsized array, it must inherrit
* its full type from the initializer. A declaration such as
(var->type->is_numeric() || var->type->is_boolean())) {
const ir_constant_data data = { { 0 } };
var->data.has_initializer = true;
+ var->data.is_implicit_initializer = true;
var->constant_initializer = new(var) ir_constant(var->type, &data);
}
(var->type->is_numeric() || var->type->is_boolean())) {
const ir_constant_data data = { { 0 } };
var->data.has_initializer = true;
+ var->data.is_implicit_initializer = true;
var->constant_initializer = new(var) ir_constant(var->type, &data);
}
var->constant_initializer =
new(var) ir_constant(glsl_type::uvec3_type, &data);
var->data.has_initializer = true;
+ var->data.is_implicit_initializer = false;
return NULL;
}
if (!var->constant_initializer && state->zero_init) {
const ir_constant_data data = { { 0 } };
var->data.has_initializer = true;
+ var->data.is_implicit_initializer = true;
var->constant_initializer = new(var) ir_constant(var->type, &data);
}
}
this->data.explicit_binding = false;
this->data.explicit_component = false;
this->data.has_initializer = false;
+ this->data.is_implicit_initializer = false;
this->data.is_unmatched_generic_inout = false;
this->data.is_xfb_only = false;
this->data.explicit_xfb_buffer = false;
unsigned has_initializer:1;
/**
+ * Is the initializer created by the compiler (glsl_zero_init)
+ */
+ unsigned is_implicit_initializer:1;
+
+ /**
* Is this variable a generic output or input that has not yet been matched
* up to a variable in another stage of the pipeline?
*
* no vendor actually implemented that behavior. The 4.20
* behavior matches the implemented behavior of at least one other
* vendor, so we'll implement that for all GLSL versions.
+ * If (at least) one of these constant expressions is implicit,
+ * because it was added by glsl_zero_init, we skip the verification.
*/
if (var->constant_initializer != NULL) {
- if (existing->constant_initializer != NULL) {
+ if (existing->constant_initializer != NULL &&
+ !existing->data.is_implicit_initializer &&
+ !var->data.is_implicit_initializer) {
if (!var->constant_initializer->has_value(existing->constant_initializer)) {
linker_error(prog, "initializers for %s "
"`%s' have differing values\n",
* not have an initializer but a later instance does,
* replace the former with the later.
*/
- variables->replace_variable(existing->name, var);
+ if (!var->data.is_implicit_initializer)
+ variables->replace_variable(existing->name, var);
}
}