From 79b7046a272ffd33f221b85cf45a128fc498680f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 12 Jan 2016 13:04:52 -0800 Subject: [PATCH 1/2] getBaseAlignment: Round up structure sizes to max alignment --- glslang/MachineIndependent/linkValidate.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index 7c96d225..664a8dff 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -959,6 +959,11 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b size += memberSize; } + // The structure may have padding at the end; the base offset of + // the member following the sub-structure is rounded up to the next + // multiple of the base alignment of the structure. + RoundToPow2(size, maxAlignment); + return maxAlignment; } From a76766a43474f11b00c89eef6ef3772c6537a4c2 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 13 Jan 2016 17:14:43 -0800 Subject: [PATCH 2/2] getBaseAlignment: Use the rowMajor argument for determining matrix strides The argument version is passed in from above and struct handling ensures that row-majorness gets propagated correctly from one level to the next. If we just look at the type itself and it's embedded in a struct that's declared row-major, we may get the wrong stride. --- glslang/MachineIndependent/linkValidate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index 664a8dff..d0e7b021 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -987,7 +987,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b // rules 5 and 7 if (type.isMatrix()) { // rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows - TType derefType(type, 0, type.getQualifier().layoutMatrix == ElmRowMajor); + TType derefType(type, 0, rowMajor); alignment = getBaseAlignment(derefType, size, dummyStride, std140, rowMajor); if (std140)