+ info.array_size = size;
+ info.type = from_gl_type(type);
+ }
+ }
+}
+
+void Program::collect_uniforms()
+{
+ const SpirVModule &mod = static_cast<const SpirVModule &>(*module);
+
+ UniformBlockInfo &default_block = uniform_blocks[string()];
+
+ const vector<SpirVModule::Variable> &variables = mod.get_variables();
+ for(vector<SpirVModule::Variable>::const_iterator i=variables.begin(); i!=variables.end(); ++i)
+ {
+ if(i->storage==SpirVModule::UNIFORM && i->struct_type)
+ {
+ UniformBlockInfo &info = uniform_blocks[i->struct_type->name];
+ info.name = i->struct_type->name;
+ info.bind_point = i->binding;
+ info.data_size = i->struct_type->size;
+
+ string prefix;
+ if(!i->name.empty())
+ prefix = i->struct_type->name+".";
+ collect_block_uniforms(info, *i->struct_type, prefix, 0);
+
+ info.layout_hash = compute_layout_hash(info.uniforms);
+ }
+ else if(i->storage==SpirVModule::UNIFORM_CONSTANT && i->location>=0)
+ {
+ UniformInfo &info = uniforms[i->name];
+ info.name = i->name;
+ info.block = &default_block;
+ info.location = i->location;
+ info.array_size = i->array_size;
+ info.type = i->type;
+ default_block.uniforms.push_back(&info);
+ }
+ }
+
+ default_block.layout_hash = compute_layout_hash(default_block.uniforms);
+
+ update_layout_hash();
+}
+
+void Program::collect_block_uniforms(UniformBlockInfo &block, const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset)
+{
+ for(vector<SpirVModule::StructMember>::const_iterator i=strct.members.begin(); i!=strct.members.end(); ++i)
+ {
+ if(i->struct_type)
+ {
+ if(i->array_size)
+ {
+ for(unsigned j=0; j<i->array_size; ++j)
+ collect_block_uniforms(block, *i->struct_type, format("%s%s[%d].", prefix, i->name, j), base_offset+i->offset+i->array_stride*j);
+ }
+ else
+ collect_block_uniforms(block, *i->struct_type, prefix+i->name+".", base_offset+i->offset);
+ }
+ else
+ {
+ string name = prefix+i->name;
+ UniformInfo &info = uniforms[name];
+ info.name = name;
+ info.block = █
+ info.offset = i->offset;
+ info.array_size = i->array_size;
+ info.array_stride = i->array_stride;
+ info.matrix_stride = i->matrix_stride;
+ info.type = i->type;
+ block.uniforms.push_back(&info);