From c1bf0909af97772da5b26d82272f337a14c1fae9 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 7 Nov 2021 15:59:13 +0200 Subject: [PATCH] Padding is required at the end of certain SPIR-V struct members 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/glsl/reflect.cpp b/source/glsl/reflect.cpp index 8ee8a88d..6027acde 100644 --- a/source/glsl/reflect.cpp +++ b/source/glsl/reflect.cpp @@ -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()-1); + r_size = aligned_size*literal->value.value(); } } -- 2.43.0