diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp | 73 |
1 files changed, 50 insertions, 23 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp b/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp index 12367066e8..ba8cdd0aa8 100644 --- a/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp +++ b/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp @@ -26,12 +26,16 @@ class ValidateConstIndexExpr : public TIntermTraverser { public: ValidateConstIndexExpr(TLoopStack& stack) - : mValid(true), mLoopStack(stack) {} + : TIntermTraverser(true, false, false), + mValid(true), + mLoopStack(stack) + { + } // Returns true if the parsed node represents a constant index expression. bool isValid() const { return mValid; } - virtual void visitSymbol(TIntermSymbol *symbol) + void visitSymbol(TIntermSymbol *symbol) override { // Only constants and loop indices are allowed in a // constant index expression. @@ -49,12 +53,35 @@ class ValidateConstIndexExpr : public TIntermTraverser } // namespace anonymous -ValidateLimitations::ValidateLimitations(sh::GLenum shaderType, - TInfoSinkBase &sink) - : mShaderType(shaderType), +ValidateLimitations::ValidateLimitations(sh::GLenum shaderType, TInfoSinkBase *sink) + : TIntermTraverser(true, false, false), + mShaderType(shaderType), mSink(sink), - mNumErrors(0) + mNumErrors(0), + mValidateIndexing(true), + mValidateInnerLoops(true) +{ +} + +// static +bool ValidateLimitations::IsLimitedForLoop(TIntermLoop *loop) { + // The shader type doesn't matter in this case. + ValidateLimitations validate(GL_FRAGMENT_SHADER, nullptr); + validate.mValidateIndexing = false; + validate.mValidateInnerLoops = false; + if (!validate.validateLoopType(loop)) + return false; + if (!validate.validateForLoopHeader(loop)) + return false; + TIntermNode *body = loop->getBody(); + if (body != nullptr) + { + validate.mLoopStack.push(loop); + body->traverse(&validate); + validate.mLoopStack.pop(); + } + return (validate.mNumErrors == 0); } bool ValidateLimitations::visitBinary(Visit, TIntermBinary *node) @@ -67,10 +94,11 @@ bool ValidateLimitations::visitBinary(Visit, TIntermBinary *node) { case EOpIndexDirect: case EOpIndexIndirect: - validateIndexing(node); - break; + if (mValidateIndexing) + validateIndexing(node); + break; default: - break; + break; } return true; } @@ -97,6 +125,9 @@ bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate *node) bool ValidateLimitations::visitLoop(Visit, TIntermLoop *node) { + if (!mValidateInnerLoops) + return true; + if (!validateLoopType(node)) return false; @@ -118,9 +149,12 @@ bool ValidateLimitations::visitLoop(Visit, TIntermLoop *node) void ValidateLimitations::error(TSourceLoc loc, const char *reason, const char *token) { - mSink.prefix(EPrefixError); - mSink.location(loc); - mSink << "'" << token << "' : " << reason << "\n"; + if (mSink) + { + mSink->prefix(EPrefixError); + mSink->location(loc); + (*mSink) << "'" << token << "' : " << reason << "\n"; + } ++mNumErrors; } @@ -389,13 +423,13 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate *node) bool valid = true; TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable; - TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->shaderVersion); + TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->getShaderVersion()); ASSERT(symbol && symbol->isFunction()); TFunction *function = static_cast<TFunction *>(symbol); for (ParamIndex::const_iterator i = pIndex.begin(); i != pIndex.end(); ++i) { - const TParameter ¶m = function->getParam(*i); + const TConstParameter ¶m = function->getParam(*i); TQualifier qual = param.type->getQualifier(); if ((qual == EvqOut) || (qual == EvqInOut)) { @@ -428,8 +462,8 @@ bool ValidateLimitations::validateOperation(TIntermOperator *node, bool ValidateLimitations::isConstExpr(TIntermNode *node) { - ASSERT(node != NULL); - return node->getAsConstantUnion() != NULL; + ASSERT(node != nullptr); + return node->getAsConstantUnion() != nullptr && node->getAsTyped()->getQualifier() == EvqConst; } bool ValidateLimitations::isConstIndexExpr(TIntermNode *node) @@ -448,13 +482,6 @@ bool ValidateLimitations::validateIndexing(TIntermBinary *node) bool valid = true; TIntermTyped *index = node->getRight(); - // The index expression must have integral type. - if (!index->isScalarInt()) { - error(index->getLine(), - "Index expression must have integral type", - index->getCompleteString().c_str()); - valid = false; - } // The index expession must be a constant-index-expression unless // the operand is a uniform in a vertex shader. TIntermTyped *operand = node->getLeft(); |