diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
commit | 6630937e63ae5797487b86743a7733c8ae5cc42c (patch) | |
tree | 3d53dacf6430f9099e1fb20835881205de674961 /src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp | |
parent | 37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff) | |
parent | c7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff) |
Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp | 139 |
1 files changed, 72 insertions, 67 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp index ff8a69efa5..485e66670c 100644 --- a/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp +++ b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp @@ -12,17 +12,24 @@ #include "common/debug.h" #include "compiler/translator/Diagnostics.h" -static TBehavior getBehavior(const std::string& str) +namespace sh +{ + +static TBehavior getBehavior(const std::string &str) { const char kRequire[] = "require"; - const char kEnable[] = "enable"; + const char kEnable[] = "enable"; const char kDisable[] = "disable"; - const char kWarn[] = "warn"; - - if (str == kRequire) return EBhRequire; - else if (str == kEnable) return EBhEnable; - else if (str == kDisable) return EBhDisable; - else if (str == kWarn) return EBhWarn; + const char kWarn[] = "warn"; + + if (str == kRequire) + return EBhRequire; + else if (str == kEnable) + return EBhEnable; + else if (str == kDisable) + return EBhDisable; + else if (str == kWarn) + return EBhWarn; return EBhUndefined; } @@ -43,30 +50,29 @@ TDirectiveHandler::~TDirectiveHandler() { } -void TDirectiveHandler::handleError(const pp::SourceLocation& loc, - const std::string& msg) +void TDirectiveHandler::handleError(const pp::SourceLocation &loc, const std::string &msg) { - mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", ""); + mDiagnostics.error(loc, msg.c_str(), ""); } -void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, - const std::string& name, - const std::string& value, +void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc, + const std::string &name, + const std::string &value, bool stdgl) { if (stdgl) { const char kInvariant[] = "invariant"; - const char kAll[] = "all"; + const char kAll[] = "all"; if (name == kInvariant && value == kAll) { if (mShaderVersion == 300 && mShaderType == GL_FRAGMENT_SHADER) { // ESSL 3.00.4 section 4.6.1 - mDiagnostics.writeInfo( - pp::Diagnostics::PP_ERROR, loc, - "#pragma STDGL invariant(all) can not be used in fragment shader", name, value); + mDiagnostics.error( + loc, "#pragma STDGL invariant(all) can not be used in fragment shader", + name.c_str()); } mPragma.stdgl.invariantAll = true; } @@ -77,30 +83,39 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, } else { - const char kOptimize[] = "optimize"; - const char kDebug[] = "debug"; + const char kOptimize[] = "optimize"; + const char kDebug[] = "debug"; const char kDebugShaderPrecision[] = "webgl_debug_shader_precision"; - const char kOn[] = "on"; - const char kOff[] = "off"; + const char kOn[] = "on"; + const char kOff[] = "off"; bool invalidValue = false; if (name == kOptimize) { - if (value == kOn) mPragma.optimize = true; - else if (value == kOff) mPragma.optimize = false; - else invalidValue = true; + if (value == kOn) + mPragma.optimize = true; + else if (value == kOff) + mPragma.optimize = false; + else + invalidValue = true; } else if (name == kDebug) { - if (value == kOn) mPragma.debug = true; - else if (value == kOff) mPragma.debug = false; - else invalidValue = true; + if (value == kOn) + mPragma.debug = true; + else if (value == kOff) + mPragma.debug = false; + else + invalidValue = true; } else if (name == kDebugShaderPrecision && mDebugShaderPrecisionSupported) { - if (value == kOn) mPragma.debugShaderPrecision = true; - else if (value == kOff) mPragma.debugShaderPrecision = false; - else invalidValue = true; + if (value == kOn) + mPragma.debugShaderPrecision = true; + else if (value == kOff) + mPragma.debugShaderPrecision = false; + else + invalidValue = true; } else { @@ -110,24 +125,21 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, if (invalidValue) { - mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, - "invalid pragma value", value, - "'on' or 'off' expected"); + mDiagnostics.error(loc, "invalid pragma value - 'on' or 'off' expected", value.c_str()); } } } -void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, - const std::string& name, - const std::string& behavior) +void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc, + const std::string &name, + const std::string &behavior) { const char kExtAll[] = "all"; TBehavior behaviorVal = getBehavior(behavior); if (behaviorVal == EBhUndefined) { - mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, - "behavior", name, "invalid"); + mDiagnostics.error(loc, "behavior invalid", name.c_str()); return; } @@ -135,15 +147,11 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, { if (behaviorVal == EBhRequire) { - mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, - "extension", name, - "cannot have 'require' behavior"); + mDiagnostics.error(loc, "extension cannot have 'require' behavior", name.c_str()); } else if (behaviorVal == EBhEnable) { - mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, - "extension", name, - "cannot have 'enable' behavior"); + mDiagnostics.error(loc, "extension cannot have 'enable' behavior", name.c_str()); } else { @@ -154,36 +162,32 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, return; } - TExtensionBehavior::iterator iter = mExtensionBehavior.find(name); + TExtensionBehavior::iterator iter = mExtensionBehavior.find(GetExtensionByName(name.c_str())); if (iter != mExtensionBehavior.end()) { iter->second = behaviorVal; return; } - pp::Diagnostics::Severity severity = pp::Diagnostics::PP_ERROR; - switch (behaviorVal) { - case EBhRequire: - severity = pp::Diagnostics::PP_ERROR; - break; - case EBhEnable: - case EBhWarn: - case EBhDisable: - severity = pp::Diagnostics::PP_WARNING; - break; - default: - UNREACHABLE(); - break; + switch (behaviorVal) + { + case EBhRequire: + mDiagnostics.error(loc, "extension is not supported", name.c_str()); + break; + case EBhEnable: + case EBhWarn: + case EBhDisable: + mDiagnostics.warning(loc, "extension is not supported", name.c_str()); + break; + default: + UNREACHABLE(); + break; } - mDiagnostics.writeInfo(severity, loc, - "extension", name, "is not supported"); } -void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc, - int version) +void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version) { - if (version == 100 || - version == 300) + if (version == 100 || version == 300 || version == 310) { mShaderVersion = version; } @@ -192,7 +196,8 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc, std::stringstream stream; stream << version; std::string str = stream.str(); - mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, - "version number", str, "not supported"); + mDiagnostics.error(loc, "version number not supported", str.c_str()); } } + +} // namespace sh |