SPV: recursively propagate row/col majorness through nested structures.
This includes doing structure uniqueness modulo majorness, for shared nested structures.
This commit is contained in:
parent
f85e806e44
commit
3ac051e41d
9 changed files with 313 additions and 163 deletions
|
|
@ -186,15 +186,15 @@ enum TLayoutPacking {
|
|||
ElpShared, // default, but different than saying nothing
|
||||
ElpStd140,
|
||||
ElpStd430,
|
||||
ElpPacked
|
||||
// If expanding, see bitfield width below
|
||||
ElpPacked,
|
||||
ElpCount // If expanding, see bitfield width below
|
||||
};
|
||||
|
||||
enum TLayoutMatrix {
|
||||
ElmNone,
|
||||
ElmRowMajor,
|
||||
ElmColumnMajor // default, but different than saying nothing
|
||||
// If expanding, see bitfield width below
|
||||
ElmColumnMajor, // default, but different than saying nothing
|
||||
ElmCount // If expanding, see bitfield width below
|
||||
};
|
||||
|
||||
// Union of geometry shader and tessellation shader geometry types.
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
// For the version, it uses the latest git tag followed by the number of commits.
|
||||
// For the date, it uses the current date (when then script is run).
|
||||
|
||||
#define GLSLANG_REVISION "SPIRV99.860"
|
||||
#define GLSLANG_DATE "19-Dec-2015"
|
||||
#define GLSLANG_REVISION "SPIRV99.861"
|
||||
#define GLSLANG_DATE "20-Dec-2015"
|
||||
|
|
|
|||
|
|
@ -5345,8 +5345,11 @@ void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typ
|
|||
const TSourceLoc& memberLoc = typeList[member].loc;
|
||||
|
||||
// "When align is applied to an array, it effects only the start of the array, not the array's internal stride."
|
||||
|
||||
int memberAlignment = intermediate.getBaseAlignment(*typeList[member].type, memberSize, qualifier.layoutPacking == ElpStd140);
|
||||
|
||||
// modify just the children's view of matrix layout, if there is one for this member
|
||||
TLayoutMatrix subMatrixLayout = typeList[member].type->getQualifier().layoutMatrix;
|
||||
int memberAlignment = intermediate.getBaseAlignment(*typeList[member].type, memberSize, qualifier.layoutPacking == ElpStd140,
|
||||
subMatrixLayout != ElmNone ? subMatrixLayout == ElmRowMajor : qualifier.layoutMatrix == ElmRowMajor);
|
||||
if (memberQualifier.hasOffset()) {
|
||||
// "The specified offset must be a multiple
|
||||
// of the base alignment of the type of the block member it qualifies, or a compile-time error results."
|
||||
|
|
|
|||
|
|
@ -859,7 +859,7 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
|
|||
//
|
||||
// The size is returned in the 'size' parameter
|
||||
// Return value is the alignment of the type.
|
||||
int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140)
|
||||
int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140, bool rowMajor)
|
||||
{
|
||||
int alignment;
|
||||
|
||||
|
|
@ -921,7 +921,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140)
|
|||
if (type.isArray()) {
|
||||
// TODO: perf: this might be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
|
||||
TType derefType(type, 0);
|
||||
alignment = getBaseAlignment(derefType, size, std140);
|
||||
alignment = getBaseAlignment(derefType, size, std140, rowMajor);
|
||||
if (std140)
|
||||
alignment = std::max(baseAlignmentVec4Std140, alignment);
|
||||
RoundToPow2(size, alignment);
|
||||
|
|
@ -937,7 +937,10 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140)
|
|||
int maxAlignment = std140 ? baseAlignmentVec4Std140 : 0;
|
||||
for (size_t m = 0; m < memberList.size(); ++m) {
|
||||
int memberSize;
|
||||
int memberAlignment = getBaseAlignment(*memberList[m].type, memberSize, std140);
|
||||
// modify just the children's view of matrix layout, if there is one for this member
|
||||
TLayoutMatrix subMatrixLayout = memberList[m].type->getQualifier().layoutMatrix;
|
||||
int memberAlignment = getBaseAlignment(*memberList[m].type, memberSize, std140,
|
||||
(subMatrixLayout != ElmNone) ? (subMatrixLayout == ElmRowMajor) : rowMajor);
|
||||
maxAlignment = std::max(maxAlignment, memberAlignment);
|
||||
RoundToPow2(size, memberAlignment);
|
||||
size += memberSize;
|
||||
|
|
@ -968,11 +971,11 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140)
|
|||
// 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);
|
||||
|
||||
alignment = getBaseAlignment(derefType, size, std140);
|
||||
alignment = getBaseAlignment(derefType, size, std140, rowMajor);
|
||||
if (std140)
|
||||
alignment = std::max(baseAlignmentVec4Std140, alignment);
|
||||
RoundToPow2(size, alignment);
|
||||
if (type.getQualifier().layoutMatrix == ElmRowMajor)
|
||||
if (rowMajor)
|
||||
size *= type.getMatrixRows();
|
||||
else
|
||||
size *= type.getMatrixCols();
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ public:
|
|||
}
|
||||
int addXfbBufferOffset(const TType&);
|
||||
unsigned int computeTypeXfbSize(const TType&, bool& containsDouble) const;
|
||||
static int getBaseAlignment(const TType&, int& size, bool std140);
|
||||
static int getBaseAlignment(const TType&, int& size, bool std140, bool rowMajor);
|
||||
|
||||
protected:
|
||||
void error(TInfoSink& infoSink, const char*);
|
||||
|
|
|
|||
|
|
@ -123,7 +123,10 @@ public:
|
|||
int memberSize;
|
||||
int offset = 0;
|
||||
for (int m = 0; m <= index; ++m) {
|
||||
int memberAlignment = intermediate.getBaseAlignment(*memberList[m].type, memberSize, type.getQualifier().layoutPacking == ElpStd140);
|
||||
// modify just the children's view of matrix layout, if there is one for this member
|
||||
TLayoutMatrix subMatrixLayout = memberList[m].type->getQualifier().layoutMatrix;
|
||||
int memberAlignment = intermediate.getBaseAlignment(*memberList[m].type, memberSize, type.getQualifier().layoutPacking == ElpStd140,
|
||||
subMatrixLayout != ElmNone ? subMatrixLayout == ElmRowMajor : type.getQualifier().layoutMatrix == ElmRowMajor);
|
||||
RoundToPow2(offset, memberAlignment);
|
||||
if (m < index)
|
||||
offset += memberSize;
|
||||
|
|
@ -141,7 +144,8 @@ public:
|
|||
int lastOffset = getOffset(blockType, lastIndex);
|
||||
|
||||
int lastMemberSize;
|
||||
intermediate.getBaseAlignment(*memberList[lastIndex].type, lastMemberSize, blockType.getQualifier().layoutPacking == ElpStd140);
|
||||
intermediate.getBaseAlignment(*memberList[lastIndex].type, lastMemberSize, blockType.getQualifier().layoutPacking == ElpStd140,
|
||||
blockType.getQualifier().layoutMatrix == ElmRowMajor);
|
||||
|
||||
return lastOffset + lastMemberSize;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue