]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix an error in calculating SPIR-V uniform offsets
authorMikko Rasa <tdb@tdb.fi>
Fri, 2 Apr 2021 09:48:46 +0000 (12:48 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 2 Apr 2021 11:02:10 +0000 (14:02 +0300)
source/core/program.cpp

index f28736bd9a63b7550ef712e0ab531d5a6b26b68d..6fdf747d99d477078ab2421cd325989a455aca82 100644 (file)
@@ -495,15 +495,16 @@ void Program::collect_block_uniforms(UniformBlockInfo &block, const SpirVModule:
 {
        for(vector<SpirVModule::StructMember>::const_iterator i=strct.members.begin(); i!=strct.members.end(); ++i)
        {
+               unsigned offset = base_offset+i->offset;
                if(i->struct_type)
                {
                        if(i->array_size)
                        {
-                               for(unsigned j=0; j<i->array_size; ++j)
-                                       collect_block_uniforms(block, *i->struct_type, format("%s%s[%d].", prefix, i->name, j), base_offset+i->offset+i->array_stride*j);
+                               for(unsigned j=0; j<i->array_size; ++j, offset+=i->array_stride)
+                                       collect_block_uniforms(block, *i->struct_type, format("%s%s[%d].", prefix, i->name, j), offset);
                        }
                        else
-                               collect_block_uniforms(block, *i->struct_type, prefix+i->name+".", base_offset+i->offset);
+                               collect_block_uniforms(block, *i->struct_type, prefix+i->name+".", offset);
                }
                else
                {
@@ -511,7 +512,7 @@ void Program::collect_block_uniforms(UniformBlockInfo &block, const SpirVModule:
                        UniformInfo &info = uniforms[name];
                        info.name = name;
                        info.block = &block;
-                       info.offset = i->offset;
+                       info.offset = offset;
                        info.array_size = i->array_size;
                        info.array_stride = i->array_stride;
                        info.matrix_stride = i->matrix_stride;