From 54519ed70fbe154e196d04a8b62f6ea6aeded52a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 7 Jul 2017 08:16:09 -0700 Subject: Fix alignment computation for `std140` uniforms Fixes #55 I was incorrectly computing alignment as `elementSize * elementAlignment`, rounded up to a power of two (which works out to be `elementSize` squared), when I should have been using `elementSize * elementCount`, rounded up to a power of two. --- source/slang/type-layout.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/slang/type-layout.cpp') diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 2fcf64226..fbaec3736 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -163,10 +163,11 @@ struct Std140LayoutRulesImpl : GLSLConstantBufferLayoutRulesImpl SimpleLayoutInfo GetVectorLayout(SimpleLayoutInfo elementInfo, size_t elementCount) override { assert(elementInfo.kind == LayoutResourceKind::Uniform); + auto size = elementInfo.size * elementCount; SimpleLayoutInfo vectorInfo( LayoutResourceKind::Uniform, - elementInfo.size * elementCount, - RoundUpToPowerOfTwo(elementInfo.size * elementInfo.alignment)); + size, + RoundUpToPowerOfTwo(size)); return vectorInfo; } }; -- cgit v1.2.3