]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove support for array size specialization from the engine as well
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 17:14:36 +0000 (19:14 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 17:14:36 +0000 (19:14 +0200)
source/backends/opengl/program_backend.cpp
source/backends/opengl/program_backend.h
source/core/module.cpp
source/core/module.h
source/core/program.cpp
source/core/program.h

index a3603adc78ef6ed5f89cbfde56543004f417a00b..1fc8c4420556257c19a5611ce66b9d212b86da86 100644 (file)
@@ -162,7 +162,7 @@ void OpenGLProgram::compile_glsl_stage(const GlslModule &mod, unsigned stage_id)
 #endif
 }
 
-void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const map<string, int> &spec_values, TransientData &transient)
+void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const map<string, int> &spec_values)
 {
        static Require _req(ARB_gl_spirv);
        static Require _req2(ARB_ES2_compatibility);
@@ -201,7 +201,6 @@ void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const map<string, i
                {
                        spec_id_array.push_back(c.constant_id);
                        spec_value_array.push_back(i->second);
-                       transient.spec_values[c.constant_id] = i->second;
                }
        }
 
index dbf043e9c89ba39a808432f80a001c2e933d68cb..b08b70fae968e5992e1e7e026aaa5f7004c78430 100644 (file)
@@ -26,7 +26,6 @@ protected:
        {
                std::map<std::string, unsigned> textures;
                std::map<std::string, unsigned> blocks;
-               std::map<unsigned, int> spec_values;
        };
 
        struct UniformCall
@@ -53,7 +52,7 @@ protected:
        unsigned add_stage(Stage);
        void add_glsl_stages(const GlslModule &, const std::map<std::string, int> &, TransientData &);
        void compile_glsl_stage(const GlslModule &, unsigned);
-       void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &, TransientData &);
+       void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &);
 
        void finalize(const Module &, TransientData &);
        void query_uniforms();
index 4afbc53403d4f283cd57277a5436a64775b1bc3e..b542f77e9c6ebcee0638b69fd76c94aff9ad3998 100644 (file)
@@ -174,18 +174,11 @@ void SpirVModule::reflect()
        for(Structure &s: structs)
        {
                for(StructMember &m: s.members)
-               {
                        if(m.struct_type)
                        {
                                auto i = struct_indices.find(m.struct_type);
                                m.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0);
                        }
-                       if(m.array_size_spec)
-                       {
-                               auto i = spec_indices.find(m.array_size_spec);
-                               m.array_size_spec = (i!=spec_indices.end() ? &spec_constants[i->second] : 0);
-                       }
-               }
 
                const StructMember *last_member = &s.members.back();
                unsigned last_offset = last_member->offset;
@@ -194,8 +187,6 @@ void SpirVModule::reflect()
                        const StructMember *lm = &last_member->struct_type->members.back();
                        if(last_member->array_size)
                                last_offset += last_member->array_stride*(last_member->array_size-1);
-                       else if(last_member->array_size_spec)
-                               last_offset += last_member->array_stride*(last_member->array_size_spec->i_value-1);
                        last_offset += lm->offset;
                        last_member = lm;
                }
@@ -219,18 +210,11 @@ void SpirVModule::reflect()
        }
 
        for(Variable &v: variables)
-       {
                if(v.struct_type)
                {
                        auto i = struct_indices.find(v.struct_type);
                        v.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0);
                }
-               if(v.array_size_spec)
-               {
-                       auto i = spec_indices.find(v.array_size_spec);
-                       v.array_size_spec = (i!=spec_indices.end() ? &spec_constants[i->second] : 0);
-               }
-       }
 
        entry_points.reserve(reflection.entry_points.size());
        for(const auto &kvp: reflection.entry_points)
@@ -427,9 +411,7 @@ void SpirVModule::Reflection::reflect_array_type(CodeIterator op)
        type.struct_type = elem.struct_type;
 
        const Constant &size = constants[*(op+3)];
-       if(size.constant_id>=0)
-               type.array_size_spec = &size;
-       else if(size.type==INT || size.type==UNSIGNED_INT)
+       if(size.type==INT || size.type==UNSIGNED_INT)
                type.array_size = size.i_value;
 }
 
@@ -450,7 +432,6 @@ void SpirVModule::Reflection::reflect_struct_type(CodeIterator op)
                mem->type = type.type;
                mem->struct_type = type.struct_type;
                mem->array_size = type.array_size;
-               mem->array_size_spec = type.array_size_spec;
                mem->array_stride = type.array_stride;
        }
 }
@@ -488,7 +469,6 @@ void SpirVModule::Reflection::reflect_variable(CodeIterator op)
        var.type = type.type;
        var.struct_type = type.struct_type;
        var.array_size = type.array_size;
