- /* Some implementations report the first element of a uniform array,
- others report just the name of the array itself. */
- if(len>3 && !strcmp(name+len-3, "[0]"))
- name[len-3] = 0;
-
- UniformInfo &info = uniforms[name];
- info.name = name;
- info.array_size = size;
- info.type = from_gl_type(type);
- uniforms_by_index[i] = &info;
- }
- }
-
- if(ARB_uniform_buffer_object)
- query_uniform_blocks(uniforms_by_index);
-
- UniformBlockInfo &default_block = uniform_blocks[string()];
-
- for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
- if(!i->second.block)
- {
- i->second.location = glGetUniformLocation(id, i->second.name.c_str());
- i->second.block = &default_block;
- default_block.uniforms.push_back(&i->second);
- }
-
- default_block.layout_hash = compute_layout_hash(default_block.uniforms);
-
- update_layout_hash();
-}
-
-void Program::query_uniform_blocks(const vector<UniformInfo *> &uniforms_by_index)
-{
- std::set<unsigned> used_bind_points;
- unsigned count = get_program_i(id, GL_ACTIVE_UNIFORM_BLOCKS);
- for(unsigned i=0; i<count; ++i)
- {
- char name[128];
- int len;
- glGetActiveUniformBlockName(id, i, sizeof(name), &len, name);
- UniformBlockInfo &info = uniform_blocks[name];
- info.name = name;
-
- int value;
- glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_DATA_SIZE, &value);
- info.data_size = value;
-
- glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &value);
- vector<int> indices(value);
- glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, &indices[0]);
- for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
- {
- if(!uniforms_by_index[*j])
- throw logic_error("Program::link");
- info.uniforms.push_back(uniforms_by_index[*j]);
- uniforms_by_index[*j]->block = &info;
- }
-
- vector<unsigned> query_indices(indices.begin(), indices.end());
- vector<int> values(indices.size());
- glGetActiveUniformsiv(id, query_indices.size(), &query_indices[0], GL_UNIFORM_OFFSET, &values[0]);
- for(unsigned j=0; j<indices.size(); ++j)
- uniforms_by_index[indices[j]]->offset = values[j];
-
- query_indices.clear();
- for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
- if(uniforms_by_index[*j]->array_size>1)
- query_indices.push_back(*j);
- if(!query_indices.empty())
- {
- glGetActiveUniformsiv(id, query_indices.size(), &query_indices[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]);
- for(unsigned j=0; j<query_indices.size(); ++j)
- uniforms_by_index[query_indices[j]]->array_stride = values[j];
- }
+ reflect_data.uniform_blocks.emplace_back();
+ ReflectData::UniformBlockInfo &info = reflect_data.uniform_blocks.back();
+ info.name = v.struct_type->name;
+ info.data_size = v.struct_type->size;
+ if(v.storage==SpirVModule::PUSH_CONSTANT)
+ {
+ info.bind_point = ReflectData::PUSH_CONSTANT;
+ reflect_data.push_constants_size = info.data_size;
+ }
+ else
+ {
+ if(v.binding>=0)
+ info.bind_point = v.binding | (v.descriptor_set<<20);
+ else
+ info.bind_point = ReflectData::DEFAULT_BLOCK;
+ reflect_data.n_descriptor_sets = max(reflect_data.n_descriptor_sets, v.descriptor_set+1);
+ }