blob: de4141d38c93a0239aa85ca3675bfd4861430513 [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
Zhenyao Moe40d1e92014-07-16 17:40:36 -07007#ifndef COMPILER_TRANSLATOR_VERSIONGLSL_H_
8#define COMPILER_TRANSLATOR_VERSIONGLSL_H_
alokp@chromium.org9ecf3952010-10-13 19:28:25 +00009
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
Zhenyao Moe40d1e92014-07-16 17:40:36 -070027class TVersionGLSL : public TIntermTraverser
28{
29 public:
Jamie Madill183bde52014-07-02 15:31:19 -040030 TVersionGLSL(sh::GLenum type);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000031
alokp@chromium.org8d47c112012-09-06 16:03:23 +000032 // Returns 120 if the following is used the shader:
33 // - "invariant",
34 // - "gl_PointCoord",
35 // - matrix/matrix constructors
36 // - array "out" parameters
37 // Else 110 is returned.
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000038 int getVersion() { return mVersion; }
39
Zhenyao Moe40d1e92014-07-16 17:40:36 -070040 virtual void visitSymbol(TIntermSymbol *);
41 virtual bool visitAggregate(Visit, TIntermAggregate *);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000042
Zhenyao Moe40d1e92014-07-16 17:40:36 -070043 protected:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000044 void updateVersion(int version);
45
Zhenyao Moe40d1e92014-07-16 17:40:36 -070046 private:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000047 int mVersion;
48};
49
Zhenyao Moe40d1e92014-07-16 17:40:36 -070050#endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_