X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=91f215651b57df64b834315c13aa89b86d57d546;hb=cebf1330ef6773b7b4496dc279ec02a7ca4351bb;hp=e146c7acd7eed8db385f2176492ed1a504fdb4e0;hpb=7696b0c0c5620398aa3a031521a1510026452f4d;p=libs%2Fgl.git diff --git a/source/core/program.cpp b/source/core/program.cpp index e146c7ac..91f21565 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -33,14 +33,13 @@ void Program::add_stages(const Module &mod, const map &spec_values) reflect_data = ReflectData(); const Module *final_module = &mod; - TransientData transient; switch(mod.get_format()) { case Module::GLSL: - add_glsl_stages(static_cast(mod), spec_values, transient); + add_glsl_stages(static_cast(mod), spec_values); break; case Module::SPIR_V: - if(!spec_values.empty()) + if(static_cast(mod).is_specializable()) { specialized_spirv = static_cast(mod).specialize(spec_values); final_module = specialized_spirv; @@ -51,14 +50,16 @@ void Program::add_stages(const Module &mod, const map &spec_values) throw invalid_argument("Program::add_stages"); } - finalize(*final_module, transient); - if(final_module->get_format()==Module::SPIR_V) { const SpirVModule &spirv_mod = *static_cast(final_module); collect_uniforms(spirv_mod); collect_attributes(spirv_mod); collect_builtins(spirv_mod); + + for(const SpirVModule::EntryPoint &e: spirv_mod.get_entry_points()) + if(e.stage==SpirVModule::COMPUTE) + reflect_data.compute_wg_size = e.compute_local_size; } finalize_uniforms(); @@ -77,7 +78,6 @@ void Program::collect_uniforms(const SpirVModule &mod) reflect_data.uniform_blocks.emplace_back(); vector > block_uniform_names(1); - unsigned n_descriptor_sets = 0; for(const SpirVModule::Variable &v: mod.get_variables()) { if((v.storage==SpirVModule::UNIFORM || v.storage==SpirVModule::PUSH_CONSTANT) && v.struct_type) @@ -85,17 +85,20 @@ void Program::collect_uniforms(const SpirVModule &mod) 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; - n_descriptor_sets = max(n_descriptor_sets, v.descriptor_set+1); + reflect_data.n_descriptor_sets = max(reflect_data.n_descriptor_sets, v.descriptor_set+1); } - info.data_size = v.struct_type->size; string prefix; if(!v.name.empty()) @@ -113,7 +116,7 @@ void Program::collect_uniforms(const SpirVModule &mod) info.location = v.location; if(v.binding>=0) info.binding = v.binding | (v.descriptor_set<<20); - n_descriptor_sets = max(n_descriptor_sets, v.descriptor_set+1); + reflect_data.n_descriptor_sets = max(reflect_data.n_descriptor_sets, v.descriptor_set+1); info.array_size = max(v.array_size, 1U); info.type = v.type; } @@ -141,7 +144,6 @@ void Program::collect_uniforms(const SpirVModule &mod) block.update_layout_hash(); } - reflect_data.n_descriptor_sets = n_descriptor_sets; reflect_data.update_layout_hash(); } @@ -193,6 +195,8 @@ void Program::collect_attributes(const SpirVModule &mod) info.type = v->type; } } + + sort_member(reflect_data.attributes, &ReflectData::AttributeInfo::name); } void Program::collect_builtins(const SpirVModule &mod)