Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
michael@0 | 1 | // |
michael@0 | 2 | // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | #include "compiler/TranslatorESSL.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "compiler/OutputESSL.h" |
michael@0 | 10 | |
michael@0 | 11 | TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec) |
michael@0 | 12 | : TCompiler(type, spec) { |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | void TranslatorESSL::translate(TIntermNode* root) { |
michael@0 | 16 | TInfoSinkBase& sink = getInfoSink().obj; |
michael@0 | 17 | |
michael@0 | 18 | // Write built-in extension behaviors. |
michael@0 | 19 | writeExtensionBehavior(); |
michael@0 | 20 | |
michael@0 | 21 | // Write emulated built-in functions if needed. |
michael@0 | 22 | getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( |
michael@0 | 23 | sink, getShaderType() == SH_FRAGMENT_SHADER); |
michael@0 | 24 | |
michael@0 | 25 | // Write array bounds clamping emulation if needed. |
michael@0 | 26 | getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); |
michael@0 | 27 | |
michael@0 | 28 | // Write translated shader. |
michael@0 | 29 | TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable()); |
michael@0 | 30 | root->traverse(&outputESSL); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | void TranslatorESSL::writeExtensionBehavior() { |
michael@0 | 34 | TInfoSinkBase& sink = getInfoSink().obj; |
michael@0 | 35 | const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); |
michael@0 | 36 | for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); |
michael@0 | 37 | iter != extensionBehavior.end(); ++iter) { |
michael@0 | 38 | if (iter->second != EBhUndefined) { |
michael@0 | 39 | sink << "#extension " << iter->first << " : " |
michael@0 | 40 | << getBehaviorString(iter->second) << "\n"; |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | } |