1 : //
2 : // Copyright (c) 2002-2011 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/TranslatorESSL.h"
8 :
9 : #include "compiler/OutputESSL.h"
10 :
11 0 : TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
12 0 : : TCompiler(type, spec) {
13 0 : }
14 :
15 0 : void TranslatorESSL::translate(TIntermNode* root) {
16 0 : TInfoSinkBase& sink = getInfoSink().obj;
17 :
18 : // Write built-in extension behaviors.
19 0 : writeExtensionBehavior();
20 :
21 : // Write emulated built-in functions if needed.
22 0 : getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
23 0 : sink, getShaderType() == SH_FRAGMENT_SHADER);
24 :
25 : // Write translated shader.
26 0 : TOutputESSL outputESSL(sink);
27 0 : root->traverse(&outputESSL);
28 0 : }
29 :
30 0 : void TranslatorESSL::writeExtensionBehavior() {
31 0 : TInfoSinkBase& sink = getInfoSink().obj;
32 0 : const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
33 0 : for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
34 0 : iter != extensionBehavior.end(); ++iter) {
35 0 : if (iter->second != EBhUndefined) {
36 0 : sink << "#extension " << iter->first << " : "
37 0 : << getBehaviorString(iter->second) << "\n";
38 : }
39 : }
40 0 : }
|