Edit

kc3-lang/angle/src/compiler/TranslatorESSL.cpp

Branch :

  • Show log

    Commit

  • Author : zmo@google.com
    Date : 2011-06-17 00:42:53
    Hash : dc4b4f85
    Message : Always emit precision in shader variable declarations. After the shader compile (and before code output), the precision scopes are already lost. In order to correctly output precisions, we need to emit precision in each variable declaration, therefore, each variable should have its precision set. This CL fixes the bugs that the precisions are lost for variables using default precsions and struct fields. Also, this CL fixes a bug in the grammar: constructors are not type_specifier and they shouldn't have precisions. BUG=168 TEST=webgl conformance tests, gles2 conformance tests. Review URL: http://codereview.appspot.com/4617041 git-svn-id: https://angleproject.googlecode.com/svn/trunk@695 736b8ea6-26fd-11df-bfd4-992fa37f6226

  • src/compiler/TranslatorESSL.cpp
  • //
    // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    #include "compiler/TranslatorESSL.h"
    
    #include "compiler/OutputESSL.h"
    
    TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
        : TCompiler(type, spec) {
    }
    
    void TranslatorESSL::translate(TIntermNode* root) {
        TInfoSinkBase& sink = getInfoSink().obj;
    
        // Write built-in extension behaviors.
        writeExtensionBehavior();
    
        // Write translated shader.
        TOutputESSL outputESSL(sink);
        root->traverse(&outputESSL);
    }
    
    void TranslatorESSL::writeExtensionBehavior() {
        TInfoSinkBase& sink = getInfoSink().obj;
        const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
        for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
             iter != extensionBehavior.end(); ++iter) {
            sink << "#extension " << iter->first << " : "
                 << getBehaviorString(iter->second) << "\n";
        }
    }