summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 23:29:50 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 23:31:02 +0200
commit70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch)
tree3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
parent8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff)
downloadUXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip
Merge branch 'ANGLE-rollback'
This resolves #624 Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp105
1 files changed, 47 insertions, 58 deletions
diff --git a/gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp b/gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp
index 7ec434796..8cbeb7dee 100755
--- a/gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp
+++ b/gfx/angle/src/compiler/translator/PruneEmptyDeclarations.cpp
@@ -9,9 +9,6 @@
#include "compiler/translator/IntermNode.h"
-namespace sh
-{
-
namespace
{
@@ -21,7 +18,7 @@ class PruneEmptyDeclarationsTraverser : private TIntermTraverser
static void apply(TIntermNode *root);
private:
PruneEmptyDeclarationsTraverser();
- bool visitDeclaration(Visit, TIntermDeclaration *node) override;
+ bool visitAggregate(Visit, TIntermAggregate *node) override;
};
void PruneEmptyDeclarationsTraverser::apply(TIntermNode *root)
@@ -36,71 +33,65 @@ PruneEmptyDeclarationsTraverser::PruneEmptyDeclarationsTraverser()
{
}
-bool PruneEmptyDeclarationsTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
+bool PruneEmptyDeclarationsTraverser::visitAggregate(Visit, TIntermAggregate *node)
{
- TIntermSequence *sequence = node->getSequence();
- if (sequence->size() >= 1)
+ if (node->getOp() == EOpDeclaration)
{
- TIntermSymbol *sym = sequence->front()->getAsSymbolNode();
- // Prune declarations without a variable name, unless it's an interface block declaration.
- if (sym != nullptr && sym->getSymbol() == "" && !sym->isInterfaceBlock())
+ TIntermSequence *sequence = node->getSequence();
+ if (sequence->size() >= 1)
{
- if (sequence->size() > 1)
- {
- // Generate a replacement that will remove the empty declarator in the beginning of
- // a declarator list. Example of a declaration that will be changed:
- // float, a;
- // will be changed to
- // float a;
- // This applies also to struct declarations.
- TIntermSequence emptyReplacement;
- mMultiReplacements.push_back(
- NodeReplaceWithMultipleEntry(node, sym, emptyReplacement));
- }
- else if (sym->getBasicType() != EbtStruct)
+ TIntermSymbol *sym = sequence->front()->getAsSymbolNode();
+ // Prune declarations without a variable name, unless it's an interface block declaration.
+ if (sym != nullptr && sym->getSymbol() == "" && !sym->isInterfaceBlock())
{
- // Single struct declarations may just declare the struct type and no variables, so
- // they should not be pruned. All other single empty declarations can be pruned
- // entirely. Example of an empty declaration that will be pruned:
- // float;
- TIntermSequence emptyReplacement;
- TIntermBlock *parentAsBlock = getParentNode()->getAsBlock();
- // The declaration may be inside a block or in a loop init expression.
- ASSERT(parentAsBlock != nullptr || getParentNode()->getAsLoopNode() != nullptr);
- if (parentAsBlock)
+ if (sequence->size() > 1)
{
- mMultiReplacements.push_back(
- NodeReplaceWithMultipleEntry(parentAsBlock, node, emptyReplacement));
+ // Generate a replacement that will remove the empty declarator in the beginning of a declarator
+ // list. Example of a declaration that will be changed:
+ // float, a;
+ // will be changed to
+ // float a;
+ // This applies also to struct declarations.
+ TIntermSequence emptyReplacement;
+ mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(node, sym, emptyReplacement));
}
- else
+ else if (sym->getBasicType() != EbtStruct)
{
- queueReplacement(node, nullptr, OriginalNode::IS_DROPPED);
+ // Single struct declarations may just declare the struct type and no variables, so they should
+ // not be pruned. All other single empty declarations can be pruned entirely. Example of an empty
+ // declaration that will be pruned:
+ // float;
+ TIntermSequence emptyReplacement;
+ TIntermAggregate *parentAgg = getParentNode()->getAsAggregate();
+ ASSERT(parentAgg != nullptr);
+ mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(parentAgg, node, emptyReplacement));
}
- }
- else if (sym->getType().getQualifier() != EvqGlobal &&
- sym->getType().getQualifier() != EvqTemporary)
- {
- // We've hit an empty struct declaration with a qualifier, for example like
- // this:
- // const struct a { int i; };
- // NVIDIA GL driver version 367.27 doesn't accept this kind of declarations, so
- // we convert the declaration to a regular struct declaration. This is okay,
- // since ESSL 1.00 spec section 4.1.8 says about structs that "The optional
- // qualifiers only apply to any declarators, and are not part of the type being
- // defined for name."
-
- if (mInGlobalScope)
- {
- sym->getTypePointer()->setQualifier(EvqGlobal);
- }
- else
+ else if (sym->getType().getQualifier() != EvqGlobal &&
+ sym->getType().getQualifier() != EvqTemporary)
{
- sym->getTypePointer()->setQualifier(EvqTemporary);
+ // We've hit an empty struct declaration with a qualifier, for example like
+ // this:
+ // const struct a { int i; };
+ // NVIDIA GL driver version 367.27 doesn't accept this kind of declarations, so
+ // we convert the declaration to a regular struct declaration. This is okay,
+ // since ESSL 1.00 spec section 4.1.8 says about structs that "The optional
+ // qualifiers only apply to any declarators, and are not part of the type being
+ // defined for name."
+
+ if (mInGlobalScope)
+ {
+ sym->getTypePointer()->setQualifier(EvqGlobal);
+ }
+ else
+ {
+ sym->getTypePointer()->setQualifier(EvqTemporary);
+ }
}
}
}
+ return false;
}
- return false;
+ return true;
}
} // namespace
@@ -109,5 +100,3 @@ void PruneEmptyDeclarations(TIntermNode *root)
{
PruneEmptyDeclarationsTraverser::apply(root);
}
-
-} // namespace sh