xref: /aosp_15_r20/external/angle/src/compiler/translator/msl/RewritePipelines.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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_MSL_REWRITEPIPELINES_H_
8 #define COMPILER_TRANSLATOR_MSL_REWRITEPIPELINES_H_
9 
10 #include "common/angleutils.h"
11 #include "compiler/translator/Compiler.h"
12 #include "compiler/translator/msl/IdGen.h"
13 #include "compiler/translator/msl/Pipeline.h"
14 #include "compiler/translator/msl/SymbolEnv.h"
15 
16 namespace sh
17 {
18 class DriverUniform;
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 [[nodiscard]] bool RewritePipelines(TCompiler &compiler,
36                                     TIntermBlock &root,
37                                     const std::vector<sh::ShaderVariable> &inputVaryings,
38                                     const std::vector<sh::ShaderVariable> &outputVariables,
39                                     IdGen &idGen,
40                                     DriverUniform &angleUniformsGlobalInstanceVar,
41                                     SymbolEnv &symbolEnv,
42                                     PipelineStructs &outStructs);
43 
44 }  // namespace sh
45 
46 #endif  // COMPILER_TRANSLATOR_MSL_REWRITEPIPELINES_H_
47