From 37827023c480a3845d9264c987708f5675d85536 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 8 Mar 2013 19:26:11 +0000 Subject: [PATCH] Add warning-suppression flag. Combined with relaxed errors, so an enum can be used instead of many bools. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20818 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- StandAlone/StandAlone.cpp | 2 +- glslang/MachineIndependent/ParseHelper.cpp | 4 ++-- glslang/MachineIndependent/ParseHelper.h | 4 ++-- glslang/MachineIndependent/ShaderLang.cpp | 4 ++-- glslang/MachineIndependent/Versions.cpp | 2 +- glslang/MachineIndependent/glslang.l | 12 ++++++------ glslang/Public/ShaderLang.h | 15 ++++++++++++--- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index e397d36..4544664 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, false, false); + ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, EShMsgDefault); #ifdef MEASURE_MEMORY GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 0850a1f..001755f 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -40,11 +40,11 @@ #include TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, EProfile p, EShLanguage L, TInfoSink& is, - bool fc, bool rc) : + bool fc, EShMessages m) : 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), forwardCompatible(fc), relaxedChecking(rc), + version(v), profile(p), forwardCompatible(fc), messages(m), contextPragma(true, false) { for (int type = 0; type < EbtNumTypes; ++type) diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index a9e7259..475a932 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -68,7 +68,7 @@ struct TPragma { // struct TParseContext { TParseContext(TSymbolTable&, TIntermediate&, int version, EProfile, EShLanguage, TInfoSink&, - bool forwardCompatible = false, bool relaxedChecking = false); + bool forwardCompatible = false, EShMessages messages = EShMsgDefault); TIntermediate& intermediate; // to hold and build a parse tree TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile TInfoSink& infoSink; @@ -86,7 +86,7 @@ struct TParseContext { 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 + EShMessages messages; // errors/warnings 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 ef658bc..9a27d0e 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -484,7 +484,7 @@ int ShCompile( int debugOptions, 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 + EShMessages messages // warnings/errors ) { if (!InitThread()) @@ -522,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, forwardCompatible, relaxedChecking); + TParseContext parseContext(symbolTable, intermediate, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages); if (! goodProfile) parseContext.error(1, "incorrect", "#version", ""); diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 16b651e..3aff363 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -135,7 +135,7 @@ void TParseContext::checkDeprecated(int line, EProfile callingProfile, int depVe if (forwardCompatible) { error(line, "deprecated, may be removed in future release", featureDesc, ""); recover(); - } else if (! relaxedChecking) { + } else if (! (messages & EShMsgSuppressWarnings)) { 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 310f61e..48a7a96 100644 --- a/glslang/MachineIndependent/glslang.l +++ b/glslang/MachineIndependent/glslang.l @@ -572,7 +572,7 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - if (pc.futureCompatibility) { + if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) { pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno); } @@ -586,7 +586,7 @@ 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); - if (pc.futureCompatibility) { + if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) { 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); } @@ -609,7 +609,7 @@ int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* p pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - if (pc.futureCompatibility) { + if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) { pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno); } @@ -624,7 +624,7 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - if (pc.futureCompatibility) { + if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) { pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno); } @@ -644,7 +644,7 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int pyylval->lex.line = line; pyylval->lex.string = NewPoolTString(text); - if (pc.futureCompatibility) { + if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) { pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno); } @@ -695,7 +695,7 @@ void CPPWarningToInfoLog(const char *msg) { TParseContext& pc = *((TParseContext *)cpp->pC); - if (! pc.relaxedChecking) + if (! (pc.messages & EShMsgSuppressWarnings)) pc.infoSink.info.message(EPrefixWarning, msg, yylineno); } diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index f60388d..01b204c 100644 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -108,6 +108,15 @@ typedef enum { } EShOptimizationLevel; // +// Message choices for what errors and warnings are given. +// +enum EShMessages { + EShMsgDefault = 0, // default is to give all required errors and extra warnings + EShMsgRelaxedErrors = (1 << 0), // be liberal in accepting input + EShMsgSuppressWarnings = (1 << 1) // suppress all warnings, except those required by the specification +}; + +// // Build a table for bindings. This can be used for locating // attributes, uniforms, globals, etc., as needed. // @@ -155,9 +164,9 @@ SH_IMPORT_EXPORT int ShCompile( const EShOptimizationLevel, const TBuiltInResource *resources, int debugOptions, - 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 + int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader + bool forwardCompatible = false, // give errors for use of deprecated features + EShMessages messages = EShMsgDefault // warnings and errors ); -- 2.7.4