]> git.tdb.fi Git - libs/gl.git/commitdiff
Determine the default uniform block size regardless of module format
authorMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 08:48:24 +0000 (11:48 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 10:54:56 +0000 (13:54 +0300)
source/backends/opengl/program_backend.cpp
source/core/program.cpp

index 4dbf38a7197e5bd40e58f1f5c4151bbfafe2a594..86235ebe45c6d769b4367c0328f56dd26b43a418 100644 (file)
@@ -334,11 +334,6 @@ void OpenGLProgram::query_uniforms()
                }
 
        default_block.sort_uniforms();
-       if(!default_block.uniforms.empty())
-       {
-               const ReflectData::UniformInfo &uni = *default_block.uniforms.back();
-               default_block.data_size = uni.location*16+uni.array_size*get_type_size(uni.type);
-       }
        default_block.update_layout_hash();
        rd.update_layout_hash();
 }
index 6458b4779d396ae3fe5072f4ec9381c1ba4b05e3..5c8257b2fc60de50bf0e767beb90a5f8da5784e2 100644 (file)
@@ -46,6 +46,13 @@ void Program::add_stages(const Module &mod, const map<string, int> &spec_values)
                collect_attributes(static_cast<const SpirVModule &>(mod));
        }
 
+       for(ReflectData::UniformBlockInfo &b: reflect_data.uniform_blocks)
+               if(!b.data_size && !b.uniforms.empty())
+               {
+                       const ReflectData::UniformInfo &uni = *b.uniforms.back();
+                       b.data_size = uni.location*16+uni.array_size*get_type_size(uni.type);
+               }
+
        for(const ReflectData::UniformInfo &u: reflect_data.uniforms)
                require_type(u.type);
        for(const ReflectData::AttributeInfo &a: reflect_data.attributes)