From: Mikko Rasa Date: Sun, 7 Nov 2021 17:14:36 +0000 (+0200) Subject: Remove support for array size specialization from the engine as well X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=959efbf61663efd7879070ce0447e02c8a447ce0;p=libs%2Fgl.git Remove support for array size specialization from the engine as well --- diff --git a/source/backends/opengl/program_backend.cpp b/source/backends/opengl/program_backend.cpp index a3603adc..1fc8c442 100644 --- a/source/backends/opengl/program_backend.cpp +++ b/source/backends/opengl/program_backend.cpp @@ -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 &spec_values, TransientData &transient) +void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const map &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 mapsecond); - transient.spec_values[c.constant_id] = i->second; } } diff --git a/source/backends/opengl/program_backend.h b/source/backends/opengl/program_backend.h index dbf043e9..b08b70fa 100644 --- a/source/backends/opengl/program_backend.h +++ b/source/backends/opengl/program_backend.h @@ -26,7 +26,6 @@ protected: { std::map textures; std::map blocks; - std::map spec_values; }; struct UniformCall @@ -53,7 +52,7 @@ protected: unsigned add_stage(Stage); void add_glsl_stages(const GlslModule &, const std::map &, TransientData &); void compile_glsl_stage(const GlslModule &, unsigned); - void add_spirv_stages(const SpirVModule &, const std::map &, TransientData &); + void add_spirv_stages(const SpirVModule &, const std::map &); void finalize(const Module &, TransientData &); void query_uniforms(); diff --git a/source/core/module.cpp b/source/core/module.cpp index 4afbc534..b542f77e 100644 --- a/source/core/module.cpp +++ b/source/core/module.cpp @@ -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) diff --git a/source/core/module.h b/source/core/module.h index 1ccbbf3d..a480b613 100644 --- a/source/core/module.h +++ b/source/core/module.h @@ -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(-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(-1); diff --git a/source/core/program.cpp b/source/core/program.cpp index 476a9c7d..57ef9879 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,7 +36,7 @@ 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)); } @@ -48,7 +48,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 +68,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) { @@ -103,29 +103,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 & = std::map()); private: - void collect_uniforms(const SpirVModule &, const std::map &); - void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, const std::map &, std::vector &); + void collect_uniforms(const SpirVModule &); + void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, std::vector &); void collect_attributes(const SpirVModule &); void collect_builtins(const SpirVModule &); void collect_builtins(const SpirVModule::Structure &);