X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=64e1ae30f4a9a38f0b749cb82109a3f5c8576a50;hb=f73e671dcb36c097647cddbf5b1eaaad2ffc9299;hp=2934d240c7ef0c3bda346636d51725c8729b7bd1;hpb=013c562e389936acf61970118eab23a420a8f611;p=libs%2Fgl.git diff --git a/source/core/program.cpp b/source/core/program.cpp index 2934d240..64e1ae30 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -26,7 +26,7 @@ void Program::add_stages(const Module &mod, const map &spec_values) add_glsl_stages(static_cast(mod), spec_values, transient); break; case Module::SPIR_V: - add_spirv_stages(static_cast(mod), spec_values, transient); + add_spirv_stages(static_cast(mod), spec_values); break; default: throw invalid_argument("Program::add_stages"); @@ -36,8 +36,9 @@ void Program::add_stages(const Module &mod, const map &spec_values) if(mod.get_format()==Module::SPIR_V) { - collect_uniforms(static_cast(mod), transient.spec_values); + collect_uniforms(static_cast(mod)); collect_attributes(static_cast(mod)); + collect_builtins(static_cast(mod)); } finalize_uniforms(); @@ -48,7 +49,7 @@ void Program::add_stages(const Module &mod, const map &spec_values) require_type(a.type); } -void Program::collect_uniforms(const SpirVModule &mod, const map &spec_values) +void Program::collect_uniforms(const SpirVModule &mod) { // Prepare the default block reflect_data.uniform_blocks.push_back(ReflectData::UniformBlockInfo()); @@ -68,7 +69,7 @@ void Program::collect_uniforms(const SpirVModule &mod, const map if(!v.name.empty()) prefix = v.struct_type->name+"."; block_uniform_names.push_back(vector()); - collect_block_uniforms(*v.struct_type, prefix, 0, spec_values, block_uniform_names.back()); + collect_block_uniforms(*v.struct_type, prefix, 0, block_uniform_names.back()); } else if(v.storage==SpirVModule::UNIFORM_CONSTANT && v.location>=0) { @@ -79,7 +80,7 @@ void Program::collect_uniforms(const SpirVModule &mod, const map info.tag = v.name; info.location = v.location; info.binding = v.binding; - info.array_size = v.array_size; + info.array_size = max(v.array_size, 1U); info.type = v.type; } } @@ -103,29 +104,20 @@ void Program::collect_uniforms(const SpirVModule &mod, const map reflect_data.update_layout_hash(); } -void Program::collect_block_uniforms(const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset, const map &spec_values, vector &uniform_names) +void Program::collect_block_uniforms(const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset, vector &uniform_names) { for(const SpirVModule::StructMember &m: strct.members) { unsigned offset = base_offset+m.offset; if(m.struct_type) { - unsigned array_size = m.array_size; - if(m.array_size_spec) + if(m.array_size) { - array_size = m.array_size_spec->i_value; - auto j = spec_values.find(m.array_size_spec->constant_id); - if(j!=spec_values.end()) - array_size = j->second; - } - - if(array_size) - { - for(unsigned j=0; j