Edit

kc3-lang/angle/src/compiler/translator/tree_ops/RemoveDynamicIndexing.h

Branch :

  • Show log

    Commit

  • Author : jchen10
    Date : 2019-10-18 16:01:34
    Hash : b3070102
    Message : Add SH_REMOVE_DYNAMIC_INDEXING_OF_SWIZZLED_VECTOR This is a workaround for the webgl2 conformance test case WebglConformance_conformance2_glsl3_vector_dynamic_indexing_swizzled_lvalue. Dynamic indexing of swizzled lvalue like "v.zyx[i] = 0.0" is problematic on various platforms. This removes the indexing by translating it this way: void dyn_index_write_vec3(inout vec3 base, in int index, in float value){ switch (index) { case (0): (base[0] = value); return ; case (1): (base[1] = value); return ; case (2): (base[2] = value); return ; default: break; } if ((index < 0)) { (base[0] = value); return ; } { (base[2] = value); } } ... dyn_index_write_vec3(v.zyx, i, 0.0); ... Bug: chromium:709351 Change-Id: I971b38eb404209b56e6764af1063878c078a7e88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1869109 Commit-Queue: Jie A Chen <jie.a.chen@intel.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>

  • src/compiler/translator/tree_ops/RemoveDynamicIndexing.h
  • //
    // 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.
    //
    // RemoveDynamicIndexing is an AST traverser to remove dynamic indexing of non-SSBO vectors and
    // matrices, replacing them with calls to functions that choose which component to return or write.
    // We don't need to consider dynamic indexing in SSBO since it can be directly as part of the offset
    // of RWByteAddressBuffer.
    //
    
    #ifndef COMPILER_TRANSLATOR_TREEOPS_REMOVEDYNAMICINDEXING_H_
    #define COMPILER_TRANSLATOR_TREEOPS_REMOVEDYNAMICINDEXING_H_
    
    #include "common/angleutils.h"
    
    #include <functional>
    
    namespace sh
    {
    
    class TCompiler;
    class TIntermNode;
    class TIntermBinary;
    class TSymbolTable;
    class PerformanceDiagnostics;
    
    ANGLE_NO_DISCARD bool RemoveDynamicIndexingOfNonSSBOVectorOrMatrix(
        TCompiler *compiler,
        TIntermNode *root,
        TSymbolTable *symbolTable,
        PerformanceDiagnostics *perfDiagnostics);
    
    ANGLE_NO_DISCARD bool RemoveDynamicIndexingOfSwizzledVector(
        TCompiler *compiler,
        TIntermNode *root,
        TSymbolTable *symbolTable,
        PerformanceDiagnostics *perfDiagnostics);
    
    }  // namespace sh
    
    #endif  // COMPILER_TRANSLATOR_TREEOPS_REMOVEDYNAMICINDEXING_H_