alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 1 | // |
Jamie Madill | 02f20dd | 2013-09-12 12:07:42 -0400 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_VERSIONGLSL_H_ |
| 8 | #define COMPILER_TRANSLATOR_VERSIONGLSL_H_ |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 9 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 10 | #include "compiler/translator/IntermNode.h" |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 11 | |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame^] | 12 | #include "compiler/translator/Pragma.h" |
| 13 | |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 14 | // Traverses the intermediate tree to return the minimum GLSL version |
| 15 | // required to legally access all built-in features used in the shader. |
| 16 | // GLSL 1.1 which is mandated by OpenGL 2.0 provides: |
| 17 | // - #version and #extension to declare version and extensions. |
| 18 | // - built-in functions refract, exp, and log. |
| 19 | // - updated step() to compare x < edge instead of x <= edge. |
| 20 | // GLSL 1.2 which is mandated by OpenGL 2.1 provides: |
| 21 | // - many changes to reduce differences when compared to the ES specification. |
| 22 | // - invariant keyword and its support. |
| 23 | // - c++ style name hiding rules. |
| 24 | // - built-in variable gl_PointCoord for fragment shaders. |
kbr@chromium.org | e26cb5e | 2011-01-18 21:27:02 +0000 | [diff] [blame] | 25 | // - matrix constructors taking matrix as argument. |
alokp@chromium.org | 8d47c11 | 2012-09-06 16:03:23 +0000 | [diff] [blame] | 26 | // - array as "out" function parameters |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 27 | // |
Jamie Madill | 02f20dd | 2013-09-12 12:07:42 -0400 | [diff] [blame] | 28 | // TODO: ES3 equivalent versions of GLSL |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 29 | class TVersionGLSL : public TIntermTraverser |
| 30 | { |
| 31 | public: |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame^] | 32 | TVersionGLSL(sh::GLenum type, const TPragma &pragma); |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 33 | |
alokp@chromium.org | 8d47c11 | 2012-09-06 16:03:23 +0000 | [diff] [blame] | 34 | // Returns 120 if the following is used the shader: |
| 35 | // - "invariant", |
| 36 | // - "gl_PointCoord", |
| 37 | // - matrix/matrix constructors |
| 38 | // - array "out" parameters |
| 39 | // Else 110 is returned. |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 40 | int getVersion() { return mVersion; } |
| 41 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 42 | virtual void visitSymbol(TIntermSymbol *); |
| 43 | virtual bool visitAggregate(Visit, TIntermAggregate *); |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 44 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 45 | protected: |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 46 | void updateVersion(int version); |
| 47 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 48 | private: |
alokp@chromium.org | 9ecf395 | 2010-10-13 19:28:25 +0000 | [diff] [blame] | 49 | int mVersion; |
| 50 | }; |
| 51 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 52 | #endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_ |