Merge pull request #632 from steve-lunarg/structure-splitting
HLSL: inter-stage structure splitting.
This commit is contained in:
@@ -186,6 +186,9 @@ protected:
|
||||
void fixConstInit(const TSourceLoc&, TString& identifier, TType& type, TIntermTyped*& initializer);
|
||||
void inheritGlobalDefaults(TQualifier& dst) const;
|
||||
TVariable* makeInternalVariable(const char* name, const TType&) const;
|
||||
TVariable* makeInternalVariable(const TString& name, const TType& type) const {
|
||||
return makeInternalVariable(name.c_str(), type);
|
||||
}
|
||||
TVariable* declareNonArray(const TSourceLoc&, TString& identifier, TType&, bool track);
|
||||
void declareArray(const TSourceLoc&, TString& identifier, const TType&, TSymbol*&, bool track);
|
||||
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
|
||||
@@ -198,7 +201,7 @@ protected:
|
||||
|
||||
// Array and struct flattening
|
||||
bool shouldFlatten(const TType& type) const;
|
||||
TIntermTyped* flattenAccess(const TSourceLoc&, TIntermTyped* base, int member);
|
||||
TIntermTyped* flattenAccess(TIntermTyped* base, int member);
|
||||
bool shouldFlattenIO(const TType&) const;
|
||||
bool shouldFlattenUniform(const TType&) const;
|
||||
bool wasFlattened(const TIntermTyped* node) const;
|
||||
@@ -206,11 +209,30 @@ protected:
|
||||
int addFlattenedMember(const TSourceLoc& loc, const TVariable&, const TType&, TFlattenData&, const TString& name, bool track);
|
||||
bool isFinalFlattening(const TType& type) const { return !(type.isStruct() || type.isArray()); }
|
||||
|
||||
// Structure splitting (splits interstage builtin types into its own struct)
|
||||
bool shouldSplit(const TType&);
|
||||
TIntermTyped* splitAccessStruct(const TSourceLoc& loc, TIntermTyped*& base, int& member);
|
||||
void splitAccessArray(const TSourceLoc& loc, TIntermTyped* base, TIntermTyped* index);
|
||||
TType& split(TType& type, TString name, const TType* outerStructType = nullptr);
|
||||
void split(TIntermTyped*);
|
||||
void split(const TVariable&);
|
||||
bool wasSplit(const TIntermTyped* node) const;
|
||||
bool wasSplit(int id) const { return splitIoVars.find(id) != splitIoVars.end(); }
|
||||
TVariable* getSplitIoVar(const TIntermTyped* node) const;
|
||||
TVariable* getSplitIoVar(const TVariable* var) const;
|
||||
TVariable* getSplitIoVar(int id) const;
|
||||
void addInterstageIoToLinkage();
|
||||
|
||||
void flatten(const TSourceLoc& loc, const TVariable& variable);
|
||||
int flatten(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);
|
||||
|
||||
// Type sanitization: return existing sanitized (temporary) type if there is one, else make new one.
|
||||
TType* sanitizeType(TType*);
|
||||
|
||||
void finish(); // post-processing
|
||||
|
||||
// Current state of parsing
|
||||
struct TPragma contextPragma;
|
||||
int loopNestingLevel; // 0 if outside all loops
|
||||
@@ -276,6 +298,38 @@ protected:
|
||||
TVector<int> flattenLevel; // nested postfix operator level for flattening
|
||||
TVector<int> flattenOffset; // cumulative offset for flattening
|
||||
|
||||
// Sanitized type map. During declarations we use the sanitized form of the type
|
||||
// if it exists.
|
||||
TMap<const TTypeList*, TType*> sanitizedTypeMap;
|
||||
|
||||
// Structure splitting data:
|
||||
TMap<int, TVariable*> splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID.
|
||||
|
||||
// The builtin interstage IO map considers e.g, EvqPosition on input and output separately, so that we
|
||||
// can build the linkage correctly if position appears on both sides. Otherwise, multiple positions
|
||||
// are considered identical.
|
||||
struct tInterstageIoData {
|
||||
tInterstageIoData(const TType& memberType, const TType& storageType) :
|
||||
builtIn(memberType.getQualifier().builtIn),
|
||||
storage(storageType.getQualifier().storage) { }
|
||||
|
||||
TBuiltInVariable builtIn;
|
||||
TStorageQualifier storage;
|
||||
|
||||
// ordering for maps
|
||||
bool operator<(const tInterstageIoData d) const {
|
||||
return (builtIn != d.builtIn) ? (builtIn < d.builtIn) : (storage < d.storage);
|
||||
}
|
||||
};
|
||||
|
||||
TMap<tInterstageIoData, TVariable*> interstageBuiltInIo; // individual builtin interstage IO vars, inxed by builtin type.
|
||||
|
||||
// We have to move array references to structs containing builtin interstage IO to the split variables.
|
||||
// This is only handled for one level. This stores the index, because we'll need it in the future, since
|
||||
// unlike normal array references, here the index happens before we discover what it applies to.
|
||||
TIntermTyped* builtInIoIndex;
|
||||
TIntermTyped* builtInIoBase;
|
||||
|
||||
unsigned int nextInLocation;
|
||||
unsigned int nextOutLocation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user