diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 516f434a..6577370b 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -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.1444" -#define GLSLANG_DATE "28-Aug-2016" +#define GLSLANG_REVISION "Overload400-PrecQual.1447" +#define GLSLANG_DATE "29-Aug-2016" diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp index 9de3a277..3669b520 100755 --- a/hlsl/hlslGrammar.cpp +++ b/hlsl/hlslGrammar.cpp @@ -2670,7 +2670,7 @@ void HlslGrammar::acceptPostDecls(TType& type) parseContext.handleRegister(registerDesc.loc, type, profile.string, *registerDesc.string, subComponent); } else { // semantic, in idToken.string - parseContext.handleSemantic(type, *idToken.string); + parseContext.handleSemantic(idToken.loc, type, *idToken.string); } } else if (acceptTokenClass(EHTokLeftAngle)) { // TODO: process annotations, just accepting them for now diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 7ca93d07..02ff5148 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -755,13 +755,19 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l inEntrypoint = (function.getName() == intermediate.getEntryPoint().c_str()); if (inEntrypoint) { - // in parameters are actually shader-scoped inputs (in) + // parameters are actually shader-scoped inputs and outputs (in or out) + unsigned int inCount = 0; + unsigned int outCount = 0; for (int i = 0; i < function.getParamCount(); i++) { - if (function[i].type->getQualifier().storage == EvqIn || - function[i].type->getQualifier().storage == EvqConstReadOnly) + if (function[i].type->getQualifier().isParamInput()) { + if (function[i].type->getQualifier().builtIn == EbvNone) + function[i].type->getQualifier().layoutLocation = inCount++; function[i].type->getQualifier().storage = EvqVaryingIn; - else + } else { + if (function[i].type->getQualifier().builtIn == EbvNone && language != EShLangFragment) + function[i].type->getQualifier().layoutLocation = outCount++; function[i].type->getQualifier().storage = EvqVaryingOut; + } } // return value is actually shader-scoped output (out) @@ -2287,32 +2293,117 @@ TFunction* HlslParseContext::handleConstructorCall(const TSourceLoc& loc, const // Handle seeing a "COLON semantic" at the end of a type declaration, // by updating the type according to the semantic. // -void HlslParseContext::handleSemantic(TType& type, const TString& semantic) +void HlslParseContext::handleSemantic(TSourceLoc loc, TType& type, 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 - if (semantic == "PSIZE") - type.getQualifier().builtIn = EbvPointSize; - else if (semantic == "POSITION") + + bool bParseDX9 = false; + if (bParseDX9) { + if (semanticUpperCase == "PSIZE") + type.getQualifier().builtIn = EbvPointSize; + else if (semantic == "FOG") + type.getQualifier().builtIn = EbvFogFragCoord; + else if (semanticUpperCase == "DEPTH") + type.getQualifier().builtIn = EbvFragDepth; + else if (semanticUpperCase == "VFACE") + type.getQualifier().builtIn = EbvFace; + else if (semanticUpperCase == "VPOS") + type.getQualifier().builtIn = EbvFragCoord; + } + + //SV Position has a different meaning in vertex vs fragment + if (semanticUpperCase == "SV_POSITION" && language != EShLangFragment) type.getQualifier().builtIn = EbvPosition; - else if (semantic == "FOG") - type.getQualifier().builtIn = EbvFogFragCoord; - else if (semantic == "DEPTH" || semantic == "SV_Depth") - type.getQualifier().builtIn = EbvFragDepth; - else if (semantic == "VFACE" || semantic == "SV_IsFrontFace") - type.getQualifier().builtIn = EbvFace; - else if (semantic == "VPOS" || semantic == "SV_Position") + else if (semanticUpperCase == "SV_POSITION" && language == EShLangFragment) type.getQualifier().builtIn = EbvFragCoord; - else if (semantic == "SV_ClipDistance") + else if (semanticUpperCase == "SV_CLIPDISTANCE") type.getQualifier().builtIn = EbvClipDistance; - else if (semantic == "SV_CullDistance") + else if (semanticUpperCase == "SV_CULLDISTANCE") type.getQualifier().builtIn = EbvCullDistance; - else if (semantic == "SV_VertexID") - type.getQualifier().builtIn = EbvVertexId; - else if (semantic == "SV_ViewportArrayIndex") + else if (semanticUpperCase == "SV_VERTEXID") + type.getQualifier().builtIn = EbvVertexIndex; + else if (semanticUpperCase == "SV_VIEWPORTARRAYINDEX") type.getQualifier().builtIn = EbvViewportIndex; + else if (semanticUpperCase == "SV_TESSFACTOR") + type.getQualifier().builtIn = EbvTessLevelOuter; + + //Targets are defined 0-7 + else if (semanticUpperCase == "SV_TARGET") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 0; + } else if (semanticUpperCase == "SV_TARGET0") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 0; + } else if (semanticUpperCase == "SV_TARGET1") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 1; + } else if (semanticUpperCase == "SV_TARGET2") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 2; + } else if (semanticUpperCase == "SV_TARGET3") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 3; + } else if (semanticUpperCase == "SV_TARGET4") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 4; + } else if (semanticUpperCase == "SV_TARGET5") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 5; + } else if (semanticUpperCase == "SV_TARGET6") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 6; + } else if (semanticUpperCase == "SV_TARGET7") { + type.getQualifier().builtIn = EbvNone; + type.getQualifier().layoutLocation = 7; + } else if (semanticUpperCase == "SV_SAMPLEINDEX") + type.getQualifier().builtIn = EbvSampleId; + else if (semanticUpperCase == "SV_RENDERTARGETARRAYINDEX") + type.getQualifier().builtIn = EbvLayer; + else if (semanticUpperCase == "SV_PRIMITIVEID") + type.getQualifier().builtIn = EbvPrimitiveId; + else if (semanticUpperCase == "SV_OUTPUTCONTROLPOINTID") + type.getQualifier().builtIn = EbvInvocationId; + else if (semanticUpperCase == "SV_ISFRONTFACE") + type.getQualifier().builtIn = EbvFace; + else if (semanticUpperCase == "SV_INSTANCEID") + type.getQualifier().builtIn = EbvInstanceIndex; + else if (semanticUpperCase == "SV_INSIDETESSFACTOR") + type.getQualifier().builtIn = EbvTessLevelInner; + else if (semanticUpperCase == "SV_GSINSTANCEID") + type.getQualifier().builtIn = EbvInvocationId; + else if (semanticUpperCase == "SV_GROUPTHREADID") + type.getQualifier().builtIn = EbvLocalInvocationId; + else if (semanticUpperCase == "SV_GROUPID") + type.getQualifier().builtIn = EbvWorkGroupId; + else if (semanticUpperCase == "SV_DOMAINLOCATION") + type.getQualifier().builtIn = EbvTessCoord; + else if (semanticUpperCase == "SV_DEPTH") + type.getQualifier().builtIn = EbvFragDepth; + + //TODO, these need to get refined to be more specific + else if( semanticUpperCase == "SV_DEPTHGREATEREQUAL") { + type.getQualifier().builtIn = EbvFragDepth; + warn(loc, "depth mode unimplemented", "SV_DEPTHGREATEREQUAL", ""); + } else if( semanticUpperCase == "SV_DEPTHLESSEQUAL") { + type.getQualifier().builtIn = EbvFragDepth; + warn(loc, "depth mode unimplemented", "SV_DEPTHLESSEQUAL", ""); + } else if( semanticUpperCase == "SV_STENCILREF") + error(loc, "unimplemented", "SV_STENCILREF", ""); + else if( semanticUpperCase == "SV_COVERAGE") + error(loc, "unimplemented", "SV_COVERAGE", ""); } // diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h index 4f8a2e9a..50f3e8b2 100755 --- a/hlsl/hlslParseHelper.h +++ b/hlsl/hlslParseHelper.h @@ -95,7 +95,7 @@ public: TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const; void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&); TFunction* handleConstructorCall(const TSourceLoc&, const TType&); - void handleSemantic(TType& type, const TString& semantic); + void handleSemantic(TSourceLoc, TType& type, const TString& semantic); void handlePackOffset(const TSourceLoc&, TType& type, const glslang::TString& location, const glslang::TString* component); void handleRegister(const TSourceLoc&, TType& type, const glslang::TString* profile, const glslang::TString& desc,