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 #ifndef COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_REWRITEPIPELINES_H_
8 #define COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_REWRITEPIPELINES_H_
9 
10 #include "common/angleutils.h"
11 #include "compiler/translator/Compiler.h"
12 #include "compiler/translator/TranslatorMetalDirect/IdGen.h"
13 #include "compiler/translator/TranslatorMetalDirect/Pipeline.h"
14 #include "compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h"
15 #include "compiler/translator/TranslatorMetalDirect/SymbolEnv.h"
16 
17 namespace sh
18 {
19 
20 // This rewrites all pipelines.
21 //
22 // For each pipeline:
23 //    - Discover all variables that are used by the pipeline
24 //    - Move the variables into an internal pipeline struct instance and update old variables to be
25 //      member access instead.
26 //    - Dependency inject the internal pipeline struct to all functions that access variables from
27 //      the struct.
28 //    - A new external pipeline struct is created if needed for impedance reasons. Otherwise the
29 //      external and internal pipeline structs are the same.
30 //    - Add `main` parameter or return value for the external pipeline struct as needed.
31 //    - Inside `main`, map the external struct to the internal struct if they differ and is provided
32 //      as a parameter to `main`.
33 //    - Inside `main`, map the internal struct to the external struct if they differ and is returned
34 //      from `main`.
35 ANGLE_NO_DISCARD bool RewritePipelines(TCompiler &compiler,
36                                        TIntermBlock &root,
37                                        IdGen &idGen,
38                                        DriverUniform &angleUniformsGlobalInstanceVar,
39                                        SymbolEnv &symbolEnv,
40                                        Invariants &invariants,
41                                        PipelineStructs &outStructs);
42 
43 }  // namespace sh
44 
45 #endif  // COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_REWRITEPIPELINES_H_
46