Hash :
19d1dc99
Author :
Date :
2016-03-08T17:18:46
Add option to limit the number of function parameters Trying to compile user-defined functions that have thousands of parameters introduces some instability in native compilers, so it is better to reject shaders with large numbers of function parameters in ANGLE. The check is only enabled if the SH_LIMIT_EXPRESSION_COMPLEXITY flag is turned on. The default limit for the number of parameters is 1024, but it can also be configured. BUG=angleproject:1338 TEST=angle_unittests Change-Id: I5c9b7a4e97e67f36e77f969368336fa8fffba1c3 Reviewed-on: https://chromium-review.googlesource.com/331970 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ValidateMaxParameters checks if function definitions have more than a set number of parameters.
#include "compiler/translator/ValidateMaxParameters.h"
ValidateMaxParameters::ValidateMaxParameters(unsigned int maxParameters)
: TIntermTraverser(true, false, false), mMaxParameters(maxParameters), mValid(true)
{
}
bool ValidateMaxParameters::visitAggregate(Visit visit, TIntermAggregate *node)
{
if (!mValid)
{
return false;
}
if (node->getOp() == EOpParameters && node->getSequence()->size() > mMaxParameters)
{
mValid = false;
}
return mValid;
}
bool ValidateMaxParameters::validate(TIntermNode *root, unsigned int maxParameters)
{
ValidateMaxParameters argsTraverser(maxParameters);
root->traverse(&argsTraverser);
return argsTraverser.mValid;
}