summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp')
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp b/src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp
index 2461b6a438..492972b60d 100644
--- a/src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp
@@ -6,8 +6,12 @@
#include "compiler/translator/ValidateGlobalInitializer.h"
+#include "compiler/translator/IntermTraverse.h"
#include "compiler/translator/ParseContext.h"
+namespace sh
+{
+
namespace
{
@@ -32,7 +36,8 @@ class ValidateGlobalInitializerTraverser : public TIntermTraverser
void ValidateGlobalInitializerTraverser::visitSymbol(TIntermSymbol *node)
{
- const TSymbol *sym = mContext->symbolTable.find(node->getSymbol(), mContext->getShaderVersion());
+ const TSymbol *sym =
+ mContext->symbolTable.find(node->getSymbol(), mContext->getShaderVersion());
if (sym->isVariable())
{
// ESSL 1.00 section 4.3 (or ESSL 3.00 section 4.3):
@@ -40,33 +45,36 @@ void ValidateGlobalInitializerTraverser::visitSymbol(TIntermSymbol *node)
const TVariable *var = static_cast<const TVariable *>(sym);
switch (var->getType().getQualifier())
{
- case EvqConst:
- break;
- case EvqGlobal:
- case EvqTemporary:
- case EvqUniform:
- // We allow these cases to be compatible with legacy ESSL 1.00 content.
- // Implement stricter rules for ESSL 3.00 since there's no legacy content to deal with.
- if (mContext->getShaderVersion() >= 300)
- {
+ case EvqConst:
+ break;
+ case EvqGlobal:
+ case EvqTemporary:
+ case EvqUniform:
+ // We allow these cases to be compatible with legacy ESSL 1.00 content.
+ // Implement stricter rules for ESSL 3.00 since there's no legacy content to deal
+ // with.
+ if (mContext->getShaderVersion() >= 300)
+ {
+ mIsValid = false;
+ }
+ else
+ {
+ mIssueWarning = true;
+ }
+ break;
+ default:
mIsValid = false;
- }
- else
- {
- mIssueWarning = true;
- }
- break;
- default:
- mIsValid = false;
}
}
}
bool ValidateGlobalInitializerTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{
- // Disallow calls to user-defined functions and texture lookup functions in global variable initializers.
- // This is done simply by disabling all function calls - built-in math functions don't use EOpFunctionCall.
- if (node->getOp() == EOpFunctionCall)
+ // Disallow calls to user-defined functions and texture lookup functions in global variable
+ // initializers.
+ // This is done simply by disabling all function calls - built-in math functions don't use
+ // the function call ops.
+ if (node->isFunctionCall())
{
mIsValid = false;
}
@@ -92,16 +100,15 @@ bool ValidateGlobalInitializerTraverser::visitUnary(Visit visit, TIntermUnary *n
}
ValidateGlobalInitializerTraverser::ValidateGlobalInitializerTraverser(const TParseContext *context)
- : TIntermTraverser(true, false, false),
- mContext(context),
- mIsValid(true),
- mIssueWarning(false)
+ : TIntermTraverser(true, false, false), mContext(context), mIsValid(true), mIssueWarning(false)
{
}
-} // namespace
+} // namespace
-bool ValidateGlobalInitializer(TIntermTyped *initializer, const TParseContext *context, bool *warning)
+bool ValidateGlobalInitializer(TIntermTyped *initializer,
+ const TParseContext *context,
+ bool *warning)
{
ValidateGlobalInitializerTraverser validate(context);
initializer->traverse(&validate);
@@ -110,3 +117,4 @@ bool ValidateGlobalInitializer(TIntermTyped *initializer, const TParseContext *c
return validate.isValid();
}
+} // namespace sh