1 //
2 // Copyright 2002 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/OutputESSL.h"
8
9 namespace sh
10 {
11
TOutputESSL(TInfoSinkBase & objSink,ShArrayIndexClampingStrategy clampingStrategy,ShHashFunction64 hashFunction,NameMap & nameMap,TSymbolTable * symbolTable,sh::GLenum shaderType,int shaderVersion,bool forceHighp,ShCompileOptions compileOptions)12 TOutputESSL::TOutputESSL(TInfoSinkBase &objSink,
13 ShArrayIndexClampingStrategy clampingStrategy,
14 ShHashFunction64 hashFunction,
15 NameMap &nameMap,
16 TSymbolTable *symbolTable,
17 sh::GLenum shaderType,
18 int shaderVersion,
19 bool forceHighp,
20 ShCompileOptions compileOptions)
21 : TOutputGLSLBase(objSink,
22 clampingStrategy,
23 hashFunction,
24 nameMap,
25 symbolTable,
26 shaderType,
27 shaderVersion,
28 SH_ESSL_OUTPUT,
29 compileOptions),
30 mForceHighp(forceHighp)
31 {}
32
writeVariablePrecision(TPrecision precision)33 bool TOutputESSL::writeVariablePrecision(TPrecision precision)
34 {
35 if (precision == EbpUndefined)
36 return false;
37
38 TInfoSinkBase &out = objSink();
39 if (mForceHighp)
40 out << getPrecisionString(EbpHigh);
41 else
42 out << getPrecisionString(precision);
43 return true;
44 }
45
translateTextureFunction(const ImmutableString & name,const ShCompileOptions & option)46 ImmutableString TOutputESSL::translateTextureFunction(const ImmutableString &name,
47 const ShCompileOptions &option)
48 {
49 // Check WEBGL_video_texture invocation first.
50 if (name == "textureVideoWEBGL")
51 {
52 if (option & SH_TAKE_VIDEO_TEXTURE_AS_EXTERNAL_OES)
53 {
54 // TODO(http://anglebug.com/3889): Implement external image situation.
55 UNIMPLEMENTED();
56 return ImmutableString("");
57 }
58 else
59 {
60 // Default translating textureVideoWEBGL to texture2D.
61 return ImmutableString("texture2D");
62 }
63 }
64
65 return name;
66 }
67
68 } // namespace sh
69