Edit

kc3-lang/angle/src/compiler/translator/OutputESSL.cpp

Branch :

  • Show log

    Commit

  • Author : Shahbaz Youssefi
    Date : 2021-06-02 22:04:45
    Hash : 1b680b77
    Message : Reland "Make SH_CLAMP_INDIRECT_ARRAY_BOUNDS do proper AST transformation" This is a reland of a474fd7de769ae817db83490d410510cdbed75b2 The integer clamp used in this transformation is not available in es100 shaders, and float clamp is used instead. Original change's description: > Make SH_CLAMP_INDIRECT_ARRAY_BOUNDS do proper AST transformation > > This translator flag adds a clamp to non-literal indices to arrays. Two > strategies were provisioned, using the clamp intrinsic or a hand-written > function. The latter is ununsed in angle, chromium, firefox and > webkit, so this change removes this option and uses the clamp intrinsic > unconditionally. > > The clamp itself was added at output generation time with special flags > set on the index node. This is changed such that a proper AST > transformation is done and no-special handling would be necessary. > > Bug: angleproject:4361 > Bug: angleproject:4889 > Change-Id: Ieccfd2c1c347563fb5282e9fa66d39304e62f2ca > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2935041 > Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Bug: angleproject:4361 Bug: angleproject:4889 Change-Id: I9397ec7e6bdfb706c2a891b33fd3b2b79e883ccc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2940902 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>

  • src/compiler/translator/OutputESSL.cpp
  • //
    // Copyright 2002 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/translator/OutputESSL.h"
    
    namespace sh
    {
    
    TOutputESSL::TOutputESSL(TInfoSinkBase &objSink,
                             ShHashFunction64 hashFunction,
                             NameMap &nameMap,
                             TSymbolTable *symbolTable,
                             sh::GLenum shaderType,
                             int shaderVersion,
                             bool forceHighp,
                             ShCompileOptions compileOptions)
        : TOutputGLSLBase(objSink,
                          hashFunction,
                          nameMap,
                          symbolTable,
                          shaderType,
                          shaderVersion,
                          SH_ESSL_OUTPUT,
                          compileOptions),
          mForceHighp(forceHighp)
    {}
    
    bool TOutputESSL::writeVariablePrecision(TPrecision precision)
    {
        if (precision == EbpUndefined)
            return false;
    
        TInfoSinkBase &out = objSink();
        if (mForceHighp)
            out << getPrecisionString(EbpHigh);
        else
            out << getPrecisionString(precision);
        return true;
    }
    
    ImmutableString TOutputESSL::translateTextureFunction(const ImmutableString &name,
                                                          const ShCompileOptions &option)
    {
        // Check WEBGL_video_texture invocation first.
        if (name == "textureVideoWEBGL")
        {
            if (option & SH_TAKE_VIDEO_TEXTURE_AS_EXTERNAL_OES)
            {
                // TODO(http://anglebug.com/3889): Implement external image situation.
                UNIMPLEMENTED();
                return ImmutableString("");
            }
            else
            {
                // Default translating textureVideoWEBGL to texture2D.
                return ImmutableString("texture2D");
            }
        }
    
        return name;
    }
    
    }  // namespace sh