X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=acdb20e88a5488063c3778a598af10f411b1b541;hb=0e61ac01ae99391c6b1301a9bf8de62fe651dac3;hp=57ef987950d9dbbaed82d3a75669b53a6b7fbc20;hpb=959efbf61663efd7879070ce0447e02c8a447ce0;p=libs%2Fgl.git diff --git a/source/core/program.cpp b/source/core/program.cpp index 57ef9879..acdb20e8 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -38,6 +38,7 @@ void Program::add_stages(const Module &mod, const map &spec_values) { collect_uniforms(static_cast(mod)); collect_attributes(static_cast(mod)); + collect_builtins(static_cast(mod)); } finalize_uniforms(); @@ -54,14 +55,24 @@ void Program::collect_uniforms(const SpirVModule &mod) reflect_data.uniform_blocks.push_back(ReflectData::UniformBlockInfo()); vector > block_uniform_names(1); + unsigned n_descriptor_sets = 0; for(const SpirVModule::Variable &v: mod.get_variables()) { - if(v.storage==SpirVModule::UNIFORM && v.struct_type) + if((v.storage==SpirVModule::UNIFORM || v.storage==SpirVModule::PUSH_CONSTANT) && v.struct_type) { reflect_data.uniform_blocks.push_back(ReflectData::UniformBlockInfo()); ReflectData::UniformBlockInfo &info = reflect_data.uniform_blocks.back(); info.name = v.struct_type->name; - info.bind_point = v.binding; + if(v.storage==SpirVModule::PUSH_CONSTANT) + info.bind_point = ReflectData::PUSH_CONSTANT; + 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); + } info.data_size = v.struct_type->size; string prefix; @@ -78,7 +89,9 @@ void Program::collect_uniforms(const SpirVModule &mod) info.name = v.name; info.tag = v.name; info.location = v.location; - info.binding = v.binding; + if(v.binding>=0) + info.binding = v.binding | (v.descriptor_set<<20); + n_descriptor_sets = max(n_descriptor_sets, v.descriptor_set+1); info.array_size = max(v.array_size, 1U); info.type = v.type; } @@ -86,6 +99,12 @@ void Program::collect_uniforms(const SpirVModule &mod) sort_member(reflect_data.uniforms, &ReflectData::UniformInfo::tag); + if(block_uniform_names.front().empty()) + { + reflect_data.uniform_blocks.erase(reflect_data.uniform_blocks.begin()); + block_uniform_names.erase(block_uniform_names.begin()); + } + for(unsigned i=0; i