throw internal_error("const variable without initializer");
int spec_id = get_layout_value(var.layout.get(), "constant_id");
+ Id *spec_var_id = (spec_id>=0 ? &declared_spec_ids[spec_id] : 0);
+ if(spec_id>=0 && *spec_var_id)
+ {
+ insert_unique(declared_ids, &var, Declaration(*spec_var_id, type_id));
+ return;
+ }
SetFlag set_const(constant_expression);
SetFlag set_spec(spec_constant, spec_id>=0);
var.init_expression->visit(*this);
var_id = r_expression_result_id;
insert_unique(declared_ids, &var, Declaration(var_id, type_id));
- writer.write_op_decorate(var_id, DECO_SPEC_ID, spec_id);
+ if(spec_id>=0)
+ {
+ writer.write_op_decorate(var_id, DECO_SPEC_ID, spec_id);
+ *spec_var_id = var_id;
+ }
/* It's unclear what should be done if a specialization constant is
initialized with anything other than a literal. GLSL doesn't seem to
std::map<std::string, Id> imported_extension_ids;
std::map<Node *, Declaration> declared_ids;
std::map<std::string, Id> declared_uniform_ids;
+ std::map<unsigned, Id> declared_spec_ids;
std::map<TypeKey, Id> standard_type_ids;
std::map<Id, Id> image_type_ids;
std::map<TypeKey, Id> array_type_ids;