From: John Kessenich Date: Wed, 15 Mar 2017 03:49:42 +0000 (-0600) Subject: Merge branch 'semantic_handling' of https://github.com/TiemoJung/glslang into TiemoJu... X-Git-Tag: submit/tizen/20180320.075658^2~434^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2dc50ff372c9047afc25df026149675ba471cd13;p=platform%2Fupstream%2Fglslang.git Merge branch 'semantic_handling' of https://github.com/TiemoJung/glslang into TiemoJung-semantic_handling --- 2dc50ff372c9047afc25df026149675ba471cd13 diff --cc glslang/MachineIndependent/iomapper.cpp index 07aa4762,9deac857..a478a2ca --- a/glslang/MachineIndependent/iomapper.cpp +++ b/glslang/MachineIndependent/iomapper.cpp @@@ -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); } } diff --cc hlsl/hlslParseHelper.cpp index 3c88d47b,89e89dec..358f9c56 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@@ -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); } //