Commit 2dc50ff3 by John Kessenich

Merge branch 'semantic_handling' of https://github.com/TiemoJung/glslang into…

Merge branch 'semantic_handling' of https://github.com/TiemoJung/glslang into TiemoJung-semantic_handling
parents 71c100d7 8bb3ee53
...@@ -394,6 +394,7 @@ public: ...@@ -394,6 +394,7 @@ public:
void clear() void clear()
{ {
semanticName = nullptr;
precision = EpqNone; precision = EpqNone;
invariant = false; invariant = false;
noContraction = false; noContraction = false;
...@@ -403,6 +404,7 @@ public: ...@@ -403,6 +404,7 @@ public:
// drop qualifiers that don't belong in a temporary variable // drop qualifiers that don't belong in a temporary variable
void makeTemporary() void makeTemporary()
{ {
semanticName = nullptr;
storage = EvqTemporary; storage = EvqTemporary;
builtIn = EbvNone; builtIn = EbvNone;
clearInterstage(); clearInterstage();
...@@ -447,10 +449,17 @@ public: ...@@ -447,10 +449,17 @@ public:
// If A, then nothing should change, if B, then everything should change, but this is half way. // If A, then nothing should change, if B, then everything should change, but this is half way.
void makePartialTemporary() void makePartialTemporary()
{ {
semanticName = nullptr;
storage = EvqTemporary; storage = EvqTemporary;
specConstant = false; specConstant = false;
} }
bool hasSemantic() const
{
return semanticName != nullptr;
}
const char* semanticName;
TStorageQualifier storage : 6; TStorageQualifier storage : 6;
TBuiltInVariable builtIn : 8; TBuiltInVariable builtIn : 8;
TPrecisionQualifier precision : 3; TPrecisionQualifier precision : 3;
......
...@@ -423,6 +423,11 @@ public: ...@@ -423,6 +423,11 @@ public:
bool getGeoPassthroughEXT() const { return geoPassthroughEXT; } bool getGeoPassthroughEXT() const { return geoPassthroughEXT; }
#endif #endif
const char* addSemanticName(const TString& name)
{
return semanticNameSet.insert(name).first->c_str();
}
protected: protected:
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&); TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&);
void error(TInfoSink& infoSink, const char*); void error(TInfoSink& infoSink, const char*);
...@@ -501,6 +506,7 @@ protected: ...@@ -501,6 +506,7 @@ protected:
std::vector<TOffsetRange> usedAtomics; // sets of bindings used by atomic counters std::vector<TOffsetRange> usedAtomics; // sets of bindings used by atomic counters
std::vector<TXfbBuffer> xfbBuffers; // all the data we need to track per xfb buffer std::vector<TXfbBuffer> xfbBuffers; // all the data we need to track per xfb buffer
std::unordered_set<int> usedConstantId; // specialization constant ids used std::unordered_set<int> usedConstantId; // specialization constant ids used
std::set<TString> semanticNameSet;
private: private:
void operator=(TIntermediate&); // prevent assignments void operator=(TIntermediate&); // prevent assignments
......
...@@ -452,10 +452,12 @@ class TIoMapper; ...@@ -452,10 +452,12 @@ class TIoMapper;
// and resolveSet are invoked to resolve the binding and descriptor // and resolveSet are invoked to resolve the binding and descriptor
// set index respectively. // set index respectively.
// Invocations happen in a particular order: // Invocations happen in a particular order:
// 1) var with binding and set already defined // 1) all shader inputs
// 2) var with binding but no set defined // 2) all shader outputs
// 3) var with set but no binding defined // 3) all uniforms with binding and set already defined
// 4) var with no binding and no set defined // 4) all uniforms with binding but no set defined
// 5) all uniforms with set but no binding defined
// 6) all uniforms with no binding and no set defined
// //
// NOTE: that still limit checks are applied to bindings and sets // NOTE: that still limit checks are applied to bindings and sets
// and may result in an error. // and may result in an error.
...@@ -473,6 +475,18 @@ public: ...@@ -473,6 +475,18 @@ public:
// Should return a value >= 0 if the current set should be overriden. // Should return a value >= 0 if the current set should be overriden.
// Return -1 if the current set (including no set) should be kept. // Return -1 if the current set (including no set) should be kept.
virtual int resolveSet(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0; virtual int resolveSet(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
// Should return true if the resuling/current setup would be ok.
// Basic idea is to do aliasing checks and reject invalid semantic names.
virtual bool validateInOut(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
// Should return a value >= 0 if the current location should be overriden.
// Return -1 if the current location (including no location) should be kept.
virtual int resolveInOutLocation(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
// Should return a value >= 0 if the current component index should be overriden.
// Return -1 if the current component index (including no index) should be kept.
virtual int resolveInOutComponent(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
// Should return a value >= 0 if the current color index should be overriden.
// Return -1 if the current color index (including no index) should be kept.
virtual int resolveInOutIndex(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
}; };
// Make one TProgram per set of shaders that will get linked together. Add all // Make one TProgram per set of shaders that will get linked together. Add all
......
...@@ -4161,6 +4161,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBu ...@@ -4161,6 +4161,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBu
} }
qualifier.builtIn = builtIn; qualifier.builtIn = builtIn;
qualifier.semanticName = intermediate.addSemanticName(semanticUpperCase);
} }
// //
......
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