blob: 442e46d2dba11972b9d66235ed892fcfad4fe401 [file] [log] [blame]
alokp@chromium.org9ecf3952010-10-13 19:28:25 +00001//
Jamie Madill02f20dd2013-09-12 12:07:42 -04002// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org9ecf3952010-10-13 19:28:25 +00003// 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_VERSIONGLSL_H_
8#define COMPILER_VERSIONGLSL_H_
9
Geoff Lang17732822013-08-29 13:46:49 -040010#include "compiler/translator/intermediate.h"
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000011
12// Traverses the intermediate tree to return the minimum GLSL version
13// required to legally access all built-in features used in the shader.
14// GLSL 1.1 which is mandated by OpenGL 2.0 provides:
15// - #version and #extension to declare version and extensions.
16// - built-in functions refract, exp, and log.
17// - updated step() to compare x < edge instead of x <= edge.
18// GLSL 1.2 which is mandated by OpenGL 2.1 provides:
19// - many changes to reduce differences when compared to the ES specification.
20// - invariant keyword and its support.
21// - c++ style name hiding rules.
22// - built-in variable gl_PointCoord for fragment shaders.
kbr@chromium.orge26cb5e2011-01-18 21:27:02 +000023// - matrix constructors taking matrix as argument.
alokp@chromium.org8d47c112012-09-06 16:03:23 +000024// - array as "out" function parameters
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000025//
Jamie Madill02f20dd2013-09-12 12:07:42 -040026// TODO: ES3 equivalent versions of GLSL
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000027class TVersionGLSL : public TIntermTraverser {
28public:
Jamie Madill183bde52014-07-02 15:31:19 -040029 TVersionGLSL(sh::GLenum type);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000030
alokp@chromium.org8d47c112012-09-06 16:03:23 +000031 // Returns 120 if the following is used the shader:
32 // - "invariant",
33 // - "gl_PointCoord",
34 // - matrix/matrix constructors
35 // - array "out" parameters
36 // Else 110 is returned.
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000037 int getVersion() { return mVersion; }
38
39 virtual void visitSymbol(TIntermSymbol*);
40 virtual void visitConstantUnion(TIntermConstantUnion*);
41 virtual bool visitBinary(Visit, TIntermBinary*);
42 virtual bool visitUnary(Visit, TIntermUnary*);
43 virtual bool visitSelection(Visit, TIntermSelection*);
44 virtual bool visitAggregate(Visit, TIntermAggregate*);
45 virtual bool visitLoop(Visit, TIntermLoop*);
46 virtual bool visitBranch(Visit, TIntermBranch*);
47
48protected:
49 void updateVersion(int version);
50
51private:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000052 int mVersion;
53};
54
55#endif // COMPILER_VERSIONGLSL_H_