gfx/angle/src/compiler/TranslatorGLSL.cpp

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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 //
     7 #include "compiler/TranslatorGLSL.h"
     9 #include "compiler/OutputGLSL.h"
    10 #include "compiler/VersionGLSL.h"
    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 }
    24 TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
    25     : TCompiler(type, spec) {
    26 }
    28 void TranslatorGLSL::translate(TIntermNode* root) {
    29     TInfoSinkBase& sink = getInfoSink().obj;
    31     // Write GLSL version.
    32     writeVersion(getShaderType(), root, sink);
    34     // Write emulated built-in functions if needed.
    35     getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
    36         sink, false);
    38     // Write array bounds clamping emulation if needed.
    39     getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
    41     // Write translated shader.
    42     TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable());
    43     root->traverse(&outputGLSL);
    44 }

mercurial