From: Mikko Rasa Date: Fri, 2 Apr 2021 09:48:46 +0000 (+0300) Subject: Fix an error in calculating SPIR-V uniform offsets X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=63383e58b25321188cbc65bf9a6bc7e2a0faaabb;p=libs%2Fgl.git Fix an error in calculating SPIR-V uniform offsets --- diff --git a/source/core/program.cpp b/source/core/program.cpp index f28736bd..6fdf747d 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -495,15 +495,16 @@ void Program::collect_block_uniforms(UniformBlockInfo &block, const SpirVModule: { for(vector::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; jarray_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; jarray_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 = █ - 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;