• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "compiler/translator/OutputGLSL.h"
8 
TOutputGLSL(TInfoSinkBase & objSink,ShArrayIndexClampingStrategy clampingStrategy,ShHashFunction64 hashFunction,NameMap & nameMap,TSymbolTable & symbolTable,int shaderVersion)9 TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink,
10                          ShArrayIndexClampingStrategy clampingStrategy,
11                          ShHashFunction64 hashFunction,
12                          NameMap& nameMap,
13                          TSymbolTable& symbolTable,
14                          int shaderVersion)
15     : TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable, shaderVersion)
16 {
17 }
18 
writeVariablePrecision(TPrecision)19 bool TOutputGLSL::writeVariablePrecision(TPrecision)
20 {
21     return false;
22 }
23 
visitSymbol(TIntermSymbol * node)24 void TOutputGLSL::visitSymbol(TIntermSymbol* node)
25 {
26     TInfoSinkBase& out = objSink();
27 
28     if (node->getSymbol() == "gl_FragDepthEXT")
29     {
30         out << "gl_FragDepth";
31     }
32     else
33     {
34         TOutputGLSLBase::visitSymbol(node);
35     }
36 }
37 
translateTextureFunction(TString & name)38 TString TOutputGLSL::translateTextureFunction(TString& name)
39 {
40     static const char *simpleRename[] = {
41         "texture2DLodEXT", "texture2DLod",
42         "texture2DProjLodEXT", "texture2DProjLod",
43         "textureCubeLodEXT", "textureCubeLod",
44         "texture2DGradEXT", "texture2DGradARB",
45         "texture2DProjGradEXT", "texture2DProjGradARB",
46         "textureCubeGradEXT", "textureCubeGradARB",
47         NULL, NULL
48     };
49 
50     for (int i = 0; simpleRename[i] != NULL; i += 2) {
51         if (name == simpleRename[i]) {
52             return simpleRename[i+1];
53         }
54     }
55 
56     return name;
57 }
58