blob: 04449e839abddfe5c51988327e84be60c58d4f85 [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
Geoff Lang7b9b2842015-06-15 11:02:49 -070014static const int GLSL_VERSION_110 = 110;
15static const int GLSL_VERSION_120 = 120;
16static const int GLSL_VERSION_130 = 130;
17static const int GLSL_VERSION_410 = 410;
18static const int GLSL_VERSION_420 = 420;
19
20int ShaderOutputTypeToGLSLVersion(ShShaderOutput output);
21
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000022// Traverses the intermediate tree to return the minimum GLSL version
23// required to legally access all built-in features used in the shader.
24// GLSL 1.1 which is mandated by OpenGL 2.0 provides:
25// - #version and #extension to declare version and extensions.
26// - built-in functions refract, exp, and log.
27// - updated step() to compare x < edge instead of x <= edge.
28// GLSL 1.2 which is mandated by OpenGL 2.1 provides:
29// - many changes to reduce differences when compared to the ES specification.
30// - invariant keyword and its support.
31// - c++ style name hiding rules.
32// - built-in variable gl_PointCoord for fragment shaders.
kbr@chromium.orge26cb5e2011-01-18 21:27:02 +000033// - matrix constructors taking matrix as argument.
alokp@chromium.org8d47c112012-09-06 16:03:23 +000034// - array as "out" function parameters
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000035//
Jamie Madill02f20dd2013-09-12 12:07:42 -040036// TODO: ES3 equivalent versions of GLSL
Zhenyao Moe40d1e92014-07-16 17:40:36 -070037class TVersionGLSL : public TIntermTraverser
38{
39 public:
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080040 TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000041
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080042 // If output is core profile, returns 150.
43 // If output is legacy profile,
44 // Returns 120 if the following is used the shader:
45 // - "invariant",
46 // - "gl_PointCoord",
47 // - matrix/matrix constructors
48 // - array "out" parameters
49 // Else 110 is returned.
Geoff Lang7b9b2842015-06-15 11:02:49 -070050 int getVersion() const { return mVersion; }
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000051
Zhenyao Moe40d1e92014-07-16 17:40:36 -070052 virtual void visitSymbol(TIntermSymbol *);
53 virtual bool visitAggregate(Visit, TIntermAggregate *);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000054
Zhenyao Moe40d1e92014-07-16 17:40:36 -070055 private:
Geoff Lang7b9b2842015-06-15 11:02:49 -070056 void ensureVersionIsAtLeast(int version);
57
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000058 int mVersion;
59};
60
Zhenyao Moe40d1e92014-07-16 17:40:36 -070061#endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_