blob: 3bd33819c10dfd3ecbd087b06914d81ec9ff1cfe [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;
Geoff Lang8273e002015-06-15 13:40:19 -070017static const int GLSL_VERSION_140 = 140;
18static const int GLSL_VERSION_150 = 150;
19static const int GLSL_VERSION_330 = 330;
20static const int GLSL_VERSION_400 = 400;
Geoff Lang7b9b2842015-06-15 11:02:49 -070021static const int GLSL_VERSION_410 = 410;
22static const int GLSL_VERSION_420 = 420;
Geoff Lang8273e002015-06-15 13:40:19 -070023static const int GLSL_VERSION_430 = 430;
24static const int GLSL_VERSION_440 = 440;
25static const int GLSL_VERSION_450 = 450;
Geoff Lang7b9b2842015-06-15 11:02:49 -070026
27int ShaderOutputTypeToGLSLVersion(ShShaderOutput output);
28
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000029// Traverses the intermediate tree to return the minimum GLSL version
30// required to legally access all built-in features used in the shader.
31// GLSL 1.1 which is mandated by OpenGL 2.0 provides:
32// - #version and #extension to declare version and extensions.
33// - built-in functions refract, exp, and log.
34// - updated step() to compare x < edge instead of x <= edge.
35// GLSL 1.2 which is mandated by OpenGL 2.1 provides:
36// - many changes to reduce differences when compared to the ES specification.
37// - invariant keyword and its support.
38// - c++ style name hiding rules.
39// - built-in variable gl_PointCoord for fragment shaders.
kbr@chromium.orge26cb5e2011-01-18 21:27:02 +000040// - matrix constructors taking matrix as argument.
alokp@chromium.org8d47c112012-09-06 16:03:23 +000041// - array as "out" function parameters
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000042//
Jamie Madill02f20dd2013-09-12 12:07:42 -040043// TODO: ES3 equivalent versions of GLSL
Zhenyao Moe40d1e92014-07-16 17:40:36 -070044class TVersionGLSL : public TIntermTraverser
45{
46 public:
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080047 TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000048
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080049 // If output is core profile, returns 150.
50 // If output is legacy profile,
51 // Returns 120 if the following is used the shader:
52 // - "invariant",
53 // - "gl_PointCoord",
54 // - matrix/matrix constructors
55 // - array "out" parameters
56 // Else 110 is returned.
Geoff Lang7b9b2842015-06-15 11:02:49 -070057 int getVersion() const { return mVersion; }
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000058
Zhenyao Moe40d1e92014-07-16 17:40:36 -070059 virtual void visitSymbol(TIntermSymbol *);
60 virtual bool visitAggregate(Visit, TIntermAggregate *);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000061
Zhenyao Moe40d1e92014-07-16 17:40:36 -070062 private:
Geoff Lang7b9b2842015-06-15 11:02:49 -070063 void ensureVersionIsAtLeast(int version);
64
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000065 int mVersion;
66};
67
Zhenyao Moe40d1e92014-07-16 17:40:36 -070068#endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_