summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-08-05 12:59:44 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-08-05 16:43:22 +0200
commita6a12d8c0fc918972c15268f749ecc7c90b95d6c (patch)
treecb6d986d30ef97e932ab51768854d5d9b46729d3 /src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
parent14f9c09542bd6cc19430473da9ce4c68f239ec7d (diff)
ANGLE: upgrade to 2.1~07d49ef5350a
This version of ANGLE provides partial ES3 support, numerous bug fixes, and several potentially useful vendor extensions. All patches have been rebased. The following changes are noted: 0000-General-fixes-for-ANGLE-2.1.patch contains compile fixes for the new ANGLE 0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch has incorporated patch 0015. 0007-Make-DX9-DX11-mutually-exclusive.patch has been removed as it was fixed upstream. 0007-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch has been moved up to fill the patch number gap. 0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch now contains patch 0014 and 0017. 0013-ANGLE-Allow-for-universal-program-binaries.patch has been removed as it is no longer relevant. 0014-ANGLE-D3D11-Fix-internal-index-buffer-for-level-9-ha.patch has been merged with patch 0010. 0015-ANGLE-Don-t-export-DLLMain-functions-for-static-buil.patch has been merged with patch 0004. 0016-ANGLE-WinRT-Call-Trim-when-application-suspends.patch has been removed and will be replaced by a follow-up patch using a different technique. 0017-ANGLE-D3D11-Don-t-use-mipmaps-in-level-9-textures.patch has been merged with patch 0010. 0018-ANGLE-WinRT-Create-swap-chain-using-physical-resolut.patch has been removed and will be replaced by a follow-up patch extending the EGL_ANGLE_window_fixed_size extension. 0019-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch is now patch 0007. [ChangeLog][Third-party libraries] ANGLE has been upgraded to version 2.1, bringing partial support for OpenGL ES3 over Direct3D 11, numerous bug fixes, and several new vendor extensions. Change-Id: I6d95ce1480462d67228d83c1e5c74a1706b5b21c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp')
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp245
1 files changed, 56 insertions, 189 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp b/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
index 89e6f1a62b..f3be20d978 100644
--- a/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
@@ -6,210 +6,77 @@
#include "compiler/translator/ForLoopUnroll.h"
-namespace {
-
-class IntegerForLoopUnrollMarker : public TIntermTraverser {
-public:
-
- virtual bool visitLoop(Visit, TIntermLoop* node)
- {
- // This is called after ValidateLimitations pass, so all the ASSERT
- // should never fail.
- // See ValidateLimitations::validateForLoopInit().
- ASSERT(node);
- ASSERT(node->getType() == ELoopFor);
- ASSERT(node->getInit());
- TIntermAggregate* decl = node->getInit()->getAsAggregate();
- ASSERT(decl && decl->getOp() == EOpDeclaration);
- TIntermSequence& declSeq = decl->getSequence();
- ASSERT(declSeq.size() == 1);
- TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
- ASSERT(declInit && declInit->getOp() == EOpInitialize);
- ASSERT(declInit->getLeft());
- TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
- ASSERT(symbol);
- TBasicType type = symbol->getBasicType();
- ASSERT(type == EbtInt || type == EbtFloat);
- if (type == EbtInt)
- node->setUnrollFlag(true);
- return true;
- }
-
-};
-
-} // anonymous namepsace
-
-void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info)
+bool ForLoopUnrollMarker::visitBinary(Visit, TIntermBinary *node)
{
- ASSERT(node->getType() == ELoopFor);
- ASSERT(node->getUnrollFlag());
-
- TIntermNode* init = node->getInit();
- ASSERT(init != NULL);
- TIntermAggregate* decl = init->getAsAggregate();
- ASSERT((decl != NULL) && (decl->getOp() == EOpDeclaration));
- TIntermSequence& declSeq = decl->getSequence();
- ASSERT(declSeq.size() == 1);
- TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
- ASSERT((declInit != NULL) && (declInit->getOp() == EOpInitialize));
- TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
- ASSERT(symbol != NULL);
- ASSERT(symbol->getBasicType() == EbtInt);
-
- info.id = symbol->getId();
-
- ASSERT(declInit->getRight() != NULL);
- TIntermConstantUnion* initNode = declInit->getRight()->getAsConstantUnion();
- ASSERT(initNode != NULL);
-
- info.initValue = evaluateIntConstant(initNode);
- info.currentValue = info.initValue;
-
- TIntermNode* cond = node->getCondition();
- ASSERT(cond != NULL);
- TIntermBinary* binOp = cond->getAsBinaryNode();
- ASSERT(binOp != NULL);
- ASSERT(binOp->getRight() != NULL);
- ASSERT(binOp->getRight()->getAsConstantUnion() != NULL);
-
- info.incrementValue = getLoopIncrement(node);
- info.stopValue = evaluateIntConstant(
- binOp->getRight()->getAsConstantUnion());
- info.op = binOp->getOp();
-}
-
-void ForLoopUnroll::Step()
-{
- ASSERT(mLoopIndexStack.size() > 0);
- TLoopIndexInfo& info = mLoopIndexStack[mLoopIndexStack.size() - 1];
- info.currentValue += info.incrementValue;
-}
+ if (mUnrollCondition != kSamplerArrayIndex)
+ return true;
-bool ForLoopUnroll::SatisfiesLoopCondition()
-{
- ASSERT(mLoopIndexStack.size() > 0);
- TLoopIndexInfo& info = mLoopIndexStack[mLoopIndexStack.size() - 1];
- // Relational operator is one of: > >= < <= == or !=.
- switch (info.op) {
- case EOpEqual:
- return (info.currentValue == info.stopValue);
- case EOpNotEqual:
- return (info.currentValue != info.stopValue);
- case EOpLessThan:
- return (info.currentValue < info.stopValue);
- case EOpGreaterThan:
- return (info.currentValue > info.stopValue);
- case EOpLessThanEqual:
- return (info.currentValue <= info.stopValue);
- case EOpGreaterThanEqual:
- return (info.currentValue >= info.stopValue);
+ // If a sampler array index is also the loop index,
+ // 1) if the index type is integer, mark the loop for unrolling;
+ // 2) if the index type if float, set a flag to later fail compile.
+ switch (node->getOp())
+ {
+ case EOpIndexIndirect:
+ if (node->getLeft() != NULL && node->getRight() != NULL && node->getLeft()->getAsSymbolNode())
+ {
+ TIntermSymbol *symbol = node->getLeft()->getAsSymbolNode();
+ if (IsSampler(symbol->getBasicType()) && symbol->isArray() && !mLoopStack.empty())
+ {
+ mVisitSamplerArrayIndexNodeInsideLoop = true;
+ node->getRight()->traverse(this);
+ mVisitSamplerArrayIndexNodeInsideLoop = false;
+ // We have already visited all the children.
+ return false;
+ }
+ }
+ break;
default:
- UNREACHABLE();
+ break;
}
- return false;
+ return true;
}
-bool ForLoopUnroll::NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol)
+bool ForLoopUnrollMarker::visitLoop(Visit, TIntermLoop *node)
{
- for (TVector<TLoopIndexInfo>::iterator i = mLoopIndexStack.begin();
- i != mLoopIndexStack.end();
- ++i) {
- if (i->id == symbol->getId())
- return true;
+ if (mUnrollCondition == kIntegerIndex)
+ {
+ // Check if loop index type is integer.
+ // This is called after ValidateLimitations pass, so all the calls
+ // should be valid. See ValidateLimitations::validateForLoopInit().
+ TIntermSequence *declSeq = node->getInit()->getAsAggregate()->getSequence();
+ TIntermSymbol *symbol = (*declSeq)[0]->getAsBinaryNode()->getLeft()->getAsSymbolNode();
+ if (symbol->getBasicType() == EbtInt)
+ node->setUnrollFlag(true);
}
- return false;
-}
-int ForLoopUnroll::GetLoopIndexValue(TIntermSymbol* symbol)
-{
- for (TVector<TLoopIndexInfo>::iterator i = mLoopIndexStack.begin();
- i != mLoopIndexStack.end();
- ++i) {
- if (i->id == symbol->getId())
- return i->currentValue;
+ TIntermNode *body = node->getBody();
+ if (body != NULL)
+ {
+ mLoopStack.push(node);
+ body->traverse(this);
+ mLoopStack.pop();
}
- UNREACHABLE();
+ // The loop is fully processed - no need to visit children.
return false;
}
-void ForLoopUnroll::Push(TLoopIndexInfo& info)
-{
- mLoopIndexStack.push_back(info);
-}
-
-void ForLoopUnroll::Pop()
+void ForLoopUnrollMarker::visitSymbol(TIntermSymbol* symbol)
{
- mLoopIndexStack.pop_back();
-}
-
-// static
-void ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(
- TIntermNode* root)
-{
- ASSERT(root);
-
- IntegerForLoopUnrollMarker marker;
- root->traverse(&marker);
-}
-
-int ForLoopUnroll::getLoopIncrement(TIntermLoop* node)
-{
- TIntermNode* expr = node->getExpression();
- ASSERT(expr != NULL);
- // for expression has one of the following forms:
- // loop_index++
- // loop_index--
- // loop_index += constant_expression
- // loop_index -= constant_expression
- // ++loop_index
- // --loop_index
- // The last two forms are not specified in the spec, but I am assuming
- // its an oversight.
- TIntermUnary* unOp = expr->getAsUnaryNode();
- TIntermBinary* binOp = unOp ? NULL : expr->getAsBinaryNode();
-
- TOperator op = EOpNull;
- TIntermConstantUnion* incrementNode = NULL;
- if (unOp != NULL) {
- op = unOp->getOp();
- } else if (binOp != NULL) {
- op = binOp->getOp();
- ASSERT(binOp->getRight() != NULL);
- incrementNode = binOp->getRight()->getAsConstantUnion();
- ASSERT(incrementNode != NULL);
- }
-
- int increment = 0;
- // The operator is one of: ++ -- += -=.
- switch (op) {
- case EOpPostIncrement:
- case EOpPreIncrement:
- ASSERT((unOp != NULL) && (binOp == NULL));
- increment = 1;
- break;
- case EOpPostDecrement:
- case EOpPreDecrement:
- ASSERT((unOp != NULL) && (binOp == NULL));
- increment = -1;
- break;
- case EOpAddAssign:
- ASSERT((unOp == NULL) && (binOp != NULL));
- increment = evaluateIntConstant(incrementNode);
+ if (!mVisitSamplerArrayIndexNodeInsideLoop)
+ return;
+ TIntermLoop *loop = mLoopStack.findLoop(symbol);
+ if (loop)
+ {
+ switch (symbol->getBasicType())
+ {
+ case EbtFloat:
+ mSamplerArrayIndexIsFloatLoopIndex = true;
break;
- case EOpSubAssign:
- ASSERT((unOp == NULL) && (binOp != NULL));
- increment = - evaluateIntConstant(incrementNode);
+ case EbtInt:
+ loop->setUnrollFlag(true);
break;
- default:
- ASSERT(false);
+ default:
+ UNREACHABLE();
+ }
}
-
- return increment;
-}
-
-int ForLoopUnroll::evaluateIntConstant(TIntermConstantUnion* node)
-{
- ASSERT((node != NULL) && (node->getUnionArrayPointer() != NULL));
- return node->getIConst(0);
}
-