Merge branch 'semantic_handling' of https://github.com/TiemoJung/glslang into TiemoJu...
authorJohn Kessenich <cepheus@frii.com>
Wed, 15 Mar 2017 03:49:42 +0000 (21:49 -0600)
committerJohn Kessenich <cepheus@frii.com>
Wed, 15 Mar 2017 03:49:42 +0000 (21:49 -0600)
1  2 
glslang/Include/Types.h
glslang/MachineIndependent/iomapper.cpp
glslang/MachineIndependent/localintermediate.h
glslang/Public/ShaderLang.h
hlsl/hlslParseHelper.cpp

Simple merge
index 07aa476284e7e7d61a112aae12299a8320e6b3c9,9deac85770e1b2b56946b88746c5d6a2d01e33a0..a478a2ca08c200ce188c4c81dd7f4abc2a96887f
@@@ -122,13 -127,22 +127,22 @@@ public
  
      virtual void visitSymbol(TIntermSymbol* base)
      {
-         if (base->getType().getQualifier().isUniformOrBuffer()) {
+         TVarLiveMap* target;
+         if (base->getQualifier().storage == EvqVaryingIn)
+             target = &inputList;
+         else if (base->getQualifier().storage == EvqVaryingOut)
+             target = &outputList;
 -        else if (base->getQualifier().storage == EvqUniform)
++        else if (base->getType().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);
          }
      }
  
