Add compilation mode flags for forward-compatible contexts and relaxed error checking. These initiate as arguments to ShCompile() and both default to being off.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20817 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
		
							parent
							
								
									9500dff05e
								
							
						
					
					
						commit
						4055816bc9
					
				| @ -259,7 +259,7 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons | |||||||
|     for (int i = 0; i < 1000; ++i) { |     for (int i = 0; i < 1000; ++i) { | ||||||
|         for (int j = 0; j < 100; ++j) |         for (int j = 0; j < 100; ++j) | ||||||
| #endif | #endif | ||||||
|             ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100); |             ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, false); | ||||||
| #ifdef MEASURE_MEMORY | #ifdef MEASURE_MEMORY | ||||||
| 
 | 
 | ||||||
|         GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); |         GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); | ||||||
|  | |||||||
| @ -178,7 +178,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod | |||||||
|             switch (getType().getBasicType()) { |             switch (getType().getBasicType()) { | ||||||
|             case EbtFloat: |             case EbtFloat: | ||||||
|                 if (rightUnionArray[i] == 0.0f) { |                 if (rightUnionArray[i] == 0.0f) { | ||||||
|                     infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine()); |  | ||||||
|                     newConstArray[i].setFConst(FLT_MAX); |                     newConstArray[i].setFConst(FLT_MAX); | ||||||
|                 } else |                 } else | ||||||
|                     newConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst()); |                     newConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst()); | ||||||
| @ -186,7 +185,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod | |||||||
| 
 | 
 | ||||||
|             case EbtInt: |             case EbtInt: | ||||||
|                 if (rightUnionArray[i] == 0) { |                 if (rightUnionArray[i] == 0) { | ||||||
|                     infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine()); |  | ||||||
|                     newConstArray[i].setIConst(0xEFFFFFFF); |                     newConstArray[i].setIConst(0xEFFFFFFF); | ||||||
|                 } else |                 } else | ||||||
|                     newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst()); |                     newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst()); | ||||||
|  | |||||||
| @ -39,11 +39,12 @@ | |||||||
| #include "osinclude.h" | #include "osinclude.h" | ||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
| 
 | 
 | ||||||
| TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, EProfile p, EShLanguage L, TInfoSink& is) :  | TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, EProfile p, EShLanguage L, TInfoSink& is,                              | ||||||
|  |                              bool fc, bool rc) :  | ||||||
|             intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), |             intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), | ||||||
|             recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), |             recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), | ||||||
|             switchNestingLevel(0), inTypeParen(false),  |             switchNestingLevel(0), inTypeParen(false),  | ||||||
|             version(v), profile(p), futureCompatibility(false), |             version(v), profile(p), forwardCompatible(fc), relaxedChecking(rc), | ||||||
|             contextPragma(true, false) |             contextPragma(true, false) | ||||||
| { | { | ||||||
|     for (int type = 0; type < EbtNumTypes; ++type) |     for (int type = 0; type < EbtNumTypes; ++type) | ||||||
| @ -438,6 +439,7 @@ bool TParseContext::reservedErrorCheck(int line, const TString& identifier) | |||||||
|         if (identifier.find("__") != TString::npos) { |         if (identifier.find("__") != TString::npos) { | ||||||
|             //error(line, "Two consecutive underscores are reserved for future use.", identifier.c_str(), "", "");
 |             //error(line, "Two consecutive underscores are reserved for future use.", identifier.c_str(), "", "");
 | ||||||
|             //return true;
 |             //return true;
 | ||||||
|  |             // TODO: make this an error
 | ||||||
|             infoSink.info.message(EPrefixWarning, "Two consecutive underscores are reserved for future use.", line); |             infoSink.info.message(EPrefixWarning, "Two consecutive underscores are reserved for future use.", line); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -67,7 +67,8 @@ struct TPragma { | |||||||
| // they can be passed to the parser without needing a global.
 | // they can be passed to the parser without needing a global.
 | ||||||
| //
 | //
 | ||||||
| struct TParseContext { | struct TParseContext { | ||||||
|     TParseContext(TSymbolTable&, TIntermediate&, int version, EProfile, EShLanguage, TInfoSink&); |     TParseContext(TSymbolTable&, TIntermediate&, int version, EProfile, EShLanguage, TInfoSink&, | ||||||
|  |                   bool forwardCompatible = false, bool relaxedChecking = false); | ||||||
|     TIntermediate& intermediate; // to hold and build a parse tree
 |     TIntermediate& intermediate; // to hold and build a parse tree
 | ||||||
|     TSymbolTable& symbolTable;   // symbol table that goes with the current language, version, and profile
 |     TSymbolTable& symbolTable;   // symbol table that goes with the current language, version, and profile
 | ||||||
|     TInfoSink& infoSink; |     TInfoSink& infoSink; | ||||||
| @ -82,8 +83,10 @@ struct TParseContext { | |||||||
|     const TType* currentFunctionType;  // the return type of the function that's currently being parsed
 |     const TType* currentFunctionType;  // the return type of the function that's currently being parsed
 | ||||||
|     bool functionReturnsValue;   // true if a non-void function has a return
 |     bool functionReturnsValue;   // true if a non-void function has a return
 | ||||||
| 
 | 
 | ||||||
|     int version;                 // the declared version in the shader (110 by default)
 |     int version;                 // version, updated by #version in the shader
 | ||||||
|     EProfile profile;            // the declared profile in the shader (core by default)
 |     EProfile profile;            // the declared profile in the shader (core by default)
 | ||||||
|  |     bool forwardCompatible;      // true if errors are to be given for use of deprecated features
 | ||||||
|  |     bool relaxedChecking;        // suppress warnings and reduce error checking
 | ||||||
|     bool futureCompatibility;    // true if requesting errors for future compatibility (false by default)
 |     bool futureCompatibility;    // true if requesting errors for future compatibility (false by default)
 | ||||||
|     TMap<TString, TBehavior> extensionBehavior;    // for each extension string, what it's current enablement is
 |     TMap<TString, TBehavior> extensionBehavior;    // for each extension string, what it's current enablement is
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -482,7 +482,9 @@ int ShCompile( | |||||||
|     const EShOptimizationLevel optLevel, |     const EShOptimizationLevel optLevel, | ||||||
|     const TBuiltInResource* resources, |     const TBuiltInResource* resources, | ||||||
|     int debugOptions, |     int debugOptions, | ||||||
|     int defaultVersion |     int defaultVersion,        // use 100 for ES environment, 110 for desktop
 | ||||||
|  |     bool forwardCompatible,    // give errors for use of deprecated features
 | ||||||
|  |     bool relaxedChecking       // no warnings, reduced errors
 | ||||||
|     ) |     ) | ||||||
| { | { | ||||||
|     if (!InitThread()) |     if (!InitThread()) | ||||||
| @ -520,7 +522,7 @@ int ShCompile( | |||||||
|     // they get popped again further down.
 |     // they get popped again further down.
 | ||||||
|     AddContextSpecificSymbols(resources, compiler->infoSink, &symbolTable, version, profile, compiler->getLanguage()); |     AddContextSpecificSymbols(resources, compiler->infoSink, &symbolTable, version, profile, compiler->getLanguage()); | ||||||
| 
 | 
 | ||||||
|     TParseContext parseContext(symbolTable, intermediate, version, profile, compiler->getLanguage(), compiler->infoSink); |     TParseContext parseContext(symbolTable, intermediate, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, relaxedChecking); | ||||||
|      |      | ||||||
|     if (! goodProfile) |     if (! goodProfile) | ||||||
|         parseContext.error(1, "incorrect", "#version", ""); |         parseContext.error(1, "incorrect", "#version", ""); | ||||||
|  | |||||||
| @ -132,10 +132,10 @@ void TParseContext::checkDeprecated(int line, EProfile callingProfile, int depVe | |||||||
| { | { | ||||||
|     if (profile == callingProfile) { |     if (profile == callingProfile) { | ||||||
|         if (version >= depVersion) { |         if (version >= depVersion) { | ||||||
|             if (futureCompatibility) { |             if (forwardCompatible) { | ||||||
|                 error(line, "deprecated, may be removed in future release", featureDesc, ""); |                 error(line, "deprecated, may be removed in future release", featureDesc, ""); | ||||||
|                 recover(); |                 recover(); | ||||||
|             } else { |             } else if (! relaxedChecking) { | ||||||
|                 infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " + |                 infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " + | ||||||
|                                                        String(depVersion) + "; may be removed in future release").c_str(), line); |                                                        String(depVersion) + "; may be removed in future release").c_str(), line); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -572,8 +572,10 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te | |||||||
| 
 | 
 | ||||||
|     pyylval->lex.line = line; |     pyylval->lex.line = line; | ||||||
|     pyylval->lex.string = NewPoolTString(text); |     pyylval->lex.string = NewPoolTString(text); | ||||||
|     pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); |     if (pc.futureCompatibility) { | ||||||
|     pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno); |         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); | ||||||
|  |         pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); |     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); | ||||||
| } | } | ||||||
| @ -584,8 +586,10 @@ int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char* | |||||||
|         pc.profile != EEsProfile && pc.version < version) { |         pc.profile != EEsProfile && pc.version < version) { | ||||||
|             pyylval->lex.line = yylineno; |             pyylval->lex.line = yylineno; | ||||||
|             pyylval->lex.string = NewPoolTString(yytext); |             pyylval->lex.string = NewPoolTString(yytext); | ||||||
|             pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); |             if (pc.futureCompatibility) { | ||||||
|             pc.infoSink.info.message(EPrefixWarning, "future reserved word in ES 300 and keyword in GLSL", yylineno); |                 pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); | ||||||
|  |                 pc.infoSink.info.message(EPrefixWarning, "future reserved word in ES 300 and keyword in GLSL", yylineno); | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); |             return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); | ||||||
|     } else if (pc.profile == EEsProfile && pc.version >= 300) |     } else if (pc.profile == EEsProfile && pc.version >= 300) | ||||||
| @ -605,8 +609,10 @@ int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* p | |||||||
| 
 | 
 | ||||||
|     pyylval->lex.line = line; |     pyylval->lex.line = line; | ||||||
|     pyylval->lex.string = NewPoolTString(text); |     pyylval->lex.string = NewPoolTString(text); | ||||||
|     pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); |     if (pc.futureCompatibility) { | ||||||
|     pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno); |         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); | ||||||
|  |         pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); |     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); | ||||||
| } | } | ||||||
| @ -618,8 +624,10 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in | |||||||
| 
 | 
 | ||||||
