for(VariableDeclaration *v: auto_constants)
{
- unsigned id = hash32(v->name)%features.constant_id_range;
- while(used_ids.count(id))
- id = (id+1)%features.constant_id_range;
+ unsigned id;
+ auto j = existing_constants.find(v->name);
+ if(j!=existing_constants.end())
+ id = j->second;
+ else
+ {
+ id = hash32(v->name)%features.constant_id_range;
+ while(used_ids.count(id))
+ id = (id+1)%features.constant_id_range;
+ }
auto i = find_member(v->layout->qualifiers, string("constant_id"), &Layout::Qualifier::name);
if(i!=v->layout->qualifiers.end())
if(i->value==-1)
auto_constants.push_back(&var);
else
+ {
+ existing_constants[var.name] = i->value;
used_ids.insert(i->value);
+ }
}
}
}
{
private:
std::set<unsigned> used_ids;
+ std::map<std::string, unsigned> existing_constants;
std::vector<VariableDeclaration *> auto_constants;
public: