// // Copyright 2019 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. // // RewriteAtomicCounters: Emulate atomic counter buffers with storage buffers. // #include "compiler/translator/tree_ops/RewriteArrayOfArrayOfOpaqueUniforms.h" #include "compiler/translator/Compiler.h" #include "compiler/translator/ImmutableStringBuilder.h" #include "compiler/translator/SymbolTable.h" #include "compiler/translator/tree_util/IntermNode_util.h" #include "compiler/translator/tree_util/IntermTraverse.h" #include "compiler/translator/tree_util/ReplaceVariable.h" namespace sh { namespace { struct UniformData { … }; UniformMap; TIntermTyped *RewriteArrayOfArraySubscriptExpression(TCompiler *compiler, TIntermBinary *node, const UniformMap &uniformMap); // Given an expression, this traverser calculates a new expression where array of array of opaque // uniforms are replaced with their flattened ones. In particular, this is run on the right node of // EOpIndexIndirect binary nodes, so that the expression in the index gets a chance to go through // this transformation. class RewriteExpressionTraverser final : public TIntermTraverser { … }; // Rewrite the index of an EOpIndexIndirect expression. The root can never need replacing, because // it cannot be an opaque uniform itself. void RewriteIndexExpression(TCompiler *compiler, TIntermTyped *expression, const UniformMap &uniformMap) { … } // Given an expression such as the following: // // EOpIndex(In)Direct (opaque uniform) // / \ // EOpIndex(In)Direct I1 // / \ // ... I2 // / // EOpIndex(In)Direct // / \ // uniform In // // produces: // // EOpIndex(In)Direct // / \ // uniform In*Pn + ... + I2*P2 + I1*P1 // TIntermTyped *RewriteArrayOfArraySubscriptExpression(TCompiler *compiler, TIntermBinary *node, const UniformMap &uniformMap) { … } // Traverser that takes: // // uniform sampler/image/atomic_uint u[N][M].. // // and transforms it to: // // uniform sampler/image/atomic_uint u[N * M * ..] // // MonomorphizeUnsupportedFunctions makes it impossible for this array to be partially // subscripted, or passed as argument to a function unsubscripted. This means that every encounter // of this uniform can be expected to be fully subscripted. // class RewriteArrayOfArrayOfOpaqueUniformsTraverser : public TIntermTraverser { … }; } // anonymous namespace bool RewriteArrayOfArrayOfOpaqueUniforms(TCompiler *compiler, TIntermBlock *root, TSymbolTable *symbolTable) { … } } // namespace sh