blob: 2b63d5f25db977499fc088d1d7018ad1bd377b4a [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 Mo05b6b7f2015-03-02 17:08:09 -080032 TVersionGLSL(sh::GLenum type, const TPragma &pragma, ShShaderOutput output);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000033
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080034 // If output is core profile, returns 150.
35 // If output is legacy profile,
36 // Returns 120 if the following is used the shader:
37 // - "invariant",
38 // - "gl_PointCoord",
39 // - matrix/matrix constructors
40 // - array "out" parameters
41 // Else 110 is returned.
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000042 int getVersion() { return mVersion; }
43
Zhenyao Moe40d1e92014-07-16 17:40:36 -070044 virtual void visitSymbol(TIntermSymbol *);
45 virtual bool visitAggregate(Visit, TIntermAggregate *);
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000046
Zhenyao Moe40d1e92014-07-16 17:40:36 -070047 protected:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000048 void updateVersion(int version);
49
Zhenyao Moe40d1e92014-07-16 17:40:36 -070050 private:
alokp@chromium.org9ecf3952010-10-13 19:28:25 +000051 int mVersion;
52};
53
Zhenyao Moe40d1e92014-07-16 17:40:36 -070054#endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_