Line data Source code
1 : //
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.
5 : //
6 :
7 : #ifndef COMPILER_TRANSLATOR_VALIDATELIMITATIONS_H_
8 : #define COMPILER_TRANSLATOR_VALIDATELIMITATIONS_H_
9 :
10 : #include "compiler/translator/IntermNode.h"
11 :
12 : namespace sh
13 : {
14 :
15 : class TInfoSinkBase;
16 :
17 : // Traverses intermediate tree to ensure that the shader does not exceed the
18 : // minimum functionality mandated in GLSL 1.0 spec, Appendix A.
19 0 : class ValidateLimitations : public TIntermTraverser
20 : {
21 : public:
22 : ValidateLimitations(sh::GLenum shaderType, TInfoSinkBase *sink);
23 :
24 0 : int numErrors() const { return mNumErrors; }
25 :
26 : bool visitBinary(Visit, TIntermBinary *) override;
27 : bool visitUnary(Visit, TIntermUnary *) override;
28 : bool visitAggregate(Visit, TIntermAggregate *) override;
29 : bool visitLoop(Visit, TIntermLoop *) override;
30 :
31 : static bool IsLimitedForLoop(TIntermLoop *node);
32 :
33 : private:
34 : void error(TSourceLoc loc, const char *reason, const char *token);
35 :
36 : bool withinLoopBody() const;
37 : bool isLoopIndex(TIntermSymbol *symbol);
38 : bool validateLoopType(TIntermLoop *node);
39 :
40 : bool validateForLoopHeader(TIntermLoop *node);
41 : // If valid, return the index symbol id; Otherwise, return -1.
42 : int validateForLoopInit(TIntermLoop *node);
43 : bool validateForLoopCond(TIntermLoop *node, int indexSymbolId);
44 : bool validateForLoopExpr(TIntermLoop *node, int indexSymbolId);
45 :
46 : // Returns true if none of the loop indices is used as the argument to
47 : // the given function out or inout parameter.
48 : bool validateFunctionCall(TIntermAggregate *node);
49 : bool validateOperation(TIntermOperator *node, TIntermNode *operand);
50 :
51 : // Returns true if indexing does not exceed the minimum functionality
52 : // mandated in GLSL 1.0 spec, Appendix A, Section 5.
53 : bool isConstExpr(TIntermNode *node);
54 : bool isConstIndexExpr(TIntermNode *node);
55 : bool validateIndexing(TIntermBinary *node);
56 :
57 : sh::GLenum mShaderType;
58 : TInfoSinkBase *mSink;
59 : int mNumErrors;
60 : std::vector<int> mLoopSymbolIds;
61 : bool mValidateIndexing;
62 : bool mValidateInnerLoops;
63 : };
64 :
65 : } // namespace sh
66 :
67 : #endif // COMPILER_TRANSLATOR_VALIDATELIMITATIONS_H_
|