alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 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 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_VALIDATELIMITATIONS_H_ |
| 8 | #define COMPILER_TRANSLATOR_VALIDATELIMITATIONS_H_ |
| 9 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 10 | #include "compiler/translator/IntermNode.h" |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 11 | #include "compiler/translator/LoopInfo.h" |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 12 | |
| 13 | class TInfoSinkBase; |
| 14 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 15 | // Traverses intermediate tree to ensure that the shader does not exceed the |
| 16 | // minimum functionality mandated in GLSL 1.0 spec, Appendix A. |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 17 | class ValidateLimitations : public TIntermTraverser |
| 18 | { |
| 19 | public: |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 20 | ValidateLimitations(sh::GLenum shaderType, TInfoSinkBase &sink); |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 21 | |
| 22 | int numErrors() const { return mNumErrors; } |
| 23 | |
Corentin Wallez | e5a1f27 | 2015-08-21 02:58:25 +0200 | [diff] [blame^] | 24 | bool visitBinary(Visit, TIntermBinary *) override; |
| 25 | bool visitUnary(Visit, TIntermUnary *) override; |
| 26 | bool visitAggregate(Visit, TIntermAggregate *) override; |
| 27 | bool visitLoop(Visit, TIntermLoop *) override; |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 28 | |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 29 | private: |
| 30 | void error(TSourceLoc loc, const char *reason, const char *token); |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 31 | |
| 32 | bool withinLoopBody() const; |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 33 | bool isLoopIndex(TIntermSymbol *symbol); |
| 34 | bool validateLoopType(TIntermLoop *node); |
| 35 | |
| 36 | bool validateForLoopHeader(TIntermLoop *node); |
| 37 | // If valid, return the index symbol id; Otherwise, return -1. |
| 38 | int validateForLoopInit(TIntermLoop *node); |
| 39 | bool validateForLoopCond(TIntermLoop *node, int indexSymbolId); |
| 40 | bool validateForLoopExpr(TIntermLoop *node, int indexSymbolId); |
| 41 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 42 | // Returns true if none of the loop indices is used as the argument to |
| 43 | // the given function out or inout parameter. |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 44 | bool validateFunctionCall(TIntermAggregate *node); |
| 45 | bool validateOperation(TIntermOperator *node, TIntermNode *operand); |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 46 | |
| 47 | // Returns true if indexing does not exceed the minimum functionality |
| 48 | // mandated in GLSL 1.0 spec, Appendix A, Section 5. |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 49 | bool isConstExpr(TIntermNode *node); |
| 50 | bool isConstIndexExpr(TIntermNode *node); |
| 51 | bool validateIndexing(TIntermBinary *node); |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 52 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 53 | sh::GLenum mShaderType; |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 54 | TInfoSinkBase &mSink; |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 55 | int mNumErrors; |
| 56 | TLoopStack mLoopStack; |
| 57 | }; |
| 58 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 59 | #endif // COMPILER_TRANSLATOR_VALIDATELIMITATIONS_H_ |