2 // Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 #include "compiler/translator/IntermNode.h"
8 #include "compiler/translator/LoopInfo.h"
12 // Traverses intermediate tree to ensure that the shader does not exceed the
13 // minimum functionality mandated in GLSL 1.0 spec, Appendix A.
14 class ValidateLimitations : public TIntermTraverser
17 ValidateLimitations(sh::GLenum shaderType, TInfoSinkBase &sink);
19 int numErrors() const { return mNumErrors; }
21 virtual bool visitBinary(Visit, TIntermBinary *);
22 virtual bool visitUnary(Visit, TIntermUnary *);
23 virtual bool visitAggregate(Visit, TIntermAggregate *);
24 virtual bool visitLoop(Visit, TIntermLoop *);
27 void error(TSourceLoc loc, const char *reason, const char *token);
29 bool withinLoopBody() const;
30 bool isLoopIndex(TIntermSymbol *symbol);
31 bool validateLoopType(TIntermLoop *node);
33 bool validateForLoopHeader(TIntermLoop *node);
34 // If valid, return the index symbol id; Otherwise, return -1.
35 int validateForLoopInit(TIntermLoop *node);
36 bool validateForLoopCond(TIntermLoop *node, int indexSymbolId);
37 bool validateForLoopExpr(TIntermLoop *node, int indexSymbolId);
39 // Returns true if none of the loop indices is used as the argument to
40 // the given function out or inout parameter.
41 bool validateFunctionCall(TIntermAggregate *node);
42 bool validateOperation(TIntermOperator *node, TIntermNode *operand);
44 // Returns true if indexing does not exceed the minimum functionality
45 // mandated in GLSL 1.0 spec, Appendix A, Section 5.
46 bool isConstExpr(TIntermNode *node);
47 bool isConstIndexExpr(TIntermNode *node);
48 bool validateIndexing(TIntermBinary *node);
50 sh::GLenum mShaderType;
53 TLoopStack mLoopStack;