|     pyylval->lex.line = line; |     pyylval->lex.line = line; | ||||||
|     pyylval->lex.string = NewPoolTString(text); |     pyylval->lex.string = NewPoolTString(text); | ||||||
|     pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); |     if (pc.futureCompatibility) { | ||||||
|     pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno); |         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); | ||||||
|  |         pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); |     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); | ||||||
| } | } | ||||||
| @ -636,8 +644,10 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int | |||||||
| 
 | 
 | ||||||
|     pyylval->lex.line = line; |     pyylval->lex.line = line; | ||||||
|     pyylval->lex.string = NewPoolTString(text); |     pyylval->lex.string = NewPoolTString(text); | ||||||
|     pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); |     if (pc.futureCompatibility) { | ||||||
|     pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno); |         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); | ||||||
|  |         pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); |     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol); | ||||||
| } | } | ||||||
| @ -685,7 +695,8 @@ void CPPWarningToInfoLog(const char *msg) | |||||||
| { | { | ||||||
|     TParseContext& pc = *((TParseContext *)cpp->pC); |     TParseContext& pc = *((TParseContext *)cpp->pC); | ||||||
| 
 | 
 | ||||||
|     pc.infoSink.info.message(EPrefixWarning, msg, yylineno); |     if (! pc.relaxedChecking) | ||||||
|  |         pc.infoSink.info.message(EPrefixWarning, msg, yylineno); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CPPShInfoLogMsg(const char *msg) | void CPPShInfoLogMsg(const char *msg) | ||||||
| @ -910,6 +921,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior) | |||||||
|                 pc.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); |                 pc.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|  | 
 | ||||||
|             return; |             return; | ||||||
|         } else |         } else | ||||||
|             iter->second = behaviorVal; |             iter->second = behaviorVal; | ||||||
|  | |||||||
| @ -155,7 +155,9 @@ SH_IMPORT_EXPORT int ShCompile( | |||||||
|     const EShOptimizationLevel, |     const EShOptimizationLevel, | ||||||
|     const TBuiltInResource *resources, |     const TBuiltInResource *resources, | ||||||
|     int debugOptions, |     int debugOptions, | ||||||
|     int defaultVersion = 110 // use 100 for ES environment
 |     int defaultVersion = 110,         // use 100 for ES environment, overridden by #version in shader
 | ||||||
|  |     bool forwardCompatible = false,   // give errors for use of deprecated features
 | ||||||
|  |     bool relaxedChecking = false      // no warnings, reduced errors
 | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 John Kessenich
						John Kessenich