1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/TranslatorESSL.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +// 1.5 +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#include "compiler/TranslatorESSL.h" 1.11 + 1.12 +#include "compiler/OutputESSL.h" 1.13 + 1.14 +TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec) 1.15 + : TCompiler(type, spec) { 1.16 +} 1.17 + 1.18 +void TranslatorESSL::translate(TIntermNode* root) { 1.19 + TInfoSinkBase& sink = getInfoSink().obj; 1.20 + 1.21 + // Write built-in extension behaviors. 1.22 + writeExtensionBehavior(); 1.23 + 1.24 + // Write emulated built-in functions if needed. 1.25 + getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( 1.26 + sink, getShaderType() == SH_FRAGMENT_SHADER); 1.27 + 1.28 + // Write array bounds clamping emulation if needed. 1.29 + getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); 1.30 + 1.31 + // Write translated shader. 1.32 + TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable()); 1.33 + root->traverse(&outputESSL); 1.34 +} 1.35 + 1.36 +void TranslatorESSL::writeExtensionBehavior() { 1.37 + TInfoSinkBase& sink = getInfoSink().obj; 1.38 + const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); 1.39 + for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); 1.40 + iter != extensionBehavior.end(); ++iter) { 1.41 + if (iter->second != EBhUndefined) { 1.42 + sink << "#extension " << iter->first << " : " 1.43 + << getBehaviorString(iter->second) << "\n"; 1.44 + } 1.45 + } 1.46 +}