Commit 2619e475 by John Kessenich

Merge pull request #130 from jekstrand/fix-std140-struct

linkValidate: Round up structure sizes to vec4 in std140
parents e23c9849 a76766a4
...@@ -959,6 +959,11 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b ...@@ -959,6 +959,11 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
size += memberSize; 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; return maxAlignment;
} }
...@@ -982,7 +987,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b ...@@ -982,7 +987,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
// rules 5 and 7 // rules 5 and 7
if (type.isMatrix()) { if (type.isMatrix()) {
// rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows // 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); alignment = getBaseAlignment(derefType, size, dummyStride, std140, rowMajor);
if (std140) if (std140)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment