michael@0: // michael@0: // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #ifndef COMPILER_VERSIONGLSL_H_ michael@0: #define COMPILER_VERSIONGLSL_H_ michael@0: michael@0: #include "GLSLANG/ShaderLang.h" michael@0: #include "compiler/intermediate.h" michael@0: michael@0: // Traverses the intermediate tree to return the minimum GLSL version michael@0: // required to legally access all built-in features used in the shader. michael@0: // GLSL 1.1 which is mandated by OpenGL 2.0 provides: michael@0: // - #version and #extension to declare version and extensions. michael@0: // - built-in functions refract, exp, and log. michael@0: // - updated step() to compare x < edge instead of x <= edge. michael@0: // GLSL 1.2 which is mandated by OpenGL 2.1 provides: michael@0: // - many changes to reduce differences when compared to the ES specification. michael@0: // - invariant keyword and its support. michael@0: // - c++ style name hiding rules. michael@0: // - built-in variable gl_PointCoord for fragment shaders. michael@0: // - matrix constructors taking matrix as argument. michael@0: // - array as "out" function parameters michael@0: // michael@0: class TVersionGLSL : public TIntermTraverser { michael@0: public: michael@0: TVersionGLSL(ShShaderType type); michael@0: michael@0: // Returns 120 if the following is used the shader: michael@0: // - "invariant", michael@0: // - "gl_PointCoord", michael@0: // - matrix/matrix constructors michael@0: // - array "out" parameters michael@0: // Else 110 is returned. michael@0: int getVersion() { return mVersion; } michael@0: michael@0: virtual void visitSymbol(TIntermSymbol*); michael@0: virtual void visitConstantUnion(TIntermConstantUnion*); michael@0: virtual bool visitBinary(Visit, TIntermBinary*); michael@0: virtual bool visitUnary(Visit, TIntermUnary*); michael@0: virtual bool visitSelection(Visit, TIntermSelection*); michael@0: virtual bool visitAggregate(Visit, TIntermAggregate*); michael@0: virtual bool visitLoop(Visit, TIntermLoop*); michael@0: virtual bool visitBranch(Visit, TIntermBranch*); michael@0: michael@0: protected: michael@0: void updateVersion(int version); michael@0: michael@0: private: michael@0: ShShaderType mShaderType; michael@0: int mVersion; michael@0: }; michael@0: michael@0: #endif // COMPILER_VERSIONGLSL_H_