Commit 727b374f by John Kessenich

HLSL: Build IO types bottom up, as parsed, and cache the original (IO).

Previously, this was done recursively, per object, and the nonIO version was cached. This reverses both those approaches.
parent 88c4464d
...@@ -412,7 +412,7 @@ public: ...@@ -412,7 +412,7 @@ public:
} }
// Remove IO related data from qualifier. // Remove IO related data from qualifier.
void makeNonIo() void makeNonIo() //?? remove?
{ {
// This preserves the storage type // This preserves the storage type
builtIn = EbvNone; builtIn = EbvNone;
...@@ -429,7 +429,7 @@ public: ...@@ -429,7 +429,7 @@ public:
} }
// Return true if there is data which would be scrubbed by makeNonIo // Return true if there is data which would be scrubbed by makeNonIo
bool hasIoData() const bool hasIoData() const // ?? remove?
{ {
return builtIn != EbvNone || return builtIn != EbvNone ||
hasLayout() || hasLayout() ||
...@@ -626,7 +626,6 @@ public: ...@@ -626,7 +626,6 @@ public:
{ {
return hasUniformLayout() || return hasUniformLayout() ||
hasAnyLocation() || hasAnyLocation() ||
hasBinding() ||
hasStream() || hasStream() ||
hasXfb() || hasXfb() ||
hasFormat() || hasFormat() ||
...@@ -1221,34 +1220,10 @@ public: ...@@ -1221,34 +1220,10 @@ public:
// Make complete copy of the whole type graph rooted at 'copyOf'. // Make complete copy of the whole type graph rooted at 'copyOf'.
void deepCopy(const TType& copyOf) void deepCopy(const TType& copyOf)
{ {
TMap<TTypeList*,TTypeList*> copied; // to enable copying a type graph as a graph, not a tree TMap<TTypeList*,TTypeList*> copied; // to enable copying a type graph as a graph, not a tree //?? turn off again?
deepCopy(copyOf, copied); deepCopy(copyOf, copied);
} }
// Return true if type (recursively) contains IO data.
bool hasIoData() const
{
if (getQualifier().hasIoData())
return true;
if (isStruct())
for (unsigned int i = 0; i < structure->size(); ++i)
if ((*structure)[i].type->hasIoData())
return true;
return false;
}
// Remove IO related data from type
void makeNonIo()
{
getQualifier().makeNonIo();
if (isStruct())
for (unsigned int i = 0; i < structure->size(); ++i)
(*structure)[i].type->makeNonIo();
}
// Recursively make temporary // Recursively make temporary
void makeTemporary() void makeTemporary()
{ {
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // 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). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1787" #define GLSLANG_REVISION "Overload400-PrecQual.1791"
#define GLSLANG_DATE "03-Feb-2017" #define GLSLANG_DATE "04-Feb-2017"
...@@ -1708,14 +1708,7 @@ bool HlslGrammar::acceptStruct(TType& type) ...@@ -1708,14 +1708,7 @@ bool HlslGrammar::acceptStruct(TType& type)
new(&type) TType(typeList, structName, postDeclQualifier); // sets EbtBlock new(&type) TType(typeList, structName, postDeclQualifier); // sets EbtBlock
} }
// If it was named, which means the type can be reused later, add parseContext.declareStruct(token.loc, structName, type);
// it to the symbol table. (Unless it's a block, in which
// case the name is not a type.)
if (type.getBasicType() != EbtBlock && structName.size() > 0) {
TVariable* userTypeDef = new TVariable(&structName, type, true);
if (! parseContext.symbolTable.insert(*userTypeDef))
parseContext.error(token.loc, "redefinition", structName.c_str(), "struct");
}
return true; return true;
} }
......
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributeMap&, TIntermNode*& entryPointTree); TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributeMap&, TIntermNode*& entryPointTree);
TIntermNode* transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributeMap&); TIntermNode* transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributeMap&);
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node); void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
void remapEntryPointIO(const TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs); void remapEntryPointIO(TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs);
void remapNonEntryPointIO(TFunction& function); void remapNonEntryPointIO(TFunction& function);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*); TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg); void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
...@@ -131,6 +131,7 @@ public: ...@@ -131,6 +131,7 @@ public:
const TFunction* findFunction(const TSourceLoc& loc, TFunction& call, bool& builtIn, TIntermTyped*& args); const TFunction* findFunction(const TSourceLoc& loc, TFunction& call, bool& builtIn, TIntermTyped*& args);
void declareTypedef(const TSourceLoc&, TString& identifier, const TType&, TArraySizes* typeArray = 0); void declareTypedef(const TSourceLoc&, TString& identifier, const TType&, TArraySizes* typeArray = 0);
void declareStruct(const TSourceLoc&, TString& structName, TType&);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, TType&, TIntermTyped* initializer = 0); TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, TType&, TIntermTyped* initializer = 0);
void lengthenList(const TSourceLoc&, TIntermSequence& list, int size); void lengthenList(const TSourceLoc&, TIntermSequence& list, int size);
TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&); TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&);
...@@ -230,10 +231,6 @@ protected: ...@@ -230,10 +231,6 @@ protected:
int flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name); int flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
int flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name); int flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
// Create a non-IO type from an IO type. If there is no IO data, this returns the input type unmodified.
// Otherwise, it modifies the type in place, and returns a pointer to it.
void makeTypeNonIo(TType*);
void finish() override; // post-processing void finish() override; // post-processing
// Current state of parsing // Current state of parsing
...@@ -299,9 +296,8 @@ protected: ...@@ -299,9 +296,8 @@ protected:
TVector<int> flattenLevel; // nested postfix operator level for flattening TVector<int> flattenLevel; // nested postfix operator level for flattening
TVector<int> flattenOffset; // cumulative offset for flattening TVector<int> flattenOffset; // cumulative offset for flattening
// Sanitized type map. If the same type is sanitized again, we want to reuse it. // IO-type map.
// We cannot index by the TType: the map is typelist to typelist. TMap<const TTypeList*, TTypeList*> ioTypeMap;
TMap<const TTypeList*, TTypeList*> nonIoTypeMap;
// Structure splitting data: // Structure splitting data:
TMap<int, TVariable*> splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID. TMap<int, TVariable*> splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID.
......
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