1 //
2 // Copyright 2020 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 //
6 
7 #include <algorithm>
8 #include <unordered_map>
9 
10 #include "compiler/translator/TranslatorMetalDirect/AstHelpers.h"
11 #include "compiler/translator/TranslatorMetalDirect/IntermRebuild.h"
12 #include "compiler/translator/TranslatorMetalDirect/TransposeRowMajorMatrices.h"
13 #include "compiler/translator/tree_ops/SeparateDeclarations.h"
14 
15 using namespace sh;
16 
17 ////////////////////////////////////////////////////////////////////////////////
18 
19 namespace
20 {
21 
22 class Rewriter : public TIntermRebuild
23 {
24   public:
Rewriter(TCompiler & compiler)25     Rewriter(TCompiler &compiler) : TIntermRebuild(compiler, true, false) {}
26     // PreResult visitConstantUnionPre(TIntermSymbol &symbolNode) override
27     // {
28     //     const TVariable &var = symbolNode.variable();
29     //     const TType &type = var.getType();
30     //     //const TLayoutQualifier &layoutQualifier = type.getLayoutQualifier();
31     //     if(type.isMatrix())
32     //     {
33     //         return CreateBuiltInUnaryFunctionCallNode("transpose", symbolNode.deepCopy(),
34     //                                                   mSymbolTable, 300));
35     //     }
36     //     return symbolNode;
37     // }
38 };
39 
40 }  // anonymous namespace
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 
TransposeRowMajorMatricies(TCompiler & compiler,TIntermBlock & root)44 bool sh::TransposeRowMajorMatricies(TCompiler &compiler, TIntermBlock &root)
45 {
46     Rewriter rewriter(compiler);
47     if (!rewriter.rebuildRoot(root))
48     {
49         return false;
50     }
51     return true;
52 }
53