]> git.tdb.fi Git - libs/gl.git/commitdiff
Padding is required at the end of certain SPIR-V struct members
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 13:59:13 +0000 (15:59 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 14:00:32 +0000 (16:00 +0200)
If the member is is itself a struct or an array, the next member must not
begin before the next alignment boundary.

source/glsl/reflect.cpp

index 8ee8a88dfe96750dd3234d88a751cc131e27ad10..6027acde36862363a6597bebe60db488fa666351 100644 (file)
@@ -304,6 +304,8 @@ void MemoryRequirementsCalculator::visit(StructDeclaration &strct)
        }
        r_size = total;
        r_alignment = max_align;
+       r_size += r_alignment-1;
+       r_size -= r_size%r_alignment;
 }
 
 void MemoryRequirementsCalculator::visit(VariableDeclaration &var)
@@ -323,7 +325,7 @@ void MemoryRequirementsCalculator::visit(VariableDeclaration &var)
                        {
                                unsigned aligned_size = r_size+r_alignment-1;
                                aligned_size -= aligned_size%r_alignment;
-                               r_size += aligned_size*(literal->value.value<int>()-1);
+                               r_size = aligned_size*literal->value.value<int>();
                        }
 }