blob: 72368e39d6600ed9b8c9c155a58c326416df8362 [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
Jamie Madillb1a85f42014-08-19 15:23:24 -040010#include "compiler/translator/IntermNode.h"
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000011
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070012#include "compiler/translator/Pragma.h"
13
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000014// 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.orge26cb5e2011-01-18 21:27:02 +000025// - matrix constructors taking matrix as argument.
alokp@chromium.org8d47c112012-09-06 16:03:23 +000026// - array as "out" function parameters
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000027//
Jamie Madill02f20dd2013-09-12 12:07:42 -040028// TODO: ES3 equivalent versions of GLSL
Zhenyao Moe40d1e92014-07-16 17:40:36 -070029class TVersionGLSL : public TIntermTraverser
30{
31 public:
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070032 TVersionGLSL(sh::GLenum type, const TPragma &pragma);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000033
alokp@chromium.org8d47c112012-09-06 16:03:23 +000034 // 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.org9ecf3952010-10-13 19:28:25 +000040 int getVersion() { return mVersion; }
41
Zhenyao Moe40d1e92014-07-16 17:40:36 -070042 virtual void visitSymbol(TIntermSymbol *);
43 virtual bool visitAggregate(Visit, TIntermAggregate *);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000044
Zhenyao Moe40d1e92014-07-16 17:40:36 -070045 protected:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000046 void updateVersion(int version);
47
Zhenyao Moe40d1e92014-07-16 17:40:36 -070048 private:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000049 int mVersion;
50};
51
Zhenyao Moe40d1e92014-07-16 17:40:36 -070052#endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_