-       var.array_size_spec = type.array_size_spec;
 }
 
 void SpirVModule::Reflection::reflect_decorate(CodeIterator op)
index 1ccbbf3d5c0d03fb3ca144d9f9def0231112fbf0..a480b6139426efaeeb7287566d8bbdc1f2891690 100644 (file)
@@ -134,7 +134,6 @@ public:
                const Structure *struct_type = 0;
                unsigned offset = 0;
                unsigned array_size = 0;
-               const Constant *array_size_spec = 0;
                unsigned array_stride = 0;
                unsigned matrix_stride = 0;
                BuiltinSemantic builtin = NOT_BUILTIN;
@@ -153,7 +152,6 @@ public:
                StorageClass storage = static_cast<StorageClass>(-1);
                DataType type = VOID;
                const Structure *struct_type = 0;
-               const Constant *array_size_spec = 0;
                unsigned array_size = 0;
                int location = -1;
                int descriptor_set = -1;
@@ -180,7 +178,6 @@ private:
        {
                DataType type = VOID;
                const Structure *struct_type = 0;
-               const Constant *array_size_spec = 0;
                unsigned array_size = 0;
                unsigned array_stride = 0;
                StorageClass storage = static_cast<StorageClass>(-1);
index 476a9c7d6aba319c9e42cb3fd345a0a889d014aa..57ef987950d9dbbaed82d3a75669b53a6b7fbc20 100644 (file)
@@ -26,7 +26,7 @@ void Program::add_stages(const Module &mod, const map<string, int> &spec_values)
                add_glsl_stages(static_cast<const GlslModule &>(mod), spec_values, transient);
                break;
        case Module::SPIR_V:
-               add_spirv_stages(static_cast<const SpirVModule &>(mod), spec_values, transient);
+               add_spirv_stages(static_cast<const SpirVModule &>(mod), spec_values);
                break;
        default:
                throw invalid_argument("Program::add_stages");
@@ -36,7 +36,7 @@ void Program::add_stages(const Module &mod, const map<string, int> &spec_values)
 
        if(mod.get_format()==Module::SPIR_V)
        {
-               collect_uniforms(static_cast<const SpirVModule &>(mod), transient.spec_values);
+               collect_uniforms(static_cast<const SpirVModule &>(mod));
                collect_attributes(static_cast<const SpirVModule &>(mod));
        }
 
@@ -48,7 +48,7 @@ void Program::add_stages(const Module &mod, const map<string, int> &spec_values)
                require_type(a.type);
 }
 
-void Program::collect_uniforms(const SpirVModule &mod, const map<unsigned, int> &spec_values)
+void Program::collect_uniforms(const SpirVModule &mod)
 {
        // Prepare the default block
        reflect_data.uniform_blocks.push_back(ReflectData::UniformBlockInfo());
@@ -68,7 +68,7 @@ void Program::collect_uniforms(const SpirVModule &mod, const map<unsigned, int>
                        if(!v.name.empty())
                                prefix = v.struct_type->name+".";
                        block_uniform_names.push_back(vector<string>());
-                       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)
                {
@@ -103,29 +103,20 @@ void Program::collect_uniforms(const SpirVModule &mod, const map<unsigned, int>
        reflect_data.update_layout_hash();
 }
 
-void Program::collect_block_uniforms(const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset, const map<unsigned, int> &spec_values, vector<string> &uniform_names)
+void Program::collect_block_uniforms(const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset, vector<string> &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<array_size; ++j, offset+=m.array_stride)
-                                       collect_block_uniforms(*m.struct_type, format("%s%s[%d].", prefix, m.name, j), offset, spec_values, uniform_names);
+                               for(unsigned j=0; j<m.array_size; ++j, offset+=m.array_stride)
+                                       collect_block_uniforms(*m.struct_type, format("%s%s[%d].", prefix, m.name, j), offset, uniform_names);
                        }
                        else
-                               collect_block_uniforms(*m.struct_type, prefix+m.name+".", offset, spec_values, uniform_names);
+                               collect_block_uniforms(*m.struct_type, prefix+m.name+".", offset, uniform_names);
                }
                else
                {
index dab249f47684546f42cc64b2c0436f538c434126..dd7d4b5f029789a074815ff94d9112e27c6818a6 100644 (file)
@@ -61,8 +61,8 @@ public:
 
        void add_stages(const Module &, const std::map<std::string, int> & = std::map<std::string, int>());
 private:
-       void collect_uniforms(const SpirVModule &, const std::map<unsigned, int> &);
-       void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, const std::map<unsigned, int> &, std::vector<std::string> &);
+       void collect_uniforms(const SpirVModule &);
+       void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, std::vector<std::string> &);
        void collect_attributes(const SpirVModule &);
        void collect_builtins(const SpirVModule &);
        void collect_builtins(const SpirVModule::Structure &);