Merge branch 'HLSL_Semantic_Mapping' of https://github.com/dankbaker/glslang into dankbaker-HLSL_Semantic_Mapping
This commit is contained in:
		
						commit
						81d4714908
					
				@ -2,5 +2,5 @@
 | 
				
			|||||||
// For the version, it uses the latest git tag followed by the number of commits.
 | 
					// 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).
 | 
					// For the date, it uses the current date (when then script is run).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GLSLANG_REVISION "Overload400-PrecQual.1444"
 | 
					#define GLSLANG_REVISION "Overload400-PrecQual.1447"
 | 
				
			||||||
#define GLSLANG_DATE "28-Aug-2016"
 | 
					#define GLSLANG_DATE "29-Aug-2016"
 | 
				
			||||||
 | 
				
			|||||||
@ -2670,7 +2670,7 @@ void HlslGrammar::acceptPostDecls(TType& type)
 | 
				
			|||||||
                parseContext.handleRegister(registerDesc.loc, type, profile.string, *registerDesc.string, subComponent);
 | 
					                parseContext.handleRegister(registerDesc.loc, type, profile.string, *registerDesc.string, subComponent);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                // semantic, in idToken.string
 | 
					                // semantic, in idToken.string
 | 
				
			||||||
                parseContext.handleSemantic(type, *idToken.string);
 | 
					                parseContext.handleSemantic(idToken.loc, type, *idToken.string);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (acceptTokenClass(EHTokLeftAngle)) {
 | 
					        } else if (acceptTokenClass(EHTokLeftAngle)) {
 | 
				
			||||||
            // TODO: process annotations, just accepting them for now
 | 
					            // TODO: process annotations, just accepting them for now
 | 
				
			||||||
 | 
				
			|||||||
@ -755,14 +755,20 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    inEntrypoint = (function.getName() == intermediate.getEntryPoint().c_str());
 | 
					    inEntrypoint = (function.getName() == intermediate.getEntryPoint().c_str());
 | 
				
			||||||
    if (inEntrypoint) {
 | 
					    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++) {
 | 
					        for (int i = 0; i < function.getParamCount(); i++) {
 | 
				
			||||||
            if (function[i].type->getQualifier().storage == EvqIn ||
 | 
					            if (function[i].type->getQualifier().isParamInput()) {
 | 
				
			||||||
                function[i].type->getQualifier().storage == EvqConstReadOnly)
 | 
					                if (function[i].type->getQualifier().builtIn == EbvNone)
 | 
				
			||||||
 | 
					                    function[i].type->getQualifier().layoutLocation = inCount++;
 | 
				
			||||||
                function[i].type->getQualifier().storage = EvqVaryingIn;
 | 
					                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;
 | 
					                function[i].type->getQualifier().storage = EvqVaryingOut;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // return value is actually shader-scoped output (out)
 | 
					        // return value is actually shader-scoped output (out)
 | 
				
			||||||
        if (function.getType().getBasicType() != EbtVoid) {
 | 
					        if (function.getType().getBasicType() != EbtVoid) {
 | 
				
			||||||
@ -2287,32 +2293,117 @@ TFunction* HlslParseContext::handleConstructorCall(const TSourceLoc& loc, const
 | 
				
			|||||||
// Handle seeing a "COLON semantic" at the end of a type declaration,
 | 
					// Handle seeing a "COLON semantic" at the end of a type declaration,
 | 
				
			||||||
// by updating the type according to the semantic.
 | 
					// 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
 | 
					    // 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
 | 
					    // The following sketches what needs to be done, but can't be right
 | 
				
			||||||
    // without taking into account stage and input/output.
 | 
					    // without taking into account stage and input/output.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (semantic == "PSIZE")
 | 
					    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
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    bool bParseDX9 = false;
 | 
				
			||||||
 | 
					    if (bParseDX9) {
 | 
				
			||||||
 | 
					        if (semanticUpperCase == "PSIZE")
 | 
				
			||||||
            type.getQualifier().builtIn = EbvPointSize;
 | 
					            type.getQualifier().builtIn = EbvPointSize;
 | 
				
			||||||
    else if (semantic == "POSITION")
 | 
					 | 
				
			||||||
        type.getQualifier().builtIn = EbvPosition;
 | 
					 | 
				
			||||||
        else if (semantic == "FOG")
 | 
					        else if (semantic == "FOG")
 | 
				
			||||||
            type.getQualifier().builtIn = EbvFogFragCoord;
 | 
					            type.getQualifier().builtIn = EbvFogFragCoord;
 | 
				
			||||||
    else if (semantic == "DEPTH" || semantic == "SV_Depth")
 | 
					        else if (semanticUpperCase == "DEPTH")
 | 
				
			||||||
            type.getQualifier().builtIn = EbvFragDepth;
 | 
					            type.getQualifier().builtIn = EbvFragDepth;
 | 
				
			||||||
    else if (semantic == "VFACE" || semantic == "SV_IsFrontFace")
 | 
					        else if (semanticUpperCase == "VFACE")
 | 
				
			||||||
            type.getQualifier().builtIn = EbvFace;
 | 
					            type.getQualifier().builtIn = EbvFace;
 | 
				
			||||||
    else if (semantic == "VPOS" || semantic == "SV_Position")
 | 
					        else if (semanticUpperCase == "VPOS")
 | 
				
			||||||
            type.getQualifier().builtIn = EbvFragCoord;
 | 
					            type.getQualifier().builtIn = EbvFragCoord;
 | 
				
			||||||
    else if (semantic == "SV_ClipDistance")
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //SV Position has a different meaning in vertex vs fragment
 | 
				
			||||||
 | 
					    if (semanticUpperCase == "SV_POSITION" && language != EShLangFragment)
 | 
				
			||||||
 | 
					        type.getQualifier().builtIn = EbvPosition;
 | 
				
			||||||
 | 
					    else if (semanticUpperCase == "SV_POSITION" && language == EShLangFragment)
 | 
				
			||||||
 | 
					        type.getQualifier().builtIn = EbvFragCoord;
 | 
				
			||||||
 | 
					    else if (semanticUpperCase == "SV_CLIPDISTANCE")
 | 
				
			||||||
        type.getQualifier().builtIn = EbvClipDistance;
 | 
					        type.getQualifier().builtIn = EbvClipDistance;
 | 
				
			||||||
    else if (semantic == "SV_CullDistance")
 | 
					    else if (semanticUpperCase == "SV_CULLDISTANCE")
 | 
				
			||||||
        type.getQualifier().builtIn = EbvCullDistance;
 | 
					        type.getQualifier().builtIn = EbvCullDistance;
 | 
				
			||||||
    else if (semantic == "SV_VertexID")
 | 
					    else if (semanticUpperCase == "SV_VERTEXID")
 | 
				
			||||||
        type.getQualifier().builtIn = EbvVertexId;
 | 
					        type.getQualifier().builtIn = EbvVertexIndex;
 | 
				
			||||||
    else if (semantic == "SV_ViewportArrayIndex")
 | 
					    else if (semanticUpperCase == "SV_VIEWPORTARRAYINDEX")
 | 
				
			||||||
        type.getQualifier().builtIn = EbvViewportIndex;
 | 
					        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", "");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
				
			|||||||
@ -95,7 +95,7 @@ public:
 | 
				
			|||||||
    TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
 | 
					    TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
 | 
				
			||||||
    void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
 | 
					    void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
 | 
				
			||||||
    TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
 | 
					    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,
 | 
					    void handlePackOffset(const TSourceLoc&, TType& type, const glslang::TString& location,
 | 
				
			||||||
                          const glslang::TString* component);
 | 
					                          const glslang::TString* component);
 | 
				
			||||||
    void handleRegister(const TSourceLoc&, TType& type, const glslang::TString* profile, const glslang::TString& desc,
 | 
					    void handleRegister(const TSourceLoc&, TType& type, const glslang::TString* profile, const glslang::TString& desc,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user