diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-11-28 11:56:07 +0000 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-11-28 11:56:07 +0000 |
commit | ce92dbbbc0883074a66fd5dfbf679f3492237d0f (patch) | |
tree | 8368c2dafa4858f870ed7ed5e3e892f614ad87c5 | |
parent | 98672c888e55b23181dcab11a359f805ebab6a36 (diff) | |
parent | a5e7bb8e41e934b48a70bb85f564ceb1810e7511 (diff) | |
download | angle_dx11-ce92dbbbc0883074a66fd5dfbf679f3492237d0f.tar.gz |
Merge from Chromium at DEPS revision 237746
This commit was generated by merge_to_master.py.
Change-Id: I833f5a91dcd06d119b577f09bbee05cb45ccd615
69 files changed, 687 insertions, 329 deletions
diff --git a/.gclient b/.gclient new file mode 100644 index 00000000..77bf7d28 --- /dev/null +++ b/.gclient @@ -0,0 +1,7 @@ +solutions = [ { + u'managed': False, + u'name': u'.', + u'url': u'https://chromium.googlesource.com/angle/angle', + u'custom_deps': { }, + u'deps_file': u'DEPS' +} ]
\ No newline at end of file @@ -13,6 +13,7 @@ TransGaming Inc. Adobe Systems Inc. Autodesk, Inc. +BlackBerry Limited Cloud Party, Inc. Intel Corporation Mozilla Corporation @@ -1,18 +1,18 @@ deps = { - "trunk/third_party/gyp": - "http://gyp.googlecode.com/svn/trunk@1564", + "third_party/gyp": + "http://gyp.googlecode.com/svn/trunk@1767", - "trunk/third_party/googletest": - "http://googletest.googlecode.com/svn/trunk@573", #release 1.6.0 + "third_party/googletest": + "http://googletest.googlecode.com/svn/trunk@629", - "trunk/third_party/googlemock": - "http://googlemock.googlecode.com/svn/trunk@387", #release 1.6.0 + "third_party/googlemock": + "http://googlemock.googlecode.com/svn/trunk@410", } hooks = [ { # A change to a .gyp, .gypi, or to GYP itself should run the generator. "pattern": ".", - "action": ["python", "trunk/build/gyp_angle"], + "action": ["python", "build/gyp_angle"], }, ] diff --git a/build/common.gypi b/build/common.gypi index 49156640..1c48170e 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -9,6 +9,8 @@ # angle_code is set to 0 for test code, sample code, and third party code. # When angle_code is 1, we build with additional warning flags on Mac and Linux. 'angle_code%': 0, + 'windows_sdk_path%': 'C:/Program Files (x86)/Windows Kits/8.0', + 'winsdk_arch%': 'x86', 'gcc_or_clang_warnings': [ '-Wall', '-Wchar-subscripts', @@ -81,7 +83,7 @@ # and utilities with console output. 'SubSystem': '1', # /SUBSYSTEM:CONSOLE 'AdditionalLibraryDirectories': [ - '$(ProgramFiles)/Windows Kits/8.0/Lib/win8/um/x86', + '<(windows_sdk_path)/Lib/win8/um/<(winsdk_arch)', ], 'AdditionalDependencies': [ 'kernel32.lib', @@ -101,7 +103,7 @@ }, 'VCLibrarianTool': { 'AdditionalLibraryDirectories': [ - '$(ProgramFiles)/Windows Kits/8.0/Lib/win8/um/x86', + '<(windows_sdk_path)/Lib/win8/um/<(winsdk_arch)', ], }, 'VCResourceCompilerTool': { @@ -109,8 +111,8 @@ }, }, 'msvs_system_include_dirs': [ - '$(ProgramFiles)/Windows Kits/8.0/Include/shared', - '$(ProgramFiles)/Windows Kits/8.0/Include/um', + '<(windows_sdk_path)/Include/shared', + '<(windows_sdk_path)/Include/um', ], }, # Common 'Debug': { diff --git a/build/gyp_angle b/build/gyp_angle index 2aa38a52..6533d367 100644 --- a/build/gyp_angle +++ b/build/gyp_angle @@ -25,7 +25,7 @@ if __name__ == '__main__': # Set the depth to get the top-level Makefile generated into the # correct directory. This only has an effect on Linux. args.append('--depth'); - args.append('./trunk'); + args.append('.'); # Add common.gypi to the include path. args.append('-I' + os.path.join(script_dir, 'common.gypi')) # Add all.gyp as the main gyp file to be generated. diff --git a/src/build_angle.gypi b/src/build_angle.gypi index 13c42f9e..d87ff4e6 100644 --- a/src/build_angle.gypi +++ b/src/build_angle.gypi @@ -369,6 +369,14 @@ ], } }, + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)', + 'files': [ + '<(windows_sdk_path)/Redist/D3D/<(winsdk_arch)/d3dcompiler_46.dll', + ], + }, + ], }, { 'target_name': 'libEGL', diff --git a/src/common/angleutils.h b/src/common/angleutils.h index 9761567f..7723f0fb 100644 --- a/src/common/angleutils.h +++ b/src/common/angleutils.h @@ -42,6 +42,20 @@ void SafeRelease(T& resource) } } +template <typename T> +void SafeDelete(T*& resource) +{ + delete resource; + resource = NULL; +} + +template <typename T> +void SafeDeleteArray(T*& resource) +{ + delete[] resource; + resource = NULL; +} + #if defined(_MSC_VER) #define snprintf _snprintf #endif diff --git a/src/common/version.h b/src/common/version.h index d917aa29..eb028574 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -1,7 +1,7 @@ #define MAJOR_VERSION 1 #define MINOR_VERSION 2 #define BUILD_VERSION 0 -#define BUILD_REVISION 2449 +#define BUILD_REVISION 2451 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/src/compiler/Diagnostics.cpp b/src/compiler/Diagnostics.cpp index 8a38c41a..1c1b9b5e 100644 --- a/src/compiler/Diagnostics.cpp +++ b/src/compiler/Diagnostics.cpp @@ -30,11 +30,11 @@ void TDiagnostics::writeInfo(Severity severity, TPrefixType prefix = EPrefixNone; switch (severity) { - case ERROR: + case PP_ERROR: ++mNumErrors; prefix = EPrefixError; break; - case WARNING: + case PP_WARNING: ++mNumWarnings; prefix = EPrefixWarning; break; diff --git a/src/compiler/DirectiveHandler.cpp b/src/compiler/DirectiveHandler.cpp index d1f6ab3a..6d3d831a 100644 --- a/src/compiler/DirectiveHandler.cpp +++ b/src/compiler/DirectiveHandler.cpp @@ -39,7 +39,7 @@ TDirectiveHandler::~TDirectiveHandler() void TDirectiveHandler::handleError(const pp::SourceLocation& loc, const std::string& msg) { - mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, msg, "", ""); + mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", ""); } void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, @@ -73,12 +73,12 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, } else { - mDiagnostics.report(pp::Diagnostics::UNRECOGNIZED_PRAGMA, loc, name); + mDiagnostics.report(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, loc, name); return; } if (invalidValue) - mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, + mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "invalid pragma value", value, "'on' or 'off' expected"); } @@ -92,7 +92,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, TBehavior behaviorVal = getBehavior(behavior); if (behaviorVal == EBhUndefined) { - mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, + mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "behavior", name, "invalid"); return; } @@ -101,13 +101,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, { if (behaviorVal == EBhRequire) { - mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, + mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name, "cannot have 'require' behavior"); } else if (behaviorVal == EBhEnable) { - mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, + mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name, "cannot have 'enable' behavior"); } @@ -127,15 +127,15 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, return; } - pp::Diagnostics::Severity severity = pp::Diagnostics::ERROR; + pp::Diagnostics::Severity severity = pp::Diagnostics::PP_ERROR; switch (behaviorVal) { case EBhRequire: - severity = pp::Diagnostics::ERROR; + severity = pp::Diagnostics::PP_ERROR; break; case EBhEnable: case EBhWarn: case EBhDisable: - severity = pp::Diagnostics::WARNING; + severity = pp::Diagnostics::PP_WARNING; break; default: UNREACHABLE(); @@ -155,7 +155,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc, std::stringstream stream; stream << version; std::string str = stream.str(); - mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, + mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "version number", str, "not supported"); } } diff --git a/src/compiler/ForLoopUnroll.h b/src/compiler/ForLoopUnroll.h index e800e25b..738b7692 100644 --- a/src/compiler/ForLoopUnroll.h +++ b/src/compiler/ForLoopUnroll.h @@ -4,6 +4,9 @@ // found in the LICENSE file. // +#ifndef COMPILER_FORLOOPUNROLL_H_ +#define COMPILER_FORLOOPUNROLL_H_ + #include "compiler/intermediate.h" struct TLoopIndexInfo { @@ -46,3 +49,4 @@ private: TVector<TLoopIndexInfo> mLoopIndexStack; }; +#endif diff --git a/src/compiler/InfoSink.h b/src/compiler/InfoSink.h index 68888381..be0ddffe 100644 --- a/src/compiler/InfoSink.h +++ b/src/compiler/InfoSink.h @@ -8,6 +8,7 @@ #define _INFOSINK_INCLUDED_ #include <math.h> +#include <stdlib.h> #include "compiler/Common.h" // Returns the fractional part of the given floating-point number. diff --git a/src/compiler/Intermediate.cpp b/src/compiler/Intermediate.cpp index 5bab2161..ef858215 100644 --- a/src/compiler/Intermediate.cpp +++ b/src/compiler/Intermediate.cpp @@ -804,9 +804,7 @@ bool TIntermSelection::replaceChildNode( // // Say whether or not an operation node changes the value of a variable. // -// Returns true if state is modified. -// -bool TIntermOperator::modifiesState() const +bool TIntermOperator::isAssignment() const { switch (op) { case EOpPostIncrement: diff --git a/src/compiler/NodeSearch.h b/src/compiler/NodeSearch.h new file mode 100644 index 00000000..27e471db --- /dev/null +++ b/src/compiler/NodeSearch.h @@ -0,0 +1,78 @@ +// +// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// NodeSearch.h: Utilities for searching translator node graphs +// + +#ifndef TRANSLATOR_NODESEARCH_H_ +#define TRANSLATOR_NODESEARCH_H_ + +namespace sh +{ + +template <class Parent> +class NodeSearchTraverser : public TIntermTraverser +{ + public: + NodeSearchTraverser() + : mFound(false) + {} + + bool found() const { return mFound; } + + static bool search(TIntermNode *node) + { + Parent searchTraverser; + node->traverse(&searchTraverser); + return searchTraverser.found(); + } + + protected: + bool mFound; +}; + +class FindDiscard : public NodeSearchTraverser<FindDiscard> +{ + public: + virtual bool visitBranch(Visit visit, TIntermBranch *node) + { + switch (node->getFlowOp()) + { + case EOpKill: + mFound = true; + break; + + default: break; + } + + return !mFound; + } +}; + +class FindSideEffectRewriting : public NodeSearchTraverser<FindSideEffectRewriting> +{ + public: + virtual bool visitBinary(Visit visit, TIntermBinary *node) + { + switch (node->getOp()) + { + case EOpLogicalOr: + case EOpLogicalAnd: + if (node->getRight()->hasSideEffects()) + { + mFound = true; + } + break; + + default: break; + } + + return !mFound; + } +}; + +} + +#endif // TRANSLATOR_NODESEARCH_H_ diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp index 79a373eb..53799dff 100644 --- a/src/compiler/OutputHLSL.cpp +++ b/src/compiler/OutputHLSL.cpp @@ -12,6 +12,7 @@ #include "compiler/InfoSink.h" #include "compiler/SearchSymbol.h" #include "compiler/UnfoldShortCircuit.h" +#include "compiler/NodeSearch.h" #include <algorithm> #include <cfloat> @@ -72,6 +73,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc mUsesAtan2_2 = false; mUsesAtan2_3 = false; mUsesAtan2_4 = false; + mUsesDiscardRewriting = false; mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1; @@ -196,6 +198,11 @@ void OutputHLSL::header() attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n"; } + if (mUsesDiscardRewriting) + { + out << "#define ANGLE_USES_DISCARD_REWRITING" << "\n"; + } + if (shaderType == SH_FRAGMENT_SHADER) { TExtensionBehavior::const_iterator iter = mContext.extensionBehavior().find("GL_EXT_draw_buffers"); @@ -1299,15 +1306,31 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) case EOpMatrixTimesVector: outputTriplet(visit, "mul(transpose(", "), ", ")"); break; case EOpMatrixTimesMatrix: outputTriplet(visit, "transpose(mul(transpose(", "), transpose(", ")))"); break; case EOpLogicalOr: - out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex(); - return false; + if (node->getRight()->hasSideEffects()) + { + out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex(); + return false; + } + else + { + outputTriplet(visit, "(", " || ", ")"); + return true; + } case EOpLogicalXor: mUsesXor = true; outputTriplet(visit, "xor(", ", ", ")"); break; case EOpLogicalAnd: - out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex(); - return false; + if (node->getRight()->hasSideEffects()) + { + out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex(); + return false; + } + else + { + outputTriplet(visit, "(", " && ", ")"); + return true; + } default: UNREACHABLE(); } @@ -1944,7 +1967,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) { mUnfoldShortCircuit->traverse(node->getCondition()); - out << "if("; + out << "if ("; node->getCondition()->traverse(this); @@ -1953,9 +1976,14 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) outputLineDirective(node->getLine().first_line); out << "{\n"; + bool discard = false; + if (node->getTrueBlock()) { traverseStatements(node->getTrueBlock()); + + // Detect true discard + discard = (discard || FindDiscard::search(node->getTrueBlock())); } outputLineDirective(node->getLine().first_line); @@ -1973,6 +2001,15 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) outputLineDirective(node->getFalseBlock()->getLine().first_line); out << ";\n}\n"; + + // Detect false discard + discard = (discard || FindDiscard::search(node->getFalseBlock())); + } + + // ANGLE issue 486: Detect problematic conditional discard + if (discard && FindSideEffectRewriting::search(node)) + { + mUsesDiscardRewriting = true; } } @@ -2070,7 +2107,9 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node) switch (node->getFlowOp()) { - case EOpKill: outputTriplet(visit, "discard;\n", "", ""); break; + case EOpKill: + outputTriplet(visit, "discard;\n", "", ""); + break; case EOpBreak: if (visit == PreVisit) { @@ -2293,7 +2332,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) if (!firstLoopFragment) { - out << "if(!Break"; + out << "if (!Break"; index->traverse(this); out << ") {\n"; } diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h index 49bc1376..586a76fb 100644 --- a/src/compiler/OutputHLSL.h +++ b/src/compiler/OutputHLSL.h @@ -125,6 +125,7 @@ class OutputHLSL : public TIntermTraverser bool mUsesAtan2_2; bool mUsesAtan2_3; bool mUsesAtan2_4; + bool mUsesDiscardRewriting; int mNumRenderTargets; diff --git a/src/compiler/ParseContext.cpp b/src/compiler/ParseContext.cpp index 9a279523..4db9c034 100644 --- a/src/compiler/ParseContext.cpp +++ b/src/compiler/ParseContext.cpp @@ -182,7 +182,7 @@ void TParseContext::error(const TSourceLoc& loc, pp::SourceLocation srcLoc; srcLoc.file = loc.first_file; srcLoc.line = loc.first_line; - diagnostics.writeInfo(pp::Diagnostics::ERROR, + diagnostics.writeInfo(pp::Diagnostics::PP_ERROR, srcLoc, reason, token, extraInfo); } @@ -193,7 +193,7 @@ void TParseContext::warning(const TSourceLoc& loc, pp::SourceLocation srcLoc; srcLoc.file = loc.first_file; srcLoc.line = loc.first_line; - diagnostics.writeInfo(pp::Diagnostics::WARNING, + diagnostics.writeInfo(pp::Diagnostics::PP_WARNING, srcLoc, reason, token, extraInfo); } diff --git a/src/compiler/UnfoldShortCircuit.cpp b/src/compiler/UnfoldShortCircuit.cpp index 47f0afca..5cfdd323 100644 --- a/src/compiler/UnfoldShortCircuit.cpp +++ b/src/compiler/UnfoldShortCircuit.cpp @@ -31,6 +31,14 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node) { TInfoSinkBase &out = mOutputHLSL->getBodyStream(); + // If our right node doesn't have side effects, we know we don't need to unfold this + // expression: there will be no short-circuiting side effects to avoid + // (note: unfolding doesn't depend on the left node -- it will always be evaluated) + if (!node->getRight()->hasSideEffects()) + { + return true; + } + switch (node->getOp()) { case EOpLogicalOr: @@ -49,7 +57,7 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node) mTemporaryIndex = i + 1; node->getLeft()->traverse(mOutputHLSL); out << ";\n"; - out << "if(!s" << i << ")\n" + out << "if (!s" << i << ")\n" "{\n"; mTemporaryIndex = i + 1; node->getRight()->traverse(this); @@ -80,7 +88,7 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node) mTemporaryIndex = i + 1; node->getLeft()->traverse(mOutputHLSL); out << ";\n"; - out << "if(s" << i << ")\n" + out << "if (s" << i << ")\n" "{\n"; mTemporaryIndex = i + 1; node->getRight()->traverse(this); @@ -115,7 +123,7 @@ bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node) mTemporaryIndex = i + 1; node->getCondition()->traverse(this); - out << "if("; + out << "if ("; mTemporaryIndex = i + 1; node->getCondition()->traverse(mOutputHLSL); out << ")\n" diff --git a/src/compiler/ValidateLimitations.cpp b/src/compiler/ValidateLimitations.cpp index 7b8b1c87..64969c48 100644 --- a/src/compiler/ValidateLimitations.cpp +++ b/src/compiler/ValidateLimitations.cpp @@ -457,7 +457,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node) bool ValidateLimitations::validateOperation(TIntermOperator* node, TIntermNode* operand) { // Check if loop index is modified in the loop body. - if (!withinLoopBody() || !node->modifiesState()) + if (!withinLoopBody() || !node->isAssignment()) return true; const TIntermSymbol* symbol = operand->getAsSymbolNode(); diff --git a/src/compiler/depgraph/DependencyGraphBuilder.cpp b/src/compiler/depgraph/DependencyGraphBuilder.cpp index d586cfd0..026e6d57 100644 --- a/src/compiler/depgraph/DependencyGraphBuilder.cpp +++ b/src/compiler/depgraph/DependencyGraphBuilder.cpp @@ -94,7 +94,7 @@ void TDependencyGraphBuilder::visitSymbol(TIntermSymbol* intermSymbol) bool TDependencyGraphBuilder::visitBinary(Visit visit, TIntermBinary* intermBinary) { TOperator op = intermBinary->getOp(); - if (op == EOpInitialize || intermBinary->modifiesState()) + if (op == EOpInitialize || intermBinary->isAssignment()) visitAssignment(intermBinary); else if (op == EOpLogicalAnd || op == EOpLogicalOr) visitLogicalOp(intermBinary); diff --git a/src/compiler/intermediate.h b/src/compiler/intermediate.h index 69e3f07a..3f2ea145 100644 --- a/src/compiler/intermediate.h +++ b/src/compiler/intermediate.h @@ -252,6 +252,8 @@ public: TIntermTyped(const TType& t) : type(t) { } virtual TIntermTyped* getAsTyped() { return this; } + virtual bool hasSideEffects() const = 0; + void setType(const TType& t) { type = t; } const TType& getType() const { return type; } TType* getTypePointer() { return &type; } @@ -354,6 +356,8 @@ public: TIntermSymbol(int i, const TString& sym, const TType& t) : TIntermTyped(t), id(i) { symbol = sym; originalSymbol = sym; } + virtual bool hasSideEffects() const { return false; } + int getId() const { return id; } const TString& getSymbol() const { return symbol; } @@ -376,11 +380,13 @@ class TIntermConstantUnion : public TIntermTyped { public: TIntermConstantUnion(ConstantUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { } + virtual bool hasSideEffects() const { return false; } + ConstantUnion* getUnionArrayPointer() const { return unionArrayPointer; } - int getIConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; } - float getFConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; } - bool getBConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; } + int getIConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; } + float getFConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; } + bool getBConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; } virtual TIntermConstantUnion* getAsConstantUnion() { return this; } virtual void traverse(TIntermTraverser*); @@ -400,9 +406,11 @@ public: TOperator getOp() const { return op; } void setOp(TOperator o) { op = o; } - bool modifiesState() const; + bool isAssignment() const; bool isConstructor() const; + virtual bool hasSideEffects() const { return isAssignment(); } + protected: TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat, EbpUndefined)), op(o) {} TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {} @@ -421,6 +429,8 @@ public: virtual bool replaceChildNode( TIntermNode *original, TIntermNode *replacement); + virtual bool hasSideEffects() const { return (isAssignment() || left->hasSideEffects() || right->hasSideEffects()); } + void setLeft(TIntermTyped* n) { left = n; } void setRight(TIntermTyped* n) { right = n; } TIntermTyped* getLeft() const { return left; } @@ -451,6 +461,8 @@ public: virtual bool replaceChildNode( TIntermNode *original, TIntermNode *replacement); + virtual bool hasSideEffects() const { return (isAssignment() || operand->hasSideEffects()); } + void setOperand(TIntermTyped* o) { operand = o; } TIntermTyped* getOperand() { return operand; } bool promote(TInfoSink&); @@ -483,6 +495,9 @@ public: virtual bool replaceChildNode( TIntermNode *original, TIntermNode *replacement); + // Conservatively assume function calls and other aggregate operators have side-effects + virtual bool hasSideEffects() const { return true; } + TIntermSequence& getSequence() { return sequence; } void setName(const TString& n) { name = n; } @@ -528,6 +543,9 @@ public: virtual bool replaceChildNode( TIntermNode *original, TIntermNode *replacement); + // Conservatively assume selections have side-effects + virtual bool hasSideEffects() const { return true; } + bool usesTernaryOperator() const { return getBasicType() != EbtVoid; } TIntermNode* getCondition() const { return condition; } TIntermNode* getTrueBlock() const { return trueBlock; } diff --git a/src/compiler/preprocessor/DiagnosticsBase.cpp b/src/compiler/preprocessor/DiagnosticsBase.cpp index 3e22e1f1..a7ce862b 100644 --- a/src/compiler/preprocessor/DiagnosticsBase.cpp +++ b/src/compiler/preprocessor/DiagnosticsBase.cpp @@ -25,14 +25,14 @@ void Diagnostics::report(ID id, Diagnostics::Severity Diagnostics::severity(ID id) { - if ((id > ERROR_BEGIN) && (id < ERROR_END)) - return ERROR; + if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END)) + return PP_ERROR; - if ((id > WARNING_BEGIN) && (id < WARNING_END)) - return WARNING; + if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END)) + return PP_WARNING; assert(false); - return ERROR; + return PP_ERROR; } std::string Diagnostics::message(ID id) @@ -40,82 +40,82 @@ std::string Diagnostics::message(ID id) switch (id) { // Errors begin. - case INTERNAL_ERROR: + case PP_INTERNAL_ERROR: return "internal error"; - case OUT_OF_MEMORY: + case PP_OUT_OF_MEMORY: return "out of memory"; - case INVALID_CHARACTER: + case PP_INVALID_CHARACTER: return "invalid character"; - case INVALID_NUMBER: + case PP_INVALID_NUMBER: return "invalid number"; - case INTEGER_OVERFLOW: + case PP_INTEGER_OVERFLOW: return "integer overflow"; - case FLOAT_OVERFLOW: + case PP_FLOAT_OVERFLOW: return "float overflow"; - case TOKEN_TOO_LONG: + case PP_TOKEN_TOO_LONG: return "token too long"; - case INVALID_EXPRESSION: + case PP_INVALID_EXPRESSION: return "invalid expression"; - case DIVISION_BY_ZERO: + case PP_DIVISION_BY_ZERO: return "division by zero"; - case EOF_IN_COMMENT: + case PP_EOF_IN_COMMENT: return "unexpected end of file found in comment"; - case UNEXPECTED_TOKEN: + case PP_UNEXPECTED_TOKEN: return "unexpected token"; - case DIRECTIVE_INVALID_NAME: + case PP_DIRECTIVE_INVALID_NAME: return "invalid directive name"; - case MACRO_NAME_RESERVED: + case PP_MACRO_NAME_RESERVED: return "macro name is reserved"; - case MACRO_REDEFINED: + case PP_MACRO_REDEFINED: return "macro redefined"; - case MACRO_PREDEFINED_REDEFINED: + case PP_MACRO_PREDEFINED_REDEFINED: return "predefined macro redefined"; - case MACRO_PREDEFINED_UNDEFINED: + case PP_MACRO_PREDEFINED_UNDEFINED: return "predefined macro undefined"; - case MACRO_UNTERMINATED_INVOCATION: + case PP_MACRO_UNTERMINATED_INVOCATION: return "unterminated macro invocation"; - case MACRO_TOO_FEW_ARGS: + case PP_MACRO_TOO_FEW_ARGS: return "Not enough arguments for macro"; - case MACRO_TOO_MANY_ARGS: + case PP_MACRO_TOO_MANY_ARGS: return "Too many arguments for macro"; - case CONDITIONAL_ENDIF_WITHOUT_IF: + case PP_CONDITIONAL_ENDIF_WITHOUT_IF: return "unexpected #endif found without a matching #if"; - case CONDITIONAL_ELSE_WITHOUT_IF: + case PP_CONDITIONAL_ELSE_WITHOUT_IF: return "unexpected #else found without a matching #if"; - case CONDITIONAL_ELSE_AFTER_ELSE: + case PP_CONDITIONAL_ELSE_AFTER_ELSE: return "unexpected #else found after another #else"; - case CONDITIONAL_ELIF_WITHOUT_IF: + case PP_CONDITIONAL_ELIF_WITHOUT_IF: return "unexpected #elif found without a matching #if"; - case CONDITIONAL_ELIF_AFTER_ELSE: + case PP_CONDITIONAL_ELIF_AFTER_ELSE: return "unexpected #elif found after #else"; - case CONDITIONAL_UNTERMINATED: + case PP_CONDITIONAL_UNTERMINATED: return "unexpected end of file found in conditional block"; - case INVALID_EXTENSION_NAME: + case PP_INVALID_EXTENSION_NAME: return "invalid extension name"; - case INVALID_EXTENSION_BEHAVIOR: + case PP_INVALID_EXTENSION_BEHAVIOR: return "invalid extension behavior"; - case INVALID_EXTENSION_DIRECTIVE: + case PP_INVALID_EXTENSION_DIRECTIVE: return "invalid extension directive"; - case INVALID_VERSION_NUMBER: + case PP_INVALID_VERSION_NUMBER: return "invalid version number"; - case INVALID_VERSION_DIRECTIVE: + case PP_INVALID_VERSION_DIRECTIVE: return "invalid version directive"; - case VERSION_NOT_FIRST_STATEMENT: + case PP_VERSION_NOT_FIRST_STATEMENT: return "#version directive must occur before anything else, " "except for comments and white space"; - case INVALID_LINE_NUMBER: + case PP_INVALID_LINE_NUMBER: return "invalid line number"; - case INVALID_FILE_NUMBER: + case PP_INVALID_FILE_NUMBER: return "invalid file number"; - case INVALID_LINE_DIRECTIVE: + case PP_INVALID_LINE_DIRECTIVE: return "invalid line directive"; // Errors end. // Warnings begin. - case EOF_IN_DIRECTIVE: + case PP_EOF_IN_DIRECTIVE: return "unexpected end of file found in directive"; - case CONDITIONAL_UNEXPECTED_TOKEN: + case PP_CONDITIONAL_UNEXPECTED_TOKEN: return "unexpected token after conditional expression"; - case UNRECOGNIZED_PRAGMA: + case PP_UNRECOGNIZED_PRAGMA: return "unrecognized pragma"; // Warnings end. default: diff --git a/src/compiler/preprocessor/DiagnosticsBase.h b/src/compiler/preprocessor/DiagnosticsBase.h index 07bc4118..2c8c5391 100644 --- a/src/compiler/preprocessor/DiagnosticsBase.h +++ b/src/compiler/preprocessor/DiagnosticsBase.h @@ -21,53 +21,53 @@ class Diagnostics public: enum Severity { - ERROR, - WARNING + PP_ERROR, + PP_WARNING }; enum ID { - ERROR_BEGIN, - INTERNAL_ERROR, - OUT_OF_MEMORY, - INVALID_CHARACTER, - INVALID_NUMBER, - INTEGER_OVERFLOW, - FLOAT_OVERFLOW, - TOKEN_TOO_LONG, - INVALID_EXPRESSION, - DIVISION_BY_ZERO, - EOF_IN_COMMENT, - UNEXPECTED_TOKEN, - DIRECTIVE_INVALID_NAME, - MACRO_NAME_RESERVED, - MACRO_REDEFINED, - MACRO_PREDEFINED_REDEFINED, - MACRO_PREDEFINED_UNDEFINED, - MACRO_UNTERMINATED_INVOCATION, - MACRO_TOO_FEW_ARGS, - MACRO_TOO_MANY_ARGS, - CONDITIONAL_ENDIF_WITHOUT_IF, - CONDITIONAL_ELSE_WITHOUT_IF, - CONDITIONAL_ELSE_AFTER_ELSE, - CONDITIONAL_ELIF_WITHOUT_IF, - CONDITIONAL_ELIF_AFTER_ELSE, - CONDITIONAL_UNTERMINATED, - INVALID_EXTENSION_NAME, - INVALID_EXTENSION_BEHAVIOR, - INVALID_EXTENSION_DIRECTIVE, - INVALID_VERSION_NUMBER, - INVALID_VERSION_DIRECTIVE, - VERSION_NOT_FIRST_STATEMENT, - INVALID_LINE_NUMBER, - INVALID_FILE_NUMBER, - INVALID_LINE_DIRECTIVE, - ERROR_END, + PP_ERROR_BEGIN, + PP_INTERNAL_ERROR, + PP_OUT_OF_MEMORY, + PP_INVALID_CHARACTER, + PP_INVALID_NUMBER, + PP_INTEGER_OVERFLOW, + PP_FLOAT_OVERFLOW, + PP_TOKEN_TOO_LONG, + PP_INVALID_EXPRESSION, + PP_DIVISION_BY_ZERO, + PP_EOF_IN_COMMENT, + PP_UNEXPECTED_TOKEN, + PP_DIRECTIVE_INVALID_NAME, + PP_MACRO_NAME_RESERVED, + PP_MACRO_REDEFINED, + PP_MACRO_PREDEFINED_REDEFINED, + PP_MACRO_PREDEFINED_UNDEFINED, + PP_MACRO_UNTERMINATED_INVOCATION, + PP_MACRO_TOO_FEW_ARGS, + PP_MACRO_TOO_MANY_ARGS, + PP_CONDITIONAL_ENDIF_WITHOUT_IF, + PP_CONDITIONAL_ELSE_WITHOUT_IF, + PP_CONDITIONAL_ELSE_AFTER_ELSE, + PP_CONDITIONAL_ELIF_WITHOUT_IF, + PP_CONDITIONAL_ELIF_AFTER_ELSE, + PP_CONDITIONAL_UNTERMINATED, + PP_INVALID_EXTENSION_NAME, + PP_INVALID_EXTENSION_BEHAVIOR, + PP_INVALID_EXTENSION_DIRECTIVE, + PP_INVALID_VERSION_NUMBER, + PP_INVALID_VERSION_DIRECTIVE, + PP_VERSION_NOT_FIRST_STATEMENT, + PP_INVALID_LINE_NUMBER, + PP_INVALID_FILE_NUMBER, + PP_INVALID_LINE_DIRECTIVE, + PP_ERROR_END, - WARNING_BEGIN, - EOF_IN_DIRECTIVE, - CONDITIONAL_UNEXPECTED_TOKEN, - UNRECOGNIZED_PRAGMA, - WARNING_END + PP_WARNING_BEGIN, + PP_EOF_IN_DIRECTIVE, + PP_CONDITIONAL_UNEXPECTED_TOKEN, + PP_UNRECOGNIZED_PRAGMA, + PP_WARNING_END }; virtual ~Diagnostics(); diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp index 94dfdf51..ebec7980 100644 --- a/src/compiler/preprocessor/DirectiveParser.cpp +++ b/src/compiler/preprocessor/DirectiveParser.cpp @@ -172,7 +172,7 @@ class DefinedParser : public Lexer if (token->type != Token::IDENTIFIER) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mLexer, token); return; @@ -185,7 +185,7 @@ class DefinedParser : public Lexer mLexer->lex(token); if (token->type != ')') { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mLexer, token); return; @@ -233,7 +233,7 @@ void DirectiveParser::lex(Token* token) if (!mConditionalStack.empty()) { const ConditionalBlock& block = mConditionalStack.back(); - mDiagnostics->report(Diagnostics::CONDITIONAL_UNTERMINATED, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED, block.location, block.type); } break; @@ -268,7 +268,7 @@ void DirectiveParser::parseDirective(Token* token) switch(directive) { case DIRECTIVE_NONE: - mDiagnostics->report(Diagnostics::DIRECTIVE_INVALID_NAME, + mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME, token->location, token->text); skipUntilEOD(mTokenizer, token); break; @@ -319,7 +319,7 @@ void DirectiveParser::parseDirective(Token* token) skipUntilEOD(mTokenizer, token); if (token->type == Token::LAST) { - mDiagnostics->report(Diagnostics::EOF_IN_DIRECTIVE, + mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE, token->location, token->text); } } @@ -331,19 +331,19 @@ void DirectiveParser::parseDefine(Token* token) mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); return; } if (isMacroPredefined(token->text, *mMacroSet)) { - mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_REDEFINED, + mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, token->location, token->text); return; } if (isMacroNameReserved(token->text)) { - mDiagnostics->report(Diagnostics::MACRO_NAME_RESERVED, + mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED, token->location, token->text); return; } @@ -368,7 +368,7 @@ void DirectiveParser::parseDefine(Token* token) if (token->type != ')') { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); return; @@ -396,7 +396,7 @@ void DirectiveParser::parseDefine(Token* token) MacroSet::const_iterator iter = mMacroSet->find(macro.name); if (iter != mMacroSet->end() && !macro.equals(iter->second)) { - mDiagnostics->report(Diagnostics::MACRO_REDEFINED, + mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED, token->location, macro.name); return; @@ -411,7 +411,7 @@ void DirectiveParser::parseUndef(Token* token) mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); return; } @@ -421,7 +421,7 @@ void DirectiveParser::parseUndef(Token* token) { if (iter->second.predefined) { - mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_UNDEFINED, + mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, token->location, token->text); } else @@ -457,7 +457,7 @@ void DirectiveParser::parseElse(Token* token) if (mConditionalStack.empty()) { - mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF, token->location, token->text); skipUntilEOD(mTokenizer, token); return; @@ -472,7 +472,7 @@ void DirectiveParser::parseElse(Token* token) } if (block.foundElseGroup) { - mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE, token->location, token->text); skipUntilEOD(mTokenizer, token); return; @@ -486,7 +486,7 @@ void DirectiveParser::parseElse(Token* token) mTokenizer->lex(token); if (!isEOD(token)) { - mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } @@ -498,7 +498,7 @@ void DirectiveParser::parseElif(Token* token) if (mConditionalStack.empty()) { - mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF, token->location, token->text); skipUntilEOD(mTokenizer, token); return; @@ -513,7 +513,7 @@ void DirectiveParser::parseElif(Token* token) } if (block.foundElseGroup) { - mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE, token->location, token->text); skipUntilEOD(mTokenizer, token); return; @@ -538,7 +538,7 @@ void DirectiveParser::parseEndif(Token* token) if (mConditionalStack.empty()) { - mDiagnostics->report(Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF, token->location, token->text); skipUntilEOD(mTokenizer, token); return; @@ -550,7 +550,7 @@ void DirectiveParser::parseEndif(Token* token) mTokenizer->lex(token); if (!isEOD(token)) { - mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } @@ -618,7 +618,7 @@ void DirectiveParser::parsePragma(Token* token) (state == RIGHT_PAREN + 1)); // With value. if (!valid) { - mDiagnostics->report(Diagnostics::UNRECOGNIZED_PRAGMA, + mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA, token->location, name); } else if (state > PRAGMA_NAME) // Do not notify for empty pragma. @@ -650,7 +650,7 @@ void DirectiveParser::parseExtension(Token* token) case EXT_NAME: if (valid && (token->type != Token::IDENTIFIER)) { - mDiagnostics->report(Diagnostics::INVALID_EXTENSION_NAME, + mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME, token->location, token->text); valid = false; } @@ -659,7 +659,7 @@ void DirectiveParser::parseExtension(Token* token) case COLON: if (valid && (token->type != ':')) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } @@ -667,7 +667,7 @@ void DirectiveParser::parseExtension(Token* token) case EXT_BEHAVIOR: if (valid && (token->type != Token::IDENTIFIER)) { - mDiagnostics->report(Diagnostics::INVALID_EXTENSION_BEHAVIOR, + mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR, token->location, token->text); valid = false; } @@ -676,7 +676,7 @@ void DirectiveParser::parseExtension(Token* token) default: if (valid) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } @@ -686,7 +686,7 @@ void DirectiveParser::parseExtension(Token* token) } if (valid && (state != EXT_BEHAVIOR + 1)) { - mDiagnostics->report(Diagnostics::INVALID_EXTENSION_DIRECTIVE, + mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE, token->location, token->text); valid = false; } @@ -700,7 +700,7 @@ void DirectiveParser::parseVersion(Token* token) if (mPastFirstStatement) { - mDiagnostics->report(Diagnostics::VERSION_NOT_FIRST_STATEMENT, + mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, token->location, token->text); skipUntilEOD(mTokenizer, token); return; @@ -723,13 +723,13 @@ void DirectiveParser::parseVersion(Token* token) case VERSION_NUMBER: if (valid && (token->type != Token::CONST_INT)) { - mDiagnostics->report(Diagnostics::INVALID_VERSION_NUMBER, + mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER, token->location, token->text); valid = false; } if (valid && !token->iValue(&version)) { - mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW, + mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); valid = false; } @@ -737,7 +737,7 @@ void DirectiveParser::parseVersion(Token* token) default: if (valid) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } @@ -747,7 +747,7 @@ void DirectiveParser::parseVersion(Token* token) } if (valid && (state != VERSION_NUMBER + 1)) { - mDiagnostics->report(Diagnostics::INVALID_VERSION_DIRECTIVE, + mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location, token->text); valid = false; } @@ -778,13 +778,13 @@ void DirectiveParser::parseLine(Token* token) case LINE_NUMBER: if (valid && (token->type != Token::CONST_INT)) { - mDiagnostics->report(Diagnostics::INVALID_LINE_NUMBER, + mDiagnostics->report(Diagnostics::PP_INVALID_LINE_NUMBER, token->location, token->text); valid = false; } if (valid && !token->iValue(&line)) { - mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW, + mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); valid = false; } @@ -792,13 +792,13 @@ void DirectiveParser::parseLine(Token* token) case FILE_NUMBER: if (valid && (token->type != Token::CONST_INT)) { - mDiagnostics->report(Diagnostics::INVALID_FILE_NUMBER, + mDiagnostics->report(Diagnostics::PP_INVALID_FILE_NUMBER, token->location, token->text); valid = false; } if (valid && !token->iValue(&file)) { - mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW, + mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); valid = false; } @@ -806,7 +806,7 @@ void DirectiveParser::parseLine(Token* token) default: if (valid) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); valid = false; } @@ -817,7 +817,7 @@ void DirectiveParser::parseLine(Token* token) if (valid && (state != FILE_NUMBER) && (state != FILE_NUMBER + 1)) { - mDiagnostics->report(Diagnostics::INVALID_LINE_DIRECTIVE, + mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE, token->location, token->text); valid = false; } @@ -893,7 +893,7 @@ int DirectiveParser::parseExpressionIf(Token* token) // Warn if there are tokens after #if expression. if (!isEOD(token)) { - mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } @@ -909,7 +909,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token) mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) { - mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); return 0; @@ -922,7 +922,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token) mTokenizer->lex(token); if (!isEOD(token)) { - mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, + mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, token->text); skipUntilEOD(mTokenizer, token); } diff --git a/src/compiler/preprocessor/ExpressionParser.cpp b/src/compiler/preprocessor/ExpressionParser.cpp index 67966e95..2d374961 100644 --- a/src/compiler/preprocessor/ExpressionParser.cpp +++ b/src/compiler/preprocessor/ExpressionParser.cpp @@ -92,6 +92,12 @@ #include "ExpressionParser.h" +#if defined(_MSC_VER) +#include <malloc.h> +#else +#include <stdlib.h> +#endif + #include <cassert> #include <sstream> @@ -1581,7 +1587,7 @@ yyreduce: std::ostringstream stream; stream << (yyvsp[(1) - (3)]) << " % " << (yyvsp[(3) - (3)]); std::string text = stream.str(); - context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO, + context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO, context->token->location, text.c_str()); YYABORT; @@ -1598,7 +1604,7 @@ yyreduce: std::ostringstream stream; stream << (yyvsp[(1) - (3)]) << " / " << (yyvsp[(3) - (3)]); std::string text = stream.str(); - context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO, + context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO, context->token->location, text.c_str()); YYABORT; @@ -1897,7 +1903,7 @@ int yylex(YYSTYPE* lvalp, Context* context) unsigned int val = 0; if (!token->uValue(&val)) { - context->diagnostics->report(pp::Diagnostics::INTEGER_OVERFLOW, + context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW, token->location, token->text); } *lvalp = static_cast<YYSTYPE>(val); @@ -1938,7 +1944,7 @@ int yylex(YYSTYPE* lvalp, Context* context) void yyerror(Context* context, const char* reason) { - context->diagnostics->report(pp::Diagnostics::INVALID_EXPRESSION, + context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION, context->token->location, reason); } @@ -1966,12 +1972,12 @@ bool ExpressionParser::parse(Token* token, int* result) break; case 2: - mDiagnostics->report(Diagnostics::OUT_OF_MEMORY, token->location, ""); + mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, ""); break; default: assert(false); - mDiagnostics->report(Diagnostics::INTERNAL_ERROR, token->location, ""); + mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, ""); break; } diff --git a/src/compiler/preprocessor/ExpressionParser.y b/src/compiler/preprocessor/ExpressionParser.y index b6d3143e..27ed6ad5 100644 --- a/src/compiler/preprocessor/ExpressionParser.y +++ b/src/compiler/preprocessor/ExpressionParser.y @@ -33,6 +33,12 @@ WHICH GENERATES THE GLSL ES preprocessor expression parser. #include "ExpressionParser.h" +#if defined(_MSC_VER) +#include <malloc.h> +#else +#include <stdlib.h> +#endif + #include <cassert> #include <sstream> diff --git a/src/compiler/preprocessor/MacroExpander.cpp b/src/compiler/preprocessor/MacroExpander.cpp index 1116c516..b789260a 100644 --- a/src/compiler/preprocessor/MacroExpander.cpp +++ b/src/compiler/preprocessor/MacroExpander.cpp @@ -254,7 +254,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro, if (token.type == Token::LAST) { - mDiagnostics->report(Diagnostics::MACRO_UNTERMINATED_INVOCATION, + mDiagnostics->report(Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION, identifier.location, identifier.text); // Do not lose EOF token. ungetToken(token); @@ -302,8 +302,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro, if (args->size() != params.size()) { Diagnostics::ID id = args->size() < macro.parameters.size() ? - Diagnostics::MACRO_TOO_FEW_ARGS : - Diagnostics::MACRO_TOO_MANY_ARGS; + Diagnostics::PP_MACRO_TOO_FEW_ARGS : + Diagnostics::PP_MACRO_TOO_MANY_ARGS; mDiagnostics->report(id, identifier.location, identifier.text); return false; } diff --git a/src/compiler/preprocessor/Preprocessor.cpp b/src/compiler/preprocessor/Preprocessor.cpp index b615c85d..580ffba4 100644 --- a/src/compiler/preprocessor/Preprocessor.cpp +++ b/src/compiler/preprocessor/Preprocessor.cpp @@ -101,11 +101,11 @@ void Preprocessor::lex(Token* token) assert(false); break; case Token::PP_NUMBER: - mImpl->diagnostics->report(Diagnostics::INVALID_NUMBER, + mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER, token->location, token->text); break; case Token::PP_OTHER: - mImpl->diagnostics->report(Diagnostics::INVALID_CHARACTER, + mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER, token->location, token->text); break; default: diff --git a/src/compiler/preprocessor/Tokenizer.cpp b/src/compiler/preprocessor/Tokenizer.cpp index 3b0fd101..21f11041 100644 --- a/src/compiler/preprocessor/Tokenizer.cpp +++ b/src/compiler/preprocessor/Tokenizer.cpp @@ -1143,7 +1143,7 @@ case YY_STATE_EOF(COMMENT): if (YY_START == COMMENT) { - yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT, + yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT, pp::SourceLocation(yyfileno, yylineno), ""); } @@ -2327,7 +2327,7 @@ void Tokenizer::lex(Token* token) token->type = pplex(&token->text,&token->location,mHandle); if (token->text.size() > mMaxTokenLength) { - mContext.diagnostics->report(Diagnostics::TOKEN_TOO_LONG, + mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG, token->location, token->text); token->text.erase(mMaxTokenLength); } diff --git a/src/compiler/translator.vcxproj b/src/compiler/translator.vcxproj index 7325172a..54d71a1d 100644 --- a/src/compiler/translator.vcxproj +++ b/src/compiler/translator.vcxproj @@ -263,6 +263,7 @@ <ClInclude Include="localintermediate.h" /> <ClInclude Include="MapLongVariableNames.h" /> <ClInclude Include="MMap.h" /> + <ClInclude Include="NodeSearch.h" /> <ClInclude Include="osinclude.h" /> <ClInclude Include="OutputESSL.h" /> <ClInclude Include="OutputGLSL.h" /> diff --git a/src/compiler/translator.vcxproj.filters b/src/compiler/translator.vcxproj.filters index b8cd7304..1df6c7c2 100644 --- a/src/compiler/translator.vcxproj.filters +++ b/src/compiler/translator.vcxproj.filters @@ -346,6 +346,9 @@ <ClInclude Include="ParseContext.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="NodeSearch.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <CustomBuild Include="glslang.l"> diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp index e084db1a..fba4104d 100644 --- a/src/libGLESv2/Context.cpp +++ b/src/libGLESv2/Context.cpp @@ -1812,6 +1812,8 @@ void Context::applyTextures(SamplerType type) { ProgramBinary *programBinary = getCurrentProgramBinary(); + FramebufferTextureSerialSet boundFramebufferTextures = getBoundFramebufferTextureSerials(); + // Range of Direct3D samplers of given sampler type int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : mRenderer->getMaxVertexTextureImageUnits(); int samplerRange = programBinary->getUsedSamplerRange(type); @@ -1825,7 +1827,8 @@ void Context::applyTextures(SamplerType type) TextureType textureType = programBinary->getSamplerTextureType(type, samplerIndex); Texture *texture = getSamplerTexture(textureUnit, textureType); - if (texture->isSamplerComplete()) + if (texture->isSamplerComplete() && + boundFramebufferTextures.find(texture->getTextureSerial()) == boundFramebufferTextures.end()) { SamplerState samplerState; texture->getSamplerState(&samplerState); @@ -2655,6 +2658,29 @@ const char *Context::getRendererString() const return mRendererString; } +Context::FramebufferTextureSerialSet Context::getBoundFramebufferTextureSerials() +{ + FramebufferTextureSerialSet set; + + Framebuffer *drawFramebuffer = getDrawFramebuffer(); + for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) + { + Renderbuffer *renderBuffer = drawFramebuffer->getColorbuffer(i); + if (renderBuffer && renderBuffer->getTextureSerial() != 0) + { + set.insert(renderBuffer->getTextureSerial()); + } + } + + Renderbuffer *depthStencilBuffer = drawFramebuffer->getDepthOrStencilbuffer(); + if (depthStencilBuffer && depthStencilBuffer->getTextureSerial() != 0) + { + set.insert(depthStencilBuffer->getTextureSerial()); + } + + return set; +} + void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask) diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h index 349ec130..09eede9f 100644 --- a/src/libGLESv2/Context.h +++ b/src/libGLESv2/Context.h @@ -18,6 +18,7 @@ #include <string> #include <map> +#include <set> #ifdef _MSC_VER #include <hash_map> #else @@ -420,6 +421,9 @@ class Context void initExtensionString(); void initRendererString(); + typedef std::set<unsigned> FramebufferTextureSerialSet; + FramebufferTextureSerialSet getBoundFramebufferTextureSerials(); + rx::Renderer *const mRenderer; State mState; diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp index 922cd3de..ee0ec8e0 100644 --- a/src/libGLESv2/ProgramBinary.cpp +++ b/src/libGLESv2/ProgramBinary.cpp @@ -34,6 +34,11 @@ std::string str(int i) return buffer; } +static rx::D3DWorkaroundType DiscardWorkaround(bool usesDiscard) +{ + return (usesDiscard ? rx::ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER : rx::ANGLE_D3D_WORKAROUND_NONE); +} + UniformLocation::UniformLocation(const std::string &name, unsigned int element, unsigned int index) : name(name), element(element), index(index) { @@ -1962,13 +1967,13 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin if (success) { - mVertexExecutable = mRenderer->compileToExecutable(infoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX); - mPixelExecutable = mRenderer->compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL); + mVertexExecutable = mRenderer->compileToExecutable(infoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX, DiscardWorkaround(vertexShader->mUsesDiscardRewriting)); + mPixelExecutable = mRenderer->compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL, DiscardWorkaround(fragmentShader->mUsesDiscardRewriting)); if (usesGeometryShader()) { std::string geometryHLSL = generateGeometryShaderHLSL(registers, packing, fragmentShader, vertexShader); - mGeometryExecutable = mRenderer->compileToExecutable(infoLog, geometryHLSL.c_str(), rx::SHADER_GEOMETRY); + mGeometryExecutable = mRenderer->compileToExecutable(infoLog, geometryHLSL.c_str(), rx::SHADER_GEOMETRY, rx::ANGLE_D3D_WORKAROUND_NONE); } if (!mVertexExecutable || !mPixelExecutable || (usesGeometryShader() && !mGeometryExecutable)) diff --git a/src/libGLESv2/Renderbuffer.cpp b/src/libGLESv2/Renderbuffer.cpp index 12751374..98d33ec6 100644 --- a/src/libGLESv2/Renderbuffer.cpp +++ b/src/libGLESv2/Renderbuffer.cpp @@ -129,6 +129,11 @@ unsigned int RenderbufferTexture2D::getSerial() const return mTexture2D->getRenderTargetSerial(mTarget); } +unsigned int RenderbufferTexture2D::getTextureSerial() const +{ + return mTexture2D->getTextureSerial(); +} + ///// RenderbufferTextureCubeMap Implementation //////// RenderbufferTextureCubeMap::RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum target) : mTarget(target) @@ -193,6 +198,11 @@ unsigned int RenderbufferTextureCubeMap::getSerial() const return mTextureCubeMap->getRenderTargetSerial(mTarget); } +unsigned int RenderbufferTextureCubeMap::getTextureSerial() const +{ + return mTextureCubeMap->getTextureSerial(); +} + ////// Renderbuffer Implementation ////// Renderbuffer::Renderbuffer(rx::Renderer *renderer, GLuint id, RenderbufferInterface *instance) : RefCountObject(id) @@ -292,6 +302,11 @@ unsigned int Renderbuffer::getSerial() const return mInstance->getSerial(); } +unsigned int Renderbuffer::getTextureSerial() const +{ + return mInstance->getTextureSerial(); +} + void Renderbuffer::setStorage(RenderbufferStorage *newStorage) { ASSERT(newStorage != NULL); diff --git a/src/libGLESv2/Renderbuffer.h b/src/libGLESv2/Renderbuffer.h index eca2f3a7..d46fd445 100644 --- a/src/libGLESv2/Renderbuffer.h +++ b/src/libGLESv2/Renderbuffer.h @@ -60,6 +60,7 @@ class RenderbufferInterface GLuint getStencilSize() const; virtual unsigned int getSerial() const = 0; + virtual unsigned int getTextureSerial() const = 0; private: DISALLOW_COPY_AND_ASSIGN(RenderbufferInterface); @@ -85,6 +86,7 @@ class RenderbufferTexture2D : public RenderbufferInterface virtual GLsizei getSamples() const; virtual unsigned int getSerial() const; + virtual unsigned int getTextureSerial() const; private: DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture2D); @@ -113,6 +115,7 @@ class RenderbufferTextureCubeMap : public RenderbufferInterface virtual GLsizei getSamples() const; virtual unsigned int getSerial() const; + virtual unsigned int getTextureSerial() const; private: DISALLOW_COPY_AND_ASSIGN(RenderbufferTextureCubeMap); @@ -141,6 +144,7 @@ class RenderbufferStorage : public RenderbufferInterface virtual GLsizei getSamples() const; virtual unsigned int getSerial() const; + virtual unsigned int getTextureSerial() const { return 0; } static unsigned int issueSerial(); static unsigned int issueCubeSerials(); @@ -193,6 +197,7 @@ class Renderbuffer : public RefCountObject GLsizei getSamples() const; unsigned int getSerial() const; + unsigned int getTextureSerial() const; void setStorage(RenderbufferStorage *newStorage); diff --git a/src/libGLESv2/Shader.cpp b/src/libGLESv2/Shader.cpp index 7dfdd0ba..f6a2f03d 100644 --- a/src/libGLESv2/Shader.cpp +++ b/src/libGLESv2/Shader.cpp @@ -307,6 +307,7 @@ void Shader::parseVaryings() mUsesPointCoord = strstr(mHlsl, "GL_USES_POINT_COORD") != NULL; mUsesDepthRange = strstr(mHlsl, "GL_USES_DEPTH_RANGE") != NULL; mUsesFragDepth = strstr(mHlsl, "GL_USES_FRAG_DEPTH") != NULL; + mUsesDiscardRewriting = strstr(mHlsl, "ANGLE_USES_DISCARD_REWRITING") != NULL; } } @@ -340,6 +341,7 @@ void Shader::uncompile() mUsesPointCoord = false; mUsesDepthRange = false; mUsesFragDepth = false; + mUsesDiscardRewriting = false; mActiveUniforms.clear(); } diff --git a/src/libGLESv2/Shader.h b/src/libGLESv2/Shader.h index 2afe2976..848d4c99 100644 --- a/src/libGLESv2/Shader.h +++ b/src/libGLESv2/Shader.h @@ -107,6 +107,7 @@ class Shader bool mUsesPointCoord; bool mUsesDepthRange; bool mUsesFragDepth; + bool mUsesDiscardRewriting; static void *mFragmentCompiler; static void *mVertexCompiler; diff --git a/src/libGLESv2/renderer/Renderer.h b/src/libGLESv2/renderer/Renderer.h index 04e877ba..e1861f01 100644 --- a/src/libGLESv2/renderer/Renderer.h +++ b/src/libGLESv2/renderer/Renderer.h @@ -93,6 +93,12 @@ enum ShaderType SHADER_GEOMETRY }; +enum D3DWorkaroundType +{ + ANGLE_D3D_WORKAROUND_NONE, + ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER +}; + class Renderer { public: @@ -207,7 +213,7 @@ class Renderer // Shader operations virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type) = 0; - virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type) = 0; + virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround) = 0; // Image operations virtual Image *createImage() = 0; diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp index 6f4da5c6..13ba355d 100644 --- a/src/libGLESv2/renderer/Renderer11.cpp +++ b/src/libGLESv2/renderer/Renderer11.cpp @@ -243,8 +243,6 @@ EGLint Renderer11::initialize() { D3D11_MESSAGE_ID hideMessages[] = { - D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD, - D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD, D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET }; @@ -919,6 +917,25 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) renderTargetFormat = colorbuffer->getActualFormat(); missingColorRenderTarget = false; } + +#ifdef _DEBUG + // Workaround for Debug SETSHADERRESOURCES_HAZARD D3D11 warnings + for (unsigned int vertexSerialIndex = 0; vertexSerialIndex < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; vertexSerialIndex++) + { + if (colorbuffer->getTextureSerial() != 0 && mCurVertexTextureSerials[vertexSerialIndex] == colorbuffer->getTextureSerial()) + { + setTexture(gl::SAMPLER_VERTEX, vertexSerialIndex, NULL); + } + } + + for (unsigned int pixelSerialIndex = 0; pixelSerialIndex < gl::MAX_TEXTURE_IMAGE_UNITS; pixelSerialIndex++) + { + if (colorbuffer->getTextureSerial() != 0 && mCurPixelTextureSerials[pixelSerialIndex] == colorbuffer->getTextureSerial()) + { + setTexture(gl::SAMPLER_PIXEL, pixelSerialIndex, NULL); + } + } +#endif } } @@ -2813,7 +2830,7 @@ ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length return executable; } -ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type) +ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround) { const char *profile = NULL; diff --git a/src/libGLESv2/renderer/Renderer11.h b/src/libGLESv2/renderer/Renderer11.h index 90ef04db..b86f485f 100644 --- a/src/libGLESv2/renderer/Renderer11.h +++ b/src/libGLESv2/renderer/Renderer11.h @@ -155,7 +155,7 @@ class Renderer11 : public Renderer // Shader operations virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type); - virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type); + virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround); // Image operations virtual Image *createImage(); diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp index d3f3814a..c46d82b3 100644 --- a/src/libGLESv2/renderer/Renderer9.cpp +++ b/src/libGLESv2/renderer/Renderer9.cpp @@ -121,8 +121,6 @@ Renderer9::Renderer9(egl::Display *display, HDC hDc, bool softwareDevice) : Rend Renderer9::~Renderer9() { - releaseDeviceResources(); - if (mDevice) { // If the device is lost, reset it first to prevent leaving the driver in an unstable state @@ -130,22 +128,19 @@ Renderer9::~Renderer9() { resetDevice(); } - - mDevice->Release(); - mDevice = NULL; } - if (mDeviceEx) - { - mDeviceEx->Release(); - mDeviceEx = NULL; - } + deinitialize(); +} - if (mD3d9) - { - mD3d9->Release(); - mD3d9 = NULL; - } +void Renderer9::deinitialize() +{ + releaseDeviceResources(); + + SafeRelease(mDevice); + SafeRelease(mDeviceEx); + SafeRelease(mD3d9); + SafeRelease(mD3d9Ex); if (mDeviceWindow) { @@ -153,12 +148,6 @@ Renderer9::~Renderer9() mDeviceWindow = NULL; } - if (mD3d9Ex) - { - mD3d9Ex->Release(); - mD3d9Ex = NULL; - } - if (mD3d9Module) { mD3d9Module = NULL; @@ -2045,31 +2034,19 @@ void Renderer9::releaseDeviceResources() mEventQueryPool.pop_back(); } - if (mMaskedClearSavedState) - { - mMaskedClearSavedState->Release(); - mMaskedClearSavedState = NULL; - } + SafeRelease(mMaskedClearSavedState); mVertexShaderCache.clear(); mPixelShaderCache.clear(); - delete mBlit; - mBlit = NULL; - - delete mVertexDataManager; - mVertexDataManager = NULL; - - delete mIndexDataManager; - mIndexDataManager = NULL; - - delete mLineLoopIB; - mLineLoopIB = NULL; + SafeDelete(mBlit); + SafeDelete(mVertexDataManager); + SafeDelete(mIndexDataManager); + SafeDelete(mLineLoopIB); for (int i = 0; i < NUM_NULL_COLORBUFFER_CACHE_ENTRIES; i++) { - delete mNullColorbufferCache[i].buffer; - mNullColorbufferCache[i].buffer = NULL; + SafeDelete(mNullColorbufferCache[i].buffer); } } @@ -2089,22 +2066,8 @@ bool Renderer9::isDeviceLost() // set notify to true to broadcast a message to all contexts of the device loss bool Renderer9::testDeviceLost(bool notify) { - HRESULT status = S_OK; - - if (mDeviceEx) - { - status = mDeviceEx->CheckDeviceState(NULL); - } - else if (mDevice) - { - status = mDevice->TestCooperativeLevel(); - } - else - { - // No device yet, so no reset required - } - - bool isLost = FAILED(status) || d3d9::isDeviceLostError(status); + HRESULT status = getDeviceStatusCode(); + bool isLost = (FAILED(status) || d3d9::isDeviceLostError(status)); if (isLost) { @@ -2123,7 +2086,7 @@ bool Renderer9::testDeviceLost(bool notify) return isLost; } -bool Renderer9::testDeviceResettable() +HRESULT Renderer9::getDeviceStatusCode() { HRESULT status = D3D_OK; @@ -2136,9 +2099,14 @@ bool Renderer9::testDeviceResettable() status = mDevice->TestCooperativeLevel(); } + return status; +} + +bool Renderer9::testDeviceResettable() +{ // On D3D9Ex, DEVICELOST represents a hung device that needs to be restarted // DEVICEREMOVED indicates the device has been stopped and must be recreated - switch (status) + switch (getDeviceStatusCode()) { case D3DERR_DEVICENOTRESET: case D3DERR_DEVICEHUNG: @@ -2146,8 +2114,8 @@ bool Renderer9::testDeviceResettable() case D3DERR_DEVICELOST: return (mDeviceEx != NULL); case D3DERR_DEVICEREMOVED: - UNIMPLEMENTED(); - return false; + ASSERT(mDeviceEx != NULL); + return isRemovedDeviceResettable(); default: return false; } @@ -2161,14 +2129,26 @@ bool Renderer9::resetDevice() HRESULT result = D3D_OK; bool lost = testDeviceLost(false); - int attempts = 3; + bool removedDevice = (getDeviceStatusCode() == D3DERR_DEVICEREMOVED); - while (lost && attempts > 0) + // Device Removed is a feature which is only present with D3D9Ex + ASSERT(mDeviceEx != NULL || !removedDevice); + + for (int attempts = 3; lost && attempts > 0; attempts--) { - if (mDeviceEx) + if (removedDevice) + { + // Device removed, which may trigger on driver reinstallation, + // may cause a longer wait other reset attempts before the + // system is ready to handle creating a new device. + Sleep(800); + lost = !resetRemovedDevice(); + } + else if (mDeviceEx) { Sleep(500); // Give the graphics driver some CPU time result = mDeviceEx->ResetEx(&presentParameters, NULL); + lost = testDeviceLost(false); } else { @@ -2183,10 +2163,8 @@ bool Renderer9::resetDevice() { result = mDevice->Reset(&presentParameters); } + lost = testDeviceLost(false); } - - lost = testDeviceLost(false); - attempts --; } if (FAILED(result)) @@ -2195,13 +2173,58 @@ bool Renderer9::resetDevice() return false; } - // reset device defaults - initializeDevice(); + if (removedDevice && lost) + { + ERR("Device lost reset failed multiple times"); + return false; + } + + // If the device was removed, we already finished re-initialization in resetRemovedDevice + if (!removedDevice) + { + // reset device defaults + initializeDevice(); + } + mDeviceLost = false; return true; } +bool Renderer9::isRemovedDeviceResettable() const +{ + bool success = false; + +#ifdef ANGLE_ENABLE_D3D9EX + IDirect3D9Ex *d3d9Ex = NULL; + typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**); + Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex")); + + if (Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &d3d9Ex))) + { + D3DCAPS9 deviceCaps; + HRESULT result = d3d9Ex->GetDeviceCaps(mAdapter, mDeviceType, &deviceCaps); + success = SUCCEEDED(result); + } + + SafeRelease(d3d9Ex); +#else + ASSERT(UNREACHABLE()); +#endif + + return success; +} + +bool Renderer9::resetRemovedDevice() +{ + // From http://msdn.microsoft.com/en-us/library/windows/desktop/bb172554(v=vs.85).aspx: + // The hardware adapter has been removed. Application must destroy the device, do enumeration of + // adapters and create another Direct3D device. If application continues rendering without + // calling Reset, the rendering calls will succeed. Applies to Direct3D 9Ex only. + deinitialize(); + return (initialize() == EGL_SUCCESS); +} + DWORD Renderer9::getAdapterVendor() const { return mAdapterIdentifier.VendorId; @@ -3129,7 +3152,7 @@ ShaderExecutable *Renderer9::loadExecutable(const void *function, size_t length, return executable; } -ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type) +ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround) { const char *profile = NULL; @@ -3146,7 +3169,11 @@ ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const cha return NULL; } - ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, ANGLE_COMPILE_OPTIMIZATION_LEVEL, true); + // ANGLE issue 486: + // Work-around a D3D9 compiler bug that presents itself when using conditional discard, by disabling optimization + UINT optimizationFlags = (workaround == ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER ? D3DCOMPILE_SKIP_OPTIMIZATION : ANGLE_COMPILE_OPTIMIZATION_LEVEL); + + ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, optimizationFlags, true); if (!binary) return NULL; diff --git a/src/libGLESv2/renderer/Renderer9.h b/src/libGLESv2/renderer/Renderer9.h index f8932c4f..1fac9b7f 100644 --- a/src/libGLESv2/renderer/Renderer9.h +++ b/src/libGLESv2/renderer/Renderer9.h @@ -170,7 +170,7 @@ class Renderer9 : public Renderer // Shader operations virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type); - virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type); + virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround); // Image operations virtual Image *createImage(); @@ -198,6 +198,8 @@ class Renderer9 : public Renderer private: DISALLOW_COPY_AND_ASSIGN(Renderer9); + void deinitialize(); + void applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v); void applyUniformniv(gl::Uniform *targetUniform, const GLint *v); void applyUniformnbv(gl::Uniform *targetUniform, const GLint *v); @@ -218,6 +220,10 @@ class Renderer9 : public Renderer D3DPRESENT_PARAMETERS getDefaultPresentParameters(); void releaseDeviceResources(); + HRESULT getDeviceStatusCode(); + bool isRemovedDeviceResettable() const; + bool resetRemovedDevice(); + UINT mAdapter; D3DDEVTYPE mDeviceType; bool mSoftwareDevice; // FIXME: Deprecate diff --git a/src/libGLESv2/renderer/SwapChain9.cpp b/src/libGLESv2/renderer/SwapChain9.cpp index 757ce1cb..7b9b32b4 100644 --- a/src/libGLESv2/renderer/SwapChain9.cpp +++ b/src/libGLESv2/renderer/SwapChain9.cpp @@ -312,6 +312,11 @@ EGLint SwapChain9::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); + for (UINT streamIndex = 0; streamIndex < gl::MAX_VERTEX_ATTRIBS; streamIndex++) + { + device->SetStreamSourceFreq(streamIndex, 1); + } + D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f}; device->SetViewport(&viewport); diff --git a/src/libGLESv2/renderer/VertexDataManager.cpp b/src/libGLESv2/renderer/VertexDataManager.cpp index 7ff5171f..8034aed8 100644 --- a/src/libGLESv2/renderer/VertexDataManager.cpp +++ b/src/libGLESv2/renderer/VertexDataManager.cpp @@ -266,6 +266,10 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], return GL_OUT_OF_MEMORY; } + mCurrentValue[i][0] = attribs[i].mCurrentValue[0]; + mCurrentValue[i][1] = attribs[i].mCurrentValue[1]; + mCurrentValue[i][2] = attribs[i].mCurrentValue[2]; + mCurrentValue[i][3] = attribs[i].mCurrentValue[3]; mCurrentValueOffsets[i] = streamOffset; } diff --git a/src/preprocessor.target.darwin-arm.mk b/src/preprocessor.target.darwin-arm.mk index 65dea454..4bd714e6 100644 --- a/src/preprocessor.target.darwin-arm.mk +++ b/src/preprocessor.target.darwin-arm.mk @@ -88,6 +88,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ @@ -171,6 +172,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ diff --git a/src/preprocessor.target.darwin-mips.mk b/src/preprocessor.target.darwin-mips.mk index 9e1d0a02..cf665a41 100644 --- a/src/preprocessor.target.darwin-mips.mk +++ b/src/preprocessor.target.darwin-mips.mk @@ -88,6 +88,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ @@ -171,6 +172,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ diff --git a/src/preprocessor.target.darwin-x86.mk b/src/preprocessor.target.darwin-x86.mk index 8411f3f5..3ba28657 100644 --- a/src/preprocessor.target.darwin-x86.mk +++ b/src/preprocessor.target.darwin-x86.mk @@ -90,6 +90,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ @@ -176,6 +177,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ diff --git a/src/preprocessor.target.linux-arm.mk b/src/preprocessor.target.linux-arm.mk index 65dea454..4bd714e6 100644 --- a/src/preprocessor.target.linux-arm.mk +++ b/src/preprocessor.target.linux-arm.mk @@ -88,6 +88,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ @@ -171,6 +172,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ diff --git a/src/preprocessor.target.linux-mips.mk b/src/preprocessor.target.linux-mips.mk index 9e1d0a02..cf665a41 100644 --- a/src/preprocessor.target.linux-mips.mk +++ b/src/preprocessor.target.linux-mips.mk @@ -88,6 +88,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ @@ -171,6 +172,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ diff --git a/src/preprocessor.target.linux-x86.mk b/src/preprocessor.target.linux-x86.mk index 8411f3f5..3ba28657 100644 --- a/src/preprocessor.target.linux-x86.mk +++ b/src/preprocessor.target.linux-x86.mk @@ -90,6 +90,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ @@ -176,6 +177,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ '-DUSE_STLPORT=1' \ diff --git a/src/translator.target.darwin-arm.mk b/src/translator.target.darwin-arm.mk index a702dd64..9ffde69e 100644 --- a/src/translator.target.darwin-arm.mk +++ b/src/translator.target.darwin-arm.mk @@ -128,6 +128,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ @@ -214,6 +215,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ diff --git a/src/translator.target.darwin-mips.mk b/src/translator.target.darwin-mips.mk index 84b88f3b..af2a2d5d 100644 --- a/src/translator.target.darwin-mips.mk +++ b/src/translator.target.darwin-mips.mk @@ -128,6 +128,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ @@ -214,6 +215,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ diff --git a/src/translator.target.darwin-x86.mk b/src/translator.target.darwin-x86.mk index 550bf55c..39587236 100644 --- a/src/translator.target.darwin-x86.mk +++ b/src/translator.target.darwin-x86.mk @@ -130,6 +130,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ @@ -219,6 +220,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ diff --git a/src/translator.target.linux-arm.mk b/src/translator.target.linux-arm.mk index a702dd64..9ffde69e 100644 --- a/src/translator.target.linux-arm.mk +++ b/src/translator.target.linux-arm.mk @@ -128,6 +128,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ @@ -214,6 +215,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ diff --git a/src/translator.target.linux-mips.mk b/src/translator.target.linux-mips.mk index 84b88f3b..af2a2d5d 100644 --- a/src/translator.target.linux-mips.mk +++ b/src/translator.target.linux-mips.mk @@ -128,6 +128,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ @@ -214,6 +215,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ diff --git a/src/translator.target.linux-x86.mk b/src/translator.target.linux-x86.mk index 550bf55c..39587236 100644 --- a/src/translator.target.linux-x86.mk +++ b/src/translator.target.linux-x86.mk @@ -130,6 +130,7 @@ MY_DEFS_Debug := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ @@ -219,6 +220,7 @@ MY_DEFS_Release := \ '-DUSE_OPENSSL=1' \ '-DENABLE_EGLIMAGE=1' \ '-DCLD_VERSION=1' \ + '-DENABLE_MANAGED_USERS=1' \ '-DANGLE_TRANSLATOR_IMPLEMENTATION' \ '-DANDROID' \ '-D__GNU_SOURCE=1' \ diff --git a/tests/build_tests.gyp b/tests/build_tests.gyp index aa930f17..d485c834 100644 --- a/tests/build_tests.gyp +++ b/tests/build_tests.gyp @@ -14,6 +14,14 @@ 'sources': [ '../third_party/googletest/src/gtest-all.cc', ], + 'defines': [ + '_VARIADIC_MAX=10', + ], + 'direct_dependent_settings': { + 'defines': [ + '_VARIADIC_MAX=10', + ], + }, }, { 'target_name': 'gmock', @@ -26,6 +34,14 @@ 'sources': [ '../third_party/googlemock/src/gmock-all.cc', ], + 'defines': [ + '_VARIADIC_MAX=10', + ], + 'direct_dependent_settings': { + 'defines': [ + '_VARIADIC_MAX=10', + ], + }, }, { 'target_name': 'preprocessor_tests', diff --git a/tests/compiler_tests/ExpressionLimit_test.cpp b/tests/compiler_tests/ExpressionLimit_test.cpp index f671bad1..bb83a4e9 100644 --- a/tests/compiler_tests/ExpressionLimit_test.cpp +++ b/tests/compiler_tests/ExpressionLimit_test.cpp @@ -145,7 +145,7 @@ protected: const char* source, int compileOptions, const char* expected_error) { - bool success = ShCompile(compiler, &source, 1, compileOptions); + bool success = ShCompile(compiler, &source, 1, compileOptions) != 0; if (success) { success = !expected_error; } else { diff --git a/tests/preprocessor_tests/char_test.cpp b/tests/preprocessor_tests/char_test.cpp index e6576a0b..6ea5d808 100644 --- a/tests/preprocessor_tests/char_test.cpp +++ b/tests/preprocessor_tests/char_test.cpp @@ -82,7 +82,7 @@ TEST_P(CharTest, Identified) // Everything else is invalid. using testing::_; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_CHARACTER, _, str)); + print(pp::Diagnostics::PP_INVALID_CHARACTER, _, str)); } pp::Token token; diff --git a/tests/preprocessor_tests/comment_test.cpp b/tests/preprocessor_tests/comment_test.cpp index 27f78cf1..f0a2814f 100644 --- a/tests/preprocessor_tests/comment_test.cpp +++ b/tests/preprocessor_tests/comment_test.cpp @@ -62,7 +62,7 @@ TEST_F(BlockCommentTest, UnterminatedComment) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); using testing::_; - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_COMMENT, _, _)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_COMMENT, _, _)); pp::Token token; mPreprocessor.lex(&token); diff --git a/tests/preprocessor_tests/define_test.cpp b/tests/preprocessor_tests/define_test.cpp index bb72016b..fd3ae415 100644 --- a/tests/preprocessor_tests/define_test.cpp +++ b/tests/preprocessor_tests/define_test.cpp @@ -19,7 +19,7 @@ TEST_F(DefineTest, NonIdentifier) "2\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::UNEXPECTED_TOKEN, + print(pp::Diagnostics::PP_UNEXPECTED_TOKEN, pp::SourceLocation(0, 1), "2")); @@ -46,19 +46,19 @@ TEST_F(DefineTest, RedefinePredefined) "1\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, pp::SourceLocation(0, 1), "__LINE__")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, pp::SourceLocation(0, 3), "__FILE__")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, pp::SourceLocation(0, 5), "__VERSION__")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_REDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, pp::SourceLocation(0, 7), "GL_ES")); @@ -73,7 +73,7 @@ TEST_F(DefineTest, ReservedUnderScore1) "__foo\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_NAME_RESERVED, + print(pp::Diagnostics::PP_MACRO_NAME_RESERVED, pp::SourceLocation(0, 1), "__foo")); @@ -88,7 +88,7 @@ TEST_F(DefineTest, ReservedUnderScore2) "foo__bar\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_NAME_RESERVED, + print(pp::Diagnostics::PP_MACRO_NAME_RESERVED, pp::SourceLocation(0, 1), "foo__bar")); @@ -103,7 +103,7 @@ TEST_F(DefineTest, ReservedGL) "GL_foo\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_NAME_RESERVED, + print(pp::Diagnostics::PP_MACRO_NAME_RESERVED, pp::SourceLocation(0, 1), "GL_foo")); @@ -135,7 +135,7 @@ TEST_F(DefineTest, ObjRedefineInvalid) "(0)\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_REDEFINED, + print(pp::Diagnostics::PP_MACRO_REDEFINED, pp::SourceLocation(0, 2), "foo")); @@ -167,7 +167,7 @@ TEST_F(DefineTest, FuncRedefineInvalid) "( a )\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_REDEFINED, + print(pp::Diagnostics::PP_MACRO_REDEFINED, pp::SourceLocation(0, 2), "foo")); @@ -684,7 +684,7 @@ TEST_F(DefineTest, FuncMissingRightParen) "\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_UNTERMINATED_INVOCATION, + print(pp::Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION, pp::SourceLocation(0, 2), "foo")); @@ -703,15 +703,15 @@ TEST_F(DefineTest, FuncIncorrectArgCount) "\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_TOO_FEW_ARGS, + print(pp::Diagnostics::PP_MACRO_TOO_FEW_ARGS, pp::SourceLocation(0, 2), "foo")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_TOO_FEW_ARGS, + print(pp::Diagnostics::PP_MACRO_TOO_FEW_ARGS, pp::SourceLocation(0, 3), "foo")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_TOO_MANY_ARGS, + print(pp::Diagnostics::PP_MACRO_TOO_MANY_ARGS, pp::SourceLocation(0, 4), "foo")); @@ -752,19 +752,19 @@ TEST_F(DefineTest, UndefPredefined) "1\n"; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, pp::SourceLocation(0, 1), "__LINE__")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, pp::SourceLocation(0, 3), "__FILE__")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, pp::SourceLocation(0, 5), "__VERSION__")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED, + print(pp::Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, pp::SourceLocation(0, 7), "GL_ES")); diff --git a/tests/preprocessor_tests/error_test.cpp b/tests/preprocessor_tests/error_test.cpp index c9e0c40f..ac7cdba3 100644 --- a/tests/preprocessor_tests/error_test.cpp +++ b/tests/preprocessor_tests/error_test.cpp @@ -86,7 +86,7 @@ TEST_F(ErrorTest, MissingNewline) EXPECT_CALL(mDirectiveHandler, handleError(pp::SourceLocation(0, 1), " foo")); // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_DIRECTIVE, _, _)); preprocess(str, expected); } diff --git a/tests/preprocessor_tests/extension_test.cpp b/tests/preprocessor_tests/extension_test.cpp index 94b7eb70..0b8cf88b 100644 --- a/tests/preprocessor_tests/extension_test.cpp +++ b/tests/preprocessor_tests/extension_test.cpp @@ -61,7 +61,7 @@ TEST_F(ExtensionTest, MissingNewline) EXPECT_CALL(mDirectiveHandler, handleExtension(pp::SourceLocation(0, 1), "foo", "bar")); // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_DIRECTIVE, _, _)); preprocess(str, expected); } @@ -93,11 +93,11 @@ TEST_P(InvalidExtensionTest, Identified) } static const ExtensionTestParam kParams[] = { - {"#extension\n", pp::Diagnostics::INVALID_EXTENSION_DIRECTIVE}, - {"#extension 1\n", pp::Diagnostics::INVALID_EXTENSION_NAME}, - {"#extension foo bar\n", pp::Diagnostics::UNEXPECTED_TOKEN}, - {"#extension foo : \n", pp::Diagnostics::INVALID_EXTENSION_DIRECTIVE}, - {"#extension foo : 1\n", pp::Diagnostics::INVALID_EXTENSION_BEHAVIOR}, - {"#extension foo : bar baz\n", pp::Diagnostics::UNEXPECTED_TOKEN} + {"#extension\n", pp::Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE}, + {"#extension 1\n", pp::Diagnostics::PP_INVALID_EXTENSION_NAME}, + {"#extension foo bar\n", pp::Diagnostics::PP_UNEXPECTED_TOKEN}, + {"#extension foo : \n", pp::Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE}, + {"#extension foo : 1\n", pp::Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR}, + {"#extension foo : bar baz\n", pp::Diagnostics::PP_UNEXPECTED_TOKEN} }; INSTANTIATE_TEST_CASE_P(All, InvalidExtensionTest, testing::ValuesIn(kParams)); diff --git a/tests/preprocessor_tests/if_test.cpp b/tests/preprocessor_tests/if_test.cpp index 7a7548ff..2849887e 100644 --- a/tests/preprocessor_tests/if_test.cpp +++ b/tests/preprocessor_tests/if_test.cpp @@ -612,7 +612,7 @@ TEST_F(IfTest, MissingExpression) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_EXPRESSION, + print(pp::Diagnostics::PP_INVALID_EXPRESSION, pp::SourceLocation(0, 1), "syntax error")); @@ -627,7 +627,7 @@ TEST_F(IfTest, DivisionByZero) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::DIVISION_BY_ZERO, + print(pp::Diagnostics::PP_DIVISION_BY_ZERO, pp::SourceLocation(0, 1), "1 / 0")); pp::Token token; @@ -641,7 +641,7 @@ TEST_F(IfTest, ModuloByZero) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::DIVISION_BY_ZERO, + print(pp::Diagnostics::PP_DIVISION_BY_ZERO, pp::SourceLocation(0, 1), "1 % 0")); pp::Token token; @@ -655,7 +655,7 @@ TEST_F(IfTest, DecIntegerOverflow) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INTEGER_OVERFLOW, + print(pp::Diagnostics::PP_INTEGER_OVERFLOW, pp::SourceLocation(0, 1), "4294967296")); pp::Token token; @@ -669,7 +669,7 @@ TEST_F(IfTest, OctIntegerOverflow) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INTEGER_OVERFLOW, + print(pp::Diagnostics::PP_INTEGER_OVERFLOW, pp::SourceLocation(0, 1), "077777777777")); pp::Token token; @@ -683,7 +683,7 @@ TEST_F(IfTest, HexIntegerOverflow) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INTEGER_OVERFLOW, + print(pp::Diagnostics::PP_INTEGER_OVERFLOW, pp::SourceLocation(0, 1), "0xfffffffff")); pp::Token token; @@ -697,11 +697,11 @@ TEST_F(IfTest, UndefinedMacro) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_EXPRESSION, + print(pp::Diagnostics::PP_INVALID_EXPRESSION, pp::SourceLocation(0, 1), "syntax error")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, + print(pp::Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, pp::SourceLocation(0, 1), "UNDEFINED")); @@ -735,7 +735,7 @@ TEST_F(IfTest, ElseWithoutIf) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF, + print(pp::Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF, pp::SourceLocation(0, 1), "else")); @@ -749,7 +749,7 @@ TEST_F(IfTest, ElifWithoutIf) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF, + print(pp::Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF, pp::SourceLocation(0, 1), "elif")); @@ -763,7 +763,7 @@ TEST_F(IfTest, EndifWithoutIf) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF, + print(pp::Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF, pp::SourceLocation(0, 1), "endif")); @@ -780,7 +780,7 @@ TEST_F(IfTest, ElseAfterElse) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE, + print(pp::Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE, pp::SourceLocation(0, 3), "else")); @@ -797,7 +797,7 @@ TEST_F(IfTest, ElifAfterElse) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE, + print(pp::Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE, pp::SourceLocation(0, 3), "elif")); @@ -811,7 +811,7 @@ TEST_F(IfTest, UnterminatedIf) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_UNTERMINATED, + print(pp::Diagnostics::PP_CONDITIONAL_UNTERMINATED, pp::SourceLocation(0, 1), "if")); @@ -825,7 +825,7 @@ TEST_F(IfTest, UnterminatedIfdef) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::CONDITIONAL_UNTERMINATED, + print(pp::Diagnostics::PP_CONDITIONAL_UNTERMINATED, pp::SourceLocation(0, 1), "ifdef")); diff --git a/tests/preprocessor_tests/location_test.cpp b/tests/preprocessor_tests/location_test.cpp index b615f99c..eb81555b 100644 --- a/tests/preprocessor_tests/location_test.cpp +++ b/tests/preprocessor_tests/location_test.cpp @@ -77,7 +77,7 @@ TEST_F(LocationTest, ErrorLocationAfterComment) const char* str = "/*\n\n*/@"; ASSERT_TRUE(mPreprocessor.init(1, &str, NULL)); - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::INVALID_CHARACTER, + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_INVALID_CHARACTER, pp::SourceLocation(0, 3), "@")); @@ -261,7 +261,7 @@ TEST_F(LocationTest, LineDirectiveMissingNewline) using testing::_; // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_DIRECTIVE, _, _)); pp::Token token; mPreprocessor.lex(&token); @@ -292,12 +292,12 @@ TEST_P(InvalidLineTest, Identified) } static const LineTestParam kParams[] = { - {"#line\n", pp::Diagnostics::INVALID_LINE_DIRECTIVE}, - {"#line foo\n", pp::Diagnostics::INVALID_LINE_NUMBER}, - {"#line 10 foo\n", pp::Diagnostics::INVALID_FILE_NUMBER}, - {"#line 10 20 foo\n", pp::Diagnostics::UNEXPECTED_TOKEN}, - {"#line 0xffffffff\n", pp::Diagnostics::INTEGER_OVERFLOW}, - {"#line 10 0xffffffff\n", pp::Diagnostics::INTEGER_OVERFLOW} + {"#line\n", pp::Diagnostics::PP_INVALID_LINE_DIRECTIVE}, + {"#line foo\n", pp::Diagnostics::PP_INVALID_LINE_NUMBER}, + {"#line 10 foo\n", pp::Diagnostics::PP_INVALID_FILE_NUMBER}, + {"#line 10 20 foo\n", pp::Diagnostics::PP_UNEXPECTED_TOKEN}, + {"#line 0xffffffff\n", pp::Diagnostics::PP_INTEGER_OVERFLOW}, + {"#line 10 0xffffffff\n", pp::Diagnostics::PP_INTEGER_OVERFLOW} }; INSTANTIATE_TEST_CASE_P(All, InvalidLineTest, testing::ValuesIn(kParams)); diff --git a/tests/preprocessor_tests/number_test.cpp b/tests/preprocessor_tests/number_test.cpp index 13673212..9b2518b7 100644 --- a/tests/preprocessor_tests/number_test.cpp +++ b/tests/preprocessor_tests/number_test.cpp @@ -20,7 +20,7 @@ TEST_P(InvalidNumberTest, InvalidNumberIdentified) ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); using testing::_; - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::INVALID_NUMBER, _, str)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_INVALID_NUMBER, _, str)); pp::Token token; mPreprocessor.lex(&token); diff --git a/tests/preprocessor_tests/pragma_test.cpp b/tests/preprocessor_tests/pragma_test.cpp index a76fadae..de0fa98c 100644 --- a/tests/preprocessor_tests/pragma_test.cpp +++ b/tests/preprocessor_tests/pragma_test.cpp @@ -91,7 +91,7 @@ TEST_F(PragmaTest, MissingNewline) EXPECT_CALL(mDirectiveHandler, handlePragma(pp::SourceLocation(0, 1), "foo", "bar")); // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_DIRECTIVE, _, _)); preprocess(str, expected); } @@ -111,7 +111,7 @@ TEST_P(InvalidPragmaTest, Identified) EXPECT_CALL(mDirectiveHandler, handlePragma(_, _, _)).Times(0); // Unrecognized pragma warning. EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::UNRECOGNIZED_PRAGMA, + print(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, pp::SourceLocation(0, 1), _)); preprocess(str, expected); diff --git a/tests/preprocessor_tests/version_test.cpp b/tests/preprocessor_tests/version_test.cpp index 0db2fad1..1c490e50 100644 --- a/tests/preprocessor_tests/version_test.cpp +++ b/tests/preprocessor_tests/version_test.cpp @@ -57,7 +57,7 @@ TEST_F(VersionTest, MissingNewline) EXPECT_CALL(mDirectiveHandler, handleVersion(pp::SourceLocation(0, 1), 200)); // Error reported about EOF. - EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::EOF_IN_DIRECTIVE, _, _)); + EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_DIRECTIVE, _, _)); preprocess(str, expected); } @@ -104,7 +104,7 @@ TEST_F(VersionTest, AfterValidToken) using testing::_; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, + print(pp::Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, pp::SourceLocation(0, 2), _)); pp::Token token; @@ -122,10 +122,10 @@ TEST_F(VersionTest, AfterInvalidToken) using testing::_; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::INVALID_CHARACTER, + print(pp::Diagnostics::PP_INVALID_CHARACTER, pp::SourceLocation(0, 1), "$")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, + print(pp::Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, pp::SourceLocation(0, 2), _)); pp::Token token; @@ -143,7 +143,7 @@ TEST_F(VersionTest, AfterValidDirective) using testing::_; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, + print(pp::Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, pp::SourceLocation(0, 2), _)); pp::Token token; @@ -161,10 +161,10 @@ TEST_F(VersionTest, AfterInvalidDirective) using testing::_; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::DIRECTIVE_INVALID_NAME, + print(pp::Diagnostics::PP_DIRECTIVE_INVALID_NAME, pp::SourceLocation(0, 1), "foo")); EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, + print(pp::Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, pp::SourceLocation(0, 2), _)); pp::Token token; @@ -184,7 +184,7 @@ TEST_F(VersionTest, AfterExcludedBlock) using testing::_; EXPECT_CALL(mDiagnostics, - print(pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT, + print(pp::Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, pp::SourceLocation(0, 4), _)); pp::Token token; @@ -220,10 +220,10 @@ TEST_P(InvalidVersionTest, Identified) } static const VersionTestParam kParams[] = { - {"#version\n", pp::Diagnostics::INVALID_VERSION_DIRECTIVE}, - {"#version foo\n", pp::Diagnostics::INVALID_VERSION_NUMBER}, - {"#version 100 foo\n", pp::Diagnostics::UNEXPECTED_TOKEN}, - {"#version 0xffffffff\n", pp::Diagnostics::INTEGER_OVERFLOW} + {"#version\n", pp::Diagnostics::PP_INVALID_VERSION_DIRECTIVE}, + {"#version foo\n", pp::Diagnostics::PP_INVALID_VERSION_NUMBER}, + {"#version 100 foo\n", pp::Diagnostics::PP_UNEXPECTED_TOKEN}, + {"#version 0xffffffff\n", pp::Diagnostics::PP_INTEGER_OVERFLOW} }; INSTANTIATE_TEST_CASE_P(All, InvalidVersionTest, testing::ValuesIn(kParams)); |