15601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// 202f20dd8be215559357f65d050b568b138e83211Jamie Madill// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. 35601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// Use of this source code is governed by a BSD-style license that can be 45601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// found in the LICENSE file. 55601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// 65601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 717732823f9c21bdba9cc51ffaceb545ce3857a8cGeoff Lang#include "compiler/translator/TranslatorESSL.h" 85601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 917732823f9c21bdba9cc51ffaceb545ce3857a8cGeoff Lang#include "compiler/translator/OutputESSL.h" 10183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill#include "angle_gl.h" 115601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 12183bde5527317fa2208401e5e6b803ef51a0fdcbJamie MadillTranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec) 1368fe74aabbb4d8ae08aadcf22705f0d85a16e0b5Jamie Madill : TCompiler(type, spec, SH_ESSL_OUTPUT) { 145601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com} 155601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 165601ea0d66442518d4745bb02b7619485b9d305bzmo@google.comvoid TranslatorESSL::translate(TIntermNode* root) { 175601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com TInfoSinkBase& sink = getInfoSink().obj; 185601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 195601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com // Write built-in extension behaviors. 205601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com writeExtensionBehavior(); 215601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 2232e97315e2a55557ad7c372239e0823a81243221zmo@google.com // Write emulated built-in functions if needed. 2332e97315e2a55557ad7c372239e0823a81243221zmo@google.com getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( 24183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill sink, getShaderType() == GL_FRAGMENT_SHADER); 2532e97315e2a55557ad7c372239e0823a81243221zmo@google.com 264167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com // Write array bounds clamping emulation if needed. 274167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); 284167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com 295601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com // Write translated shader. 3002f20dd8be215559357f65d050b568b138e83211Jamie Madill TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion()); 315601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com root->traverse(&outputESSL); 325601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com} 335601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 345601ea0d66442518d4745bb02b7619485b9d305bzmo@google.comvoid TranslatorESSL::writeExtensionBehavior() { 355601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com TInfoSinkBase& sink = getInfoSink().obj; 365601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); 375601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); 385601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com iter != extensionBehavior.end(); ++iter) { 3909c323a40ad0de489eee946bfe171d337616e09czmo@google.com if (iter->second != EBhUndefined) { 4009c323a40ad0de489eee946bfe171d337616e09czmo@google.com sink << "#extension " << iter->first << " : " 4109c323a40ad0de489eee946bfe171d337616e09czmo@google.com << getBehaviorString(iter->second) << "\n"; 4209c323a40ad0de489eee946bfe171d337616e09czmo@google.com } 435601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com } 445601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com} 45