Simple merge
index 3c88d47b532b306ae5d3b45fce53202eed6814e3,89e89deca81ecea0caabb7c957296b3b62273ff6..358f9c56788cbe297adda22bcdc328d6cab4f021
@@@ -4144,23 -3793,119 +4144,24 @@@ 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, const TString& semantic)
 -{
 -    // TODO: need to know if it's an input or an output
 -    // The following sketches what needs to be done, but can't be right
 -    // without taking into account stage and input/output.
 -
 -    TString semanticUpperCase = semantic;
 -    std::transform(semanticUpperCase.begin(), semanticUpperCase.end(), semanticUpperCase.begin(), ::toupper);
 -    // in DX9, all outputs had to have a semantic associated with them, that was either consumed
 -    // by the system or was a specific register assignment
 -    // in DX10+, only semantics with the SV_ prefix have any meaning beyond decoration
 -    // Fxc will only accept DX9 style semantics in compat mode
 -    // Also, in DX10 if a SV value is present as the input of a stage, but isn't appropriate for that
 -    // stage, it would just be ignored as it is likely there as part of an output struct from one stage
 -    // to the next
 -    qualifier.semanticName = intermediate.addSemanticName(semanticUpperCase);
 +void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBuiltInVariable builtIn)
 +{
 +    // adjust for stage in/out
  
 -    bool bParseDX9 = false;
 -    if (bParseDX9) {
 -        if (semanticUpperCase == "PSIZE")
 -            qualifier.builtIn = EbvPointSize;
 -        else if (semantic == "FOG")
 -            qualifier.builtIn = EbvFogFragCoord;
 -        else if (semanticUpperCase == "DEPTH")
 -            qualifier.builtIn = EbvFragDepth;
 -        else if (semanticUpperCase == "VFACE")
 -            qualifier.builtIn = EbvFace;
 -        else if (semanticUpperCase == "VPOS")
 -            qualifier.builtIn = EbvFragCoord;
 -    }
 -
 -    // SV Position has a different meaning in vertex vs fragment
 -    if (semanticUpperCase == "SV_POSITION" && language != EShLangFragment)
 -        qualifier.builtIn = EbvPosition;
 -    else if (semanticUpperCase == "SV_POSITION" && language == EShLangFragment)
 -        qualifier.builtIn = EbvFragCoord;
 -    else if (semanticUpperCase == "SV_CLIPDISTANCE")
 -        qualifier.builtIn = EbvClipDistance;
 -    else if (semanticUpperCase == "SV_CULLDISTANCE")
 -        qualifier.builtIn = EbvCullDistance;
 -    else if (semanticUpperCase == "SV_VERTEXID")
 -        qualifier.builtIn = EbvVertexIndex;
 -    else if (semanticUpperCase == "SV_VIEWPORTARRAYINDEX")
 -        qualifier.builtIn = EbvViewportIndex;
 -    else if (semanticUpperCase == "SV_TESSFACTOR")
 -        qualifier.builtIn = EbvTessLevelOuter;
 -
 -    // Targets are defined 0-7
 -    else if (semanticUpperCase == "SV_TARGET") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 0;
 -    } else if (semanticUpperCase == "SV_TARGET0") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 0;
 -    } else if (semanticUpperCase == "SV_TARGET1") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 1;
 -    } else if (semanticUpperCase == "SV_TARGET2") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 2;
 -    } else if (semanticUpperCase == "SV_TARGET3") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 3;
 -    } else if (semanticUpperCase == "SV_TARGET4") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 4;
 -    } else if (semanticUpperCase == "SV_TARGET5") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 5;
 -    } else if (semanticUpperCase == "SV_TARGET6") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 6;
 -    } else if (semanticUpperCase == "SV_TARGET7") {
 -        qualifier.builtIn = EbvNone;
 -        // qualifier.layoutLocation = 7;
 -    } else if (semanticUpperCase == "SV_SAMPLEINDEX")
 -        qualifier.builtIn = EbvSampleId;
 -    else if (semanticUpperCase == "SV_RENDERTARGETARRAYINDEX")
 -        qualifier.builtIn = EbvLayer;
 -    else if (semanticUpperCase == "SV_PRIMITIVEID")
 -        qualifier.builtIn = EbvPrimitiveId;
 -    else if (semanticUpperCase == "SV_OUTPUTCONTROLPOINTID")
 -        qualifier.builtIn = EbvInvocationId;
 -    else if (semanticUpperCase == "SV_ISFRONTFACE")
 -        qualifier.builtIn = EbvFace;
 -    else if (semanticUpperCase == "SV_INSTANCEID")
 -        qualifier.builtIn = EbvInstanceIndex;
 -    else if (semanticUpperCase == "SV_INSIDETESSFACTOR")
 -        qualifier.builtIn = EbvTessLevelInner;
 -    else if (semanticUpperCase == "SV_GSINSTANCEID")
 -        qualifier.builtIn = EbvInvocationId;
 -    else if (semanticUpperCase == "SV_DISPATCHTHREADID")
 -        qualifier.builtIn = EbvGlobalInvocationId;
 -    else if (semanticUpperCase == "SV_GROUPTHREADID")
 -        qualifier.builtIn = EbvLocalInvocationId;
 -    else if (semanticUpperCase == "SV_GROUPID")
 -        qualifier.builtIn = EbvWorkGroupId;
 -    else if (semanticUpperCase == "SV_DOMAINLOCATION")
 -        qualifier.builtIn = EbvTessCoord;
 -    else if (semanticUpperCase == "SV_DEPTH")
 -        qualifier.builtIn = EbvFragDepth;
 -    else if( semanticUpperCase == "SV_COVERAGE")
 -        qualifier.builtIn = EbvSampleMask;
 -
 -    // TODO, these need to get refined to be more specific
 -    else if( semanticUpperCase == "SV_DEPTHGREATEREQUAL")
 -        qualifier.builtIn = EbvFragDepthGreater;
 -    else if( semanticUpperCase == "SV_DEPTHLESSEQUAL")
 -        qualifier.builtIn = EbvFragDepthLesser;
 -    else if( semanticUpperCase == "SV_STENCILREF")
 +    switch(builtIn) {
 +    case EbvPosition:
 +        if (language == EShLangFragment)
 +            builtIn = EbvFragCoord;
 +        break;
 +    case EbvStencilRef:
          error(loc, "unimplemented; need ARB_shader_stencil_export", "SV_STENCILREF", "");
 -    else if( semanticUpperCase == "SV_GROUPINDEX")
 -        error(loc, "unimplemented", "SV_GROUPINDEX", "");
 +        break;
 +    default:
 +        break;
 +    }
 +
 +    qualifier.builtIn = builtIn;
++    qualifier.semanticName = intermediate.addSemanticName(semanticUpperCase);
  }
  
  //