1// 2// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. 3// Use of this source code is governed by a BSD-style license that can be 4// found in the LICENSE file. 5// 6 7#ifndef COMPILER_TRANSLATOR_VERSIONGLSL_H_ 8#define COMPILER_TRANSLATOR_VERSIONGLSL_H_ 9 10#include "compiler/translator/IntermNode.h" 11 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. 23// - matrix constructors taking matrix as argument. 24// - array as "out" function parameters 25// 26// TODO: ES3 equivalent versions of GLSL 27class TVersionGLSL : public TIntermTraverser 28{ 29 public: 30 TVersionGLSL(sh::GLenum type); 31 32 // 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. 38 int getVersion() { return mVersion; } 39 40 virtual void visitSymbol(TIntermSymbol *); 41 virtual bool visitAggregate(Visit, TIntermAggregate *); 42 43 protected: 44 void updateVersion(int version); 45 46 private: 47 int mVersion; 48}; 49 50#endif // COMPILER_TRANSLATOR_VERSIONGLSL_H_ 51