Fold user-definedness of function nodes into TOperator
Whether a function call is user-defined is not orthogonal to TOperator
associated with the call node - other ops than function calls can't be
user-defined. Because of this it makes sense to store the user-
definedness by having different TOperator enums for different types of
calls.
This patch also tags internal helper functions that have a raw
definition outside the AST with a separate TOperator enum. This way
they can be handled with logic that is easy to understand. Before this,
function calls like this left the user-defined bit unset, despite not
really being built-ins either. The EmulatePrecision traverser uses
this. This is also something that could be used to clean up built-in
emulation in the future.
BUG=angleproject:1490
TEST=angle_unittests
Change-Id: I597fcd9789d0cc22b689ef3ce5a0cc3f621d4859
Reviewed-on: https://chromium-review.googlesource.com/433443
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ASTMetadataHLSL.cpp b/src/compiler/translator/ASTMetadataHLSL.cpp
index 5301b04..d37b3dc 100644
--- a/src/compiler/translator/ASTMetadataHLSL.cpp
+++ b/src/compiler/translator/ASTMetadataHLSL.cpp
@@ -102,27 +102,23 @@
{
if (visit == PreVisit)
{
- if (node->getOp() == EOpFunctionCall)
+ if (node->getOp() == EOpCallFunctionInAST)
{
- if (node->isUserDefined())
- {
- size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
- ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
+ size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
+ ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
- if ((*mMetadataList)[calleeIndex].mUsesGradient)
- {
- onGradient();
- }
+ if ((*mMetadataList)[calleeIndex].mUsesGradient)
+ {
+ onGradient();
}
- else
- {
- TString name =
- TFunction::unmangleName(node->getFunctionSymbolInfo()->getName());
+ }
+ else if (node->getOp() == EOpCallBuiltInFunction)
+ {
+ TString name = TFunction::unmangleName(node->getFunctionSymbolInfo()->getName());
- if (name == "texture2D" || name == "texture2DProj" || name == "textureCube")
- {
- onGradient();
- }
+ if (name == "texture2D" || name == "texture2DProj" || name == "textureCube")
+ {
+ onGradient();
}
}
}
@@ -273,17 +269,14 @@
bool visitAggregate(Visit visit, TIntermAggregate *node) override
{
- if (visit == PreVisit && node->getOp() == EOpFunctionCall)
+ if (visit == PreVisit && node->getOp() == EOpCallFunctionInAST)
{
- if (node->isUserDefined())
- {
- size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
- ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
+ size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
+ ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
- if ((*mMetadataList)[calleeIndex].mHasGradientLoopInCallGraph)
- {
- onGradientLoop();
- }
+ if ((*mMetadataList)[calleeIndex].mHasGradientLoopInCallGraph)
+ {
+ onGradientLoop();
}
}
@@ -354,8 +347,8 @@
{
switch (node->getOp())
{
- case EOpFunctionCall:
- if (visit == PreVisit && node->isUserDefined() && mNestedDiscont > 0)
+ case EOpCallFunctionInAST:
+ if (visit == PreVisit && mNestedDiscont > 0)
{
size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);