zenilib: zenilib/jni/external/angle/src/compiler/TranslatorGLSL.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TranslatorGLSL.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2002-2010 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/TranslatorGLSL.h"
8
9 #include "compiler/OutputGLSL.h"
10 #include "compiler/VersionGLSL.h"
11
12 static void writeVersion(ShShaderType type, TIntermNode* root,
13 TInfoSinkBase& sink) {
14 TVersionGLSL versionGLSL(type);
15 root->traverse(&versionGLSL);
16 int version = versionGLSL.getVersion();
17 // We need to write version directive only if it is greater than 110.
18 // If there is no version directive in the shader, 110 is implied.
19 if (version > 110) {
20 sink << "#version " << version << "\n";
21 }
22 }
23
24 TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
25 : TCompiler(type, spec) {
26 }
27
28 void TranslatorGLSL::translate(TIntermNode* root) {
29 TInfoSinkBase& sink = getInfoSink().obj;
30
31 // Write GLSL version.
32 writeVersion(getShaderType(), root, sink);
33
34 // Write emulated built-in functions if needed.
35 getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
36 sink, false);
37
38 // Write array bounds clamping emulation if needed.
39 getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
40
41 // Write translated shader.
42 TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable());
43 root->traverse(&outputGLSL);
44 }
TCompiler::getSymbolTable
TSymbolTable & getSymbolTable()
Definition: ShHandle.h:77
sink
GLsizei GLenum GLboolean sink
Definition: glew.h:4448
type
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
TCompiler::getShaderType
ShShaderType getShaderType() const
Definition: ShHandle.h:80
TCompiler::getBuiltInFunctionEmulator
const BuiltInFunctionEmulator & getBuiltInFunctionEmulator() const
Definition: Compiler.cpp:405
TVersionGLSL
Definition: VersionGLSL.h:27
version
int const char * version
Definition: zlib.h:813
TVersionGLSL::getVersion
int getVersion()
Definition: VersionGLSL.h:37
TranslatorGLSL::translate
virtual void translate(TIntermNode *root)
Definition: TranslatorGLSL.cpp:28
TCompiler::getArrayBoundsClamper
const ArrayBoundsClamper & getArrayBoundsClamper() const
Definition: Compiler.cpp:395
TCompiler::getInfoSink
TInfoSink & getInfoSink()
Definition: ShHandle.h:70
TranslatorGLSL.h
VersionGLSL.h
TInfoSinkBase
Definition: InfoSink.h:38
TOutputGLSL
Definition: OutputGLSL.h:12
TCompiler::getHashFunction
ShHashFunction64 getHashFunction() const
Definition: ShHandle.h:75
TCompiler::getArrayIndexClampingStrategy
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const
Definition: Compiler.cpp:400
TIntermNode::traverse
virtual void traverse(TIntermTraverser *)=0
TranslatorGLSL::TranslatorGLSL
TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
Definition: TranslatorGLSL.cpp:24
ArrayBoundsClamper::OutputClampingFunctionDefinition
void OutputClampingFunctionDefinition(TInfoSinkBase &out) const
Definition: ArrayBoundsClamper.cpp:95
TCompiler
Definition: ShHandle.h:58
ShShaderType
ShShaderType
Definition: ShaderLang.h:48
TIntermNode
Definition: intermediate.h:206
ShShaderSpec
ShShaderSpec
Definition: ShaderLang.h:53
TInfoSink::obj
TInfoSinkBase obj
Definition: InfoSink.h:112
OutputGLSL.h
TCompiler::getNameMap
NameMap & getNameMap()
Definition: ShHandle.h:76
BuiltInFunctionEmulator::OutputEmulatedFunctionDefinition
void OutputEmulatedFunctionDefinition(TInfoSinkBase &out, bool withPrecision) const
Definition: BuiltInFunctionEmulator.cpp:305
writeVersion
static void writeVersion(ShShaderType type, TIntermNode *root, TInfoSinkBase &sink)
Definition: TranslatorGLSL.cpp:12