]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix size calculation for GLSL arrays
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 12:31:38 +0000 (14:31 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 14:00:32 +0000 (16:00 +0200)
source/glsl/reflect.cpp

index cc2e3a0c8bc2c6570e30bb50decd35cd413b97f1..8ee8a88dfe96750dd3234d88a751cc131e27ad10 100644 (file)
@@ -320,7 +320,11 @@ void MemoryRequirementsCalculator::visit(VariableDeclaration &var)
        if(var.array)
                if(const Literal *literal = dynamic_cast<const Literal *>(var.array_size.get()))
                        if(literal->value.check_type<int>())
-                               r_size += r_alignment*(literal->value.value<int>()-1);
+                       {
+                               unsigned aligned_size = r_size+r_alignment-1;
+                               aligned_size -= aligned_size%r_alignment;
+                               r_size += aligned_size*(literal->value.value<int>()-1);
+                       }
 }