Restore r26192, r26240, r26241: All three about implicit-array sizing design and implementation. *Minus* test results.
r26192: Link-time sizing of implicitly-sized arrays and handling of anonymous blocks containing implicitly-sized members. Also changed "__anon" to "anon@" and encapsulated it. r26240: Solidify the sharing of struct and array information between nodes and variables: A single copy now allows for simultaneously setting array size for all effected nodes and symbols of a given type. This allowed removal of ioArrayNodeResizeList and makes nodes of implicitly sized arrays know the final size. r26241: Fix g++ issue with wanting non-const iterator. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@26218 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
078c010de7
commit
150b7acd9a
7 changed files with 222 additions and 150 deletions
|
|
@ -206,7 +206,10 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
|
|||
// Similarly for binding
|
||||
if (! symbol->getQualifier().hasBinding() && unitSymbol->getQualifier().hasBinding())
|
||||
symbol->getQualifier().layoutBinding = unitSymbol->getQualifier().layoutBinding;
|
||||
|
||||
|
||||
// Update implicit array sizes
|
||||
mergeImplicitArraySizes(symbol->getWritableType(), unitSymbol->getType());
|
||||
|
||||
// Check for consistent types/qualification/initializers etc.
|
||||
mergeErrorCheck(infoSink, *symbol, *unitSymbol, false);
|
||||
}
|
||||
|
|
@ -216,6 +219,25 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
|
|||
}
|
||||
}
|
||||
|
||||
// Recursively merge the implicit array sizes through the objects' respective type trees.
|
||||
void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
|
||||
{
|
||||
if (type.isImplicitlySizedArray() && unitType.isArray()) {
|
||||
int newImplicitArraySize = unitType.getArraySize();
|
||||
if (newImplicitArraySize == 0)
|
||||
newImplicitArraySize = unitType.getImplicitArraySize();
|
||||
if (newImplicitArraySize > type.getImplicitArraySize ())
|
||||
type.setImplicitArraySize(newImplicitArraySize);
|
||||
}
|
||||
|
||||
// Type mismatches are caught and reported after this, just be careful for now.
|
||||
if (! type.isStruct() || ! unitType.isStruct() || type.getStruct()->size() != unitType.getStruct()->size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < (int)type.getStruct()->size(); ++i)
|
||||
mergeImplicitArraySizes(*(*type.getStruct())[i].type, *(*unitType.getStruct())[i].type);
|
||||
}
|
||||
|
||||
//
|
||||
// Compare two global objects from two compilation units and see if they match
|
||||
// well enough. Rules can be different for intra- vs. cross-stage matching.
|
||||
|
|
@ -305,7 +327,7 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
|||
// Do final link-time error checking of a complete (merged) intermediate representation.
|
||||
// (Much error checking was done during merging).
|
||||
//
|
||||
// Also, lock in defaults of things not set.
|
||||
// Also, lock in defaults of things not set, including array sizes.
|
||||
//
|
||||
void TIntermediate::finalCheck(TInfoSink& infoSink)
|
||||
{
|
||||
|
|
@ -392,6 +414,21 @@ void TIntermediate::finalCheck(TInfoSink& infoSink)
|
|||
case EShLangCompute:
|
||||
break;
|
||||
}
|
||||
|
||||
// Process the tree for any node-specific work.
|
||||
class TFinalLinkTraverser : public TIntermTraverser {
|
||||
public:
|
||||
TFinalLinkTraverser() { }
|
||||
virtual ~TFinalLinkTraverser() { }
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol* symbol)
|
||||
{
|
||||
// Implicitly size arrays.
|
||||
symbol->getWritableType().adoptImplicitArraySizes();
|
||||
}
|
||||
} finalLinkTraverser;
|
||||
|
||||
treeRoot->traverse(&finalLinkTraverser);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -877,11 +914,8 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140) c
|
|||
|
||||
// rules 5 and 7
|
||||
if (type.isMatrix()) {
|
||||
TType derefType(type, 0);
|
||||
|
||||
// rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows
|
||||
if (type.getQualifier().layoutMatrix == ElmRowMajor)
|
||||
derefType.setElementType(derefType.getBasicType(), type.getMatrixCols(), 0, 0, 0);
|
||||
TType derefType(type, 0, type.getQualifier().layoutMatrix == ElmRowMajor);
|
||||
|
||||
alignment = getBaseAlignment(derefType, size, std140);
|
||||
if (std140)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue