Merge branch 'TiemoJung-semantic_handling'
authorJohn Kessenich <cepheus@frii.com>
Wed, 15 Mar 2017 03:50:06 +0000 (21:50 -0600)
committerJohn Kessenich <cepheus@frii.com>
Wed, 15 Mar 2017 04:44:24 +0000 (22:44 -0600)
1  2 
glslang/Include/Types.h
glslang/Include/revision.h
glslang/MachineIndependent/iomapper.cpp
glslang/MachineIndependent/localintermediate.h
hlsl/hlslGrammar.cpp
hlsl/hlslParseHelper.cpp
hlsl/hlslParseHelper.h
hlsl/hlslScanContext.cpp
hlsl/hlslScanContext.h
hlsl/hlslTokenStream.h

index 4d3c4b90508d2875c298c59e6bf41a0588622972,7078d8fdcb8a0a439f1116a42a0d564619ff06e6..f2b786eb4ecde4ec290eeaab41d4c406093ba6e1
@@@ -451,6 -454,12 +452,7 @@@ public
          specConstant = false;
      }
  
 -    bool hasSemantic() const
 -    {
 -      return semanticName != nullptr;
 -    }
 -
+     const char*         semanticName;
      TStorageQualifier   storage   : 6;
      TBuiltInVariable    builtIn   : 8;
      TPrecisionQualifier precision : 3;
index ea24000f6d7df374fd1d80e890ae7b58f16ad307,ea24000f6d7df374fd1d80e890ae7b58f16ad307..162e400bc7310f33398130460007efef42ef3d8c
@@@ -2,5 -2,5 +2,5 @@@
  // 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).
  
--#define GLSLANG_REVISION "Overload400-PrecQual.1911"
++#define GLSLANG_REVISION "Overload400-PrecQual.1914"
  #define GLSLANG_DATE "14-Mar-2017"
index 07aa476284e7e7d61a112aae12299a8320e6b3c9,a478a2ca08c200ce188c4c81dd7f4abc2a96887f..bebf775d9189daedbb5a8517ddb76f44859413e1
@@@ -122,13 -127,22 +127,21 @@@ public
  
      virtual void visitSymbol(TIntermSymbol* base)
      {
-         if (base->getType().getQualifier().isUniformOrBuffer()) {
 -        TVarLiveMap* target;
++        TVarLiveMap* target = nullptr;
+         if (base->getQualifier().storage == EvqVaryingIn)
+             target = &inputList;
+         else if (base->getQualifier().storage == EvqVaryingOut)
+             target = &outputList;
 -        else if (base->getType().getQualifier().isUniformOrBuffer())
++        else if (base->getQualifier().isUniformOrBuffer())
+             target = &uniformList;
 -        else
 -            target = nullptr;
++
+         if (target) {
              TVarEntryInfo ent = { base->getId(), base, !traverseAll };
-             TVarLiveMap::iterator at = std::lower_bound(varLiveList.begin(), varLiveList.end(), ent, TVarEntryInfo::TOrderById());
-             if (at != varLiveList.end() && at->id == ent.id)
+             TVarLiveMap::iterator at = std::lower_bound(target->begin(), target->end(), ent, TVarEntryInfo::TOrderById());
+             if (at != target->end() && at->id == ent.id)
                at->live = at->live || !traverseAll; // update live state
              else
-               varLiveList.insert(at, ent);
+               target->insert(at, ent);
          }
      }
  
@@@ -148,11 -166,22 +165,22 @@@ public
  
      virtual void visitSymbol(TIntermSymbol* base)
      {
 -        else if (base->getQualifier().storage == EvqUniform)
+         const TVarLiveMap* source;
+         if (base->getQualifier().storage == EvqVaryingIn)
+             source = &inputList;
+         else if (base->getQualifier().storage == EvqVaryingOut)
+             source = &outputList;
++        else if (base->getQualifier().isUniformOrBuffer())
+             source = &uniformList;
+         else
+             return;
          TVarEntryInfo ent = { base->getId() };
-         TVarLiveMap::const_iterator at = std::lower_bound(varLiveList.begin(), varLiveList.end(), ent, TVarEntryInfo::TOrderById());
-         if (at == varLiveList.end())
+         TVarLiveMap::const_iterator at = std::lower_bound(source->begin(), source->end(), ent, TVarEntryInfo::TOrderById());
+         if (at == source->end())
              return;
-         if (!(at->id == ent.id))
+         if (at->id != ent.id)
              return;
  
          if (at->newBinding != -1)
@@@ -216,8 -313,8 +312,8 @@@ private
  
  /*
   * Basic implementation of glslang::TIoMapResolver that replaces the
-- * previous offset behaviour.
-- * It does the same, uses the offsets for th corresponding uniform
++ * previous offset behavior.
++ * It does the same, uses the offsets for the corresponding uniform
   * types. Also respects the EOptionAutoMapBindings flag and binds
   * them if needed.
   */
index 34940a6982c57e59e615d505bc5362d2ae67178d,e9ed67ac065a14414df7bb4a841bc024b8a6864b..392a2ab09e99f74cc6b0db3b92669c7b61b150fb
@@@ -423,6 -423,11 +423,11 @@@ public
      bool getGeoPassthroughEXT() const { return geoPassthroughEXT; }
  #endif
  
 -      return semanticNameSet.insert(name).first->c_str();
+     const char* addSemanticName(const TString& name)
+     {
++        return semanticNameSet.insert(name).first->c_str();
+     }
  protected:
      TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&);
      void error(TInfoSink& infoSink, const char*);
index 166141b3e12df15045a8d7c228cff3406ce454a1,166141b3e12df15045a8d7c228cff3406ce454a1..7a0172c847c7e174366c86f7513c9b4354db7d9f
@@@ -3528,7 -3528,7 +3528,9 @@@ bool HlslGrammar::acceptPostDecls(TQual
                  parseContext.handleRegister(registerDesc.loc, qualifier, profile.string, *registerDesc.string, subComponent, spaceDesc.string);
              } else {
                  // semantic, in idToken.string
--                parseContext.handleSemantic(idToken.loc, qualifier, mapSemantic(*idToken.string));
++                TString semanticUpperCase = *idToken.string;
++                std::transform(semanticUpperCase.begin(), semanticUpperCase.end(), semanticUpperCase.begin(), ::toupper);
++                parseContext.handleSemantic(idToken.loc, qualifier, mapSemantic(semanticUpperCase.c_str()), semanticUpperCase);
              }
          } else if (peekTokenClass(EHTokLeftAngle)) {
              found = true;
index 3c88d47b532b306ae5d3b45fce53202eed6814e3,358f9c56788cbe297adda22bcdc328d6cab4f021..34cf5d37d5b9a3684725e7228967de9f214ce5ca
@@@ -4144,7 -4144,7 +4144,7 @@@ TFunction* HlslParseContext::handleCons
  // Handle seeing a "COLON semantic" at the end of a type declaration,
  // by updating the type according to the semantic.
  //
--void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBuiltInVariable builtIn)
++void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBuiltInVariable builtIn, const TString& upperCase)
  {
      // adjust for stage in/out
  
      }
  
      qualifier.builtIn = builtIn;
 -    qualifier.semanticName = intermediate.addSemanticName(semanticUpperCase);
++    qualifier.semanticName = intermediate.addSemanticName(upperCase);
  }
  
  //
index 2f6f24c7ecc2e90dc8cb925de21ac36f88039947,2f6f24c7ecc2e90dc8cb925de21ac36f88039947..602bb86acfec597fd7ba6e3d687666e427e15da3
@@@ -91,7 -91,7 +91,7 @@@ public
      TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermOperator&);
      void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
      TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
--    void handleSemantic(TSourceLoc, TQualifier&, TBuiltInVariable);
++    void handleSemantic(TSourceLoc, TQualifier&, TBuiltInVariable, const TString& upperCase);
      void handlePackOffset(const TSourceLoc&, TQualifier&, const glslang::TString& location,
                            const glslang::TString* component);
      void handleRegister(const TSourceLoc&, TQualifier&, const glslang::TString* profile, const glslang::TString& desc,
index ba8088bc12652b573037eb110a71b0b1493ffa47,ba8088bc12652b573037eb110a71b0b1493ffa47..d08a2c365504c5a97657041ef103393596d2082d
@@@ -467,12 -467,12 +467,9 @@@ void HlslScanContext::tokenize(HlslToke
      token.tokenClass = tokenClass;
  }
  
--glslang::TBuiltInVariable HlslScanContext::mapSemantic(const TString& semantic)
++glslang::TBuiltInVariable HlslScanContext::mapSemantic(const char* upperCase)
  {
--    TString semanticUpperCase = semantic;
--    std::transform(semanticUpperCase.begin(), semanticUpperCase.end(), semanticUpperCase.begin(), ::toupper);
--
--    auto it = SemanticMap->find(semanticUpperCase.c_str());
++    auto it = SemanticMap->find(upperCase);
      if (it != SemanticMap->end())
          return it->second;
      else
index bb8b09e85dd823036ac8079c52fed133be2441f3,bb8b09e85dd823036ac8079c52fed133be2441f3..c6f47ff5001a3a4fdb0d50d7076a1e4645939040
@@@ -82,7 -82,7 +82,7 @@@ public
      static void deleteKeywordMap();
  
      void tokenize(HlslToken&);
--    glslang::TBuiltInVariable mapSemantic(const TString& semantic);
++    glslang::TBuiltInVariable mapSemantic(const char*);
  
  protected:
      HlslScanContext(HlslScanContext&);
index 333fef96a63e776df8c8b7e3bb6956eec1e14927,333fef96a63e776df8c8b7e3bb6956eec1e14927..cb6c9e7234fecf23c8069c30c8f6770aefc1523f
@@@ -52,7 -52,7 +52,7 @@@ namespace glslang 
          bool acceptTokenClass(EHlslTokenClass);
          EHlslTokenClass peek() const;
          bool peekTokenClass(EHlslTokenClass) const;
--        glslang::TBuiltInVariable mapSemantic(const TString& semantic) { return scanner.mapSemantic(semantic); }
++        glslang::TBuiltInVariable mapSemantic(const char* upperCase) { return scanner.mapSemantic(upperCase); }
  
          void pushTokenStream(const TVector<HlslToken>* tokens);
          void popTokenStream();