summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp b/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
index 98e010a56..de9050cd8 100755
--- a/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
+++ b/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
@@ -20,9 +20,6 @@
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/OutputHLSL.h"
-namespace sh
-{
-
namespace
{
@@ -32,7 +29,7 @@ class SeparateArrayInitTraverser : private TIntermTraverser
static void apply(TIntermNode *root);
private:
SeparateArrayInitTraverser();
- bool visitDeclaration(Visit, TIntermDeclaration *node) override;
+ bool visitAggregate(Visit, TIntermAggregate *node) override;
};
void SeparateArrayInitTraverser::apply(TIntermNode *root)
@@ -47,38 +44,44 @@ SeparateArrayInitTraverser::SeparateArrayInitTraverser()
{
}
-bool SeparateArrayInitTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
+bool SeparateArrayInitTraverser::visitAggregate(Visit, TIntermAggregate *node)
{
- TIntermSequence *sequence = node->getSequence();
- TIntermBinary *initNode = sequence->back()->getAsBinaryNode();
- if (initNode != nullptr && initNode->getOp() == EOpInitialize)
+ if (node->getOp() == EOpDeclaration)
{
- TIntermTyped *initializer = initNode->getRight();
- if (initializer->isArray() && !sh::OutputHLSL::canWriteAsHLSLLiteral(initializer))
+ TIntermSequence *sequence = node->getSequence();
+ TIntermBinary *initNode = sequence->back()->getAsBinaryNode();
+ if (initNode != nullptr && initNode->getOp() == EOpInitialize)
{
- // We rely on that array declarations have been isolated to single declarations.
- ASSERT(sequence->size() == 1);
- TIntermTyped *symbol = initNode->getLeft();
- TIntermBlock *parentBlock = getParentNode()->getAsBlock();
- ASSERT(parentBlock != nullptr);
+ TIntermTyped *initializer = initNode->getRight();
+ if (initializer->isArray() && !sh::OutputHLSL::canWriteAsHLSLLiteral(initializer))
+ {
+ // We rely on that array declarations have been isolated to single declarations.
+ ASSERT(sequence->size() == 1);
+ TIntermTyped *symbol = initNode->getLeft();
+ TIntermAggregate *parentAgg = getParentNode()->getAsAggregate();
+ ASSERT(parentAgg != nullptr);
- TIntermSequence replacements;
+ TIntermSequence replacements;
- TIntermDeclaration *replacementDeclaration = new TIntermDeclaration();
- replacementDeclaration->appendDeclarator(symbol);
- replacementDeclaration->setLine(symbol->getLine());
- replacements.push_back(replacementDeclaration);
+ TIntermAggregate *replacementDeclaration = new TIntermAggregate;
+ replacementDeclaration->setOp(EOpDeclaration);
+ replacementDeclaration->getSequence()->push_back(symbol);
+ replacementDeclaration->setLine(symbol->getLine());
+ replacements.push_back(replacementDeclaration);
- TIntermBinary *replacementAssignment =
- new TIntermBinary(EOpAssign, symbol, initializer);
- replacementAssignment->setLine(symbol->getLine());
- replacements.push_back(replacementAssignment);
+ TIntermBinary *replacementAssignment = new TIntermBinary(EOpAssign);
+ replacementAssignment->setLeft(symbol);
+ replacementAssignment->setRight(initializer);
+ replacementAssignment->setType(initializer->getType());
+ replacementAssignment->setLine(symbol->getLine());
+ replacements.push_back(replacementAssignment);
- mMultiReplacements.push_back(
- NodeReplaceWithMultipleEntry(parentBlock, node, replacements));
+ mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(parentAgg, node, replacements));
+ }
}
+ return false;
}
- return false;
+ return true;
}
} // namespace
@@ -87,5 +90,3 @@ void SeparateArrayInitialization(TIntermNode *root)
{
SeparateArrayInitTraverser::apply(root);
}
-
-} // namespace sh