Commit 150b7acd by John Kessenich

Restore r26192, r26240, r26241: All three about implicit-array sizing design…

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
parent 078c010d
...@@ -866,10 +866,10 @@ void TIntermediate::addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguag ...@@ -866,10 +866,10 @@ void TIntermediate::addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguag
// by the AST. // by the AST.
// //
// Almost entirely, translation of symbols is driven by what's present // Almost entirely, translation of symbols is driven by what's present
// in the AST traversal, not by translating the symbol table. // in the AST traversal, not by translating the symbol table.
// //
// However, there are some special cases: // However, there are some special cases:
// - From the specification: "Special built-in inputs gl_VertexID and // - From the specification: "Special built-in inputs gl_VertexID and
// gl_InstanceID are also considered active vertex attributes." // gl_InstanceID are also considered active vertex attributes."
// - Linker-based type mismatch error reporting needs to see all // - Linker-based type mismatch error reporting needs to see all
// uniforms/ins/outs variables and blocks. // uniforms/ins/outs variables and blocks.
......
...@@ -1064,7 +1064,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages) ...@@ -1064,7 +1064,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
intermediate[stage]->finalCheck(*infoSink); intermediate[stage]->finalCheck(*infoSink);
if (messages & EShMsgAST) if (messages & EShMsgAST)
intermediate[stage]->output(*infoSink, stages[stage].size() > 1); intermediate[stage]->output(*infoSink, true);
return intermediate[stage]->getNumErrors() == 0; return intermediate[stage]->getNumErrors() == 0;
} }
......
...@@ -206,7 +206,10 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin ...@@ -206,7 +206,10 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
// Similarly for binding // Similarly for binding
if (! symbol->getQualifier().hasBinding() && unitSymbol->getQualifier().hasBinding()) if (! symbol->getQualifier().hasBinding() && unitSymbol->getQualifier().hasBinding())
symbol->getQualifier().layoutBinding = unitSymbol->getQualifier().layoutBinding; symbol->getQualifier().layoutBinding = unitSymbol->getQualifier().layoutBinding;
// Update implicit array sizes
mergeImplicitArraySizes(symbol->getWritableType(), unitSymbol->getType());
// Check for consistent types/qualification/initializers etc. // Check for consistent types/qualification/initializers etc.
mergeErrorCheck(infoSink, *symbol, *unitSymbol, false); mergeErrorCheck(infoSink, *symbol, *unitSymbol, false);
} }
...@@ -216,6 +219,25 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin ...@@ -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 // 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. // well enough. Rules can be different for intra- vs. cross-stage matching.
...@@ -305,7 +327,7 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy ...@@ -305,7 +327,7 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
// Do final link-time error checking of a complete (merged) intermediate representation. // Do final link-time error checking of a complete (merged) intermediate representation.
// (Much error checking was done during merging). // (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) void TIntermediate::finalCheck(TInfoSink& infoSink)
{ {
...@@ -392,6 +414,21 @@ void TIntermediate::finalCheck(TInfoSink& infoSink) ...@@ -392,6 +414,21 @@ void TIntermediate::finalCheck(TInfoSink& infoSink)
case EShLangCompute: case EShLangCompute:
break; 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 ...@@ -877,11 +914,8 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140) c
// rules 5 and 7 // rules 5 and 7
if (type.isMatrix()) { 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 // 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) TType derefType(type, 0, type.getQualifier().layoutMatrix == ElmRowMajor);
derefType.setElementType(derefType.getBasicType(), type.getMatrixCols(), 0, 0, 0);
alignment = getBaseAlignment(derefType, size, std140); alignment = getBaseAlignment(derefType, size, std140);
if (std140) if (std140)
......
...@@ -251,6 +251,7 @@ protected: ...@@ -251,6 +251,7 @@ protected:
void error(TInfoSink& infoSink, const char*); void error(TInfoSink& infoSink, const char*);
void mergeBodies(TInfoSink&, TIntermSequence& globals, const TIntermSequence& unitGlobals); void mergeBodies(TInfoSink&, TIntermSequence& globals, const TIntermSequence& unitGlobals);
void mergeLinkerObjects(TInfoSink&, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects); void mergeLinkerObjects(TInfoSink&, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects);
void mergeImplicitArraySizes(TType&, const TType&);
void mergeErrorCheck(TInfoSink&, const TIntermSymbol&, const TIntermSymbol&, bool crossStage); void mergeErrorCheck(TInfoSink&, const TIntermSymbol&, const TIntermSymbol&, bool crossStage);
void checkCallGraphCycles(TInfoSink&); void checkCallGraphCycles(TInfoSink&);
void inOutLocationCheck(TInfoSink&); void inOutLocationCheck(TInfoSink&);
......
...@@ -283,7 +283,7 @@ public: ...@@ -283,7 +283,7 @@ public:
bool block = base->getBasicType() == EbtBlock; bool block = base->getBasicType() == EbtBlock;
if (block) { if (block) {
offset = 0; offset = 0;
anonymous = base->getName().compare(0, 6, "__anon") == 0; anonymous = IsAnonymous(base->getName());
if (base->getType().isArray()) { if (base->getType().isArray()) {
assert(! anonymous); assert(! anonymous);
for (int e = 0; e < base->getType().getArraySize(); ++e) for (int e = 0; e < base->getType().getArraySize(); ++e)
......
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