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