diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index a797295e..e397d363 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -259,7 +259,7 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons for (int i = 0; i < 1000; ++i) { for (int j = 0; j < 100; ++j) #endif - ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100); + ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, false); #ifdef MEASURE_MEMORY GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp index df09a1c0..6ae811fc 100644 --- a/glslang/MachineIndependent/Constant.cpp +++ b/glslang/MachineIndependent/Constant.cpp @@ -178,7 +178,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod switch (getType().getBasicType()) { case EbtFloat: if (rightUnionArray[i] == 0.0f) { - infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine()); newConstArray[i].setFConst(FLT_MAX); } else newConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst()); @@ -186,7 +185,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod case EbtInt: if (rightUnionArray[i] == 0) { - infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine()); newConstArray[i].setIConst(0xEFFFFFFF); } else newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst()); diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 7b597e43..0850a1f5 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -39,11 +39,12 @@ #include "osinclude.h" #include -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), recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), switchNestingLevel(0), inTypeParen(false), - version(v), profile(p), futureCompatibility(false), + version(v), profile(p), forwardCompatible(fc), relaxedChecking(rc), contextPragma(true, false) { for (int type = 0; type < EbtNumTypes; ++type) @@ -438,6 +439,7 @@ bool TParseContext::reservedErrorCheck(int line, const TString& identifier) if (identifier.find("__") != TString::npos) { //error(line, "Two consecutive underscores are reserved for future use.", identifier.c_str(), "", ""); //return true; + // TODO: make this an error infoSink.info.message(EPrefixWarning, "Two consecutive underscores are reserved for future use.", line); return false; } diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 97bca382..a9e7259e 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -67,7 +67,8 @@ struct TPragma { // they can be passed to the parser without needing a global. // 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 TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile TInfoSink& infoSink; @@ -82,8 +83,10 @@ struct TParseContext { 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 - 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) + 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) TMap extensionBehavior; // for each extension string, what it's current enablement is diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index 0e34d177..ef658bca 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -482,7 +482,9 @@ int ShCompile( const EShOptimizationLevel optLevel, const TBuiltInResource* resources, 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()) @@ -520,7 +522,7 @@ int ShCompile( // they get popped again further down. 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) parseContext.error(1, "incorrect", "#version", ""); diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 3ab3475a..16b651e7 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -132,10 +132,10 @@ void TParseContext::checkDeprecated(int line, EProfile callingProfile, int depVe { if (profile == callingProfile) { if (version >= depVersion) { - if (futureCompatibility) { + if (forwardCompatible) { error(line, "deprecated, may be removed in future release", featureDesc, ""); recover(); - } else { + } else if (! relaxedChecking) { infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " + String(depVersion) + "; may be removed in future release").c_str(), line); } diff --git a/glslang/MachineIndependent/glslang.l b/glslang/MachineIndependent/glslang.l index caf143ee..310f61ed 100644 --- a/glslang/MachineIndependent/glslang.l +++ b/glslang/MachineIndependent/glslang.l @@ -572,8 +572,10 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); - pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno); + if (pc.futureCompatibility) { + 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); } @@ -584,8 +586,10 @@ int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char* pc.profile != EEsProfile && pc.version < version) { pyylval->lex.line = yylineno; pyylval->lex.string = NewPoolTString(yytext); - 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); + if (pc.futureCompatibility) { + 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); } 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.string = NewPoolTString(text); - pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); - pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno); + if (pc.futureCompatibility) { + 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); } @@ -618,8 +624,10 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); - pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno); + if (pc.futureCompatibility) { + 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); } @@ -636,8 +644,10 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); - pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno); + if (pc.futureCompatibility) { + 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); } @@ -685,7 +695,8 @@ void CPPWarningToInfoLog(const char *msg) { 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) @@ -910,6 +921,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior) pc.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); break; } + return; } else iter->second = behaviorVal; diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index b97261aa..f60388d1 100644 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -155,7 +155,9 @@ SH_IMPORT_EXPORT int ShCompile( const EShOptimizationLevel, const TBuiltInResource *resources, 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 );