| Flutter Impeller |

compiler_backend.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_COMPILER_COMPILER_BACKEND_H_
6 #define FLUTTER_IMPELLER_COMPILER_COMPILER_BACKEND_H_
7
8 #include <cstdint>
9 #include <memory>
10 #include <variant>
11
12 #include "flutter/fml/logging.h"
13 #include "flutter/fml/macros.h"
14 #include "spirv_glsl.hpp"
15 #include "spirv_msl.hpp"
16 #include "spirv_sksl.h"
17
18 namespace impeller {
19 namespace compiler {
20
21 struct CompilerBackend {
22 using MSLCompiler = std::shared_ptr<spirv_cross::CompilerMSL>;
23 using GLSLCompiler = std::shared_ptr<spirv_cross::CompilerGLSL>;
24 using SkSLCompiler = std::shared_ptr<CompilerSkSL>;
25 using Compiler = std::variant<MSLCompiler, GLSLCompiler, SkSLCompiler>;
26
27 enum class Type {
28 kMSL,
29 kGLSL,
30 kSkSL,
31 };
32
33 explicit CompilerBackend(MSLCompiler compiler);
34
35 explicit CompilerBackend(GLSLCompiler compiler);
36
37 explicit CompilerBackend(SkSLCompiler compiler);
38
39 CompilerBackend(Type type, Compiler compiler);
40
41 CompilerBackend();
42
43 ~CompilerBackend();
44
45 Type GetType() const;
46
47 const spirv_cross::Compiler* operator->() const;
48
49 spirv_cross::Compiler* GetCompiler();
50
51 explicit operator bool() const;
52
53 enum class ExtendedResourceIndex {
54 kPrimary,
55 kSecondary,
56 };
57 uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index,
58 spirv_cross::ID id) const;
59
60 const spirv_cross::Compiler* GetCompiler() const;
61
62 private:
63 Type type_ = Type::kMSL;
64 Compiler compiler_;
65
66 const spirv_cross::CompilerMSL* GetMSLCompiler() const;
67
68 const spirv_cross::CompilerGLSL* GetGLSLCompiler() const;
69
70 const CompilerSkSL* GetSkSLCompiler() const;
71 };
72
73 } // namespace compiler
74 } // namespace impeller
75
76 #endif // FLUTTER_IMPELLER_COMPILER_COMPILER_BACKEND_H_
impeller::compiler::Compiler
Definition: compiler.h:25
impeller::compiler::CompilerBackend
Definition: compiler_backend.h:21
impeller::compiler::CompilerBackend::Compiler
std::variant< MSLCompiler, GLSLCompiler, SkSLCompiler > Compiler
Definition: compiler_backend.h:25
impeller::compiler::CompilerBackend::Type
Type
Definition: compiler_backend.h:27
impeller::compiler::CompilerBackend::MSLCompiler
std::shared_ptr< spirv_cross::CompilerMSL > MSLCompiler
Definition: compiler_backend.h:22
impeller::compiler::CompilerBackend::ExtendedResourceIndex::kSecondary
@ kSecondary
impeller::compiler::CompilerBackend::GetExtendedMSLResourceBinding
uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index, spirv_cross::ID id) const
Definition: compiler_backend.cc:32
impeller::compiler::CompilerBackend::Type::kGLSL
@ kGLSL
impeller::compiler::CompilerBackend::GetType
Type GetType() const
Definition: compiler_backend.cc:105
impeller::compiler::CompilerBackend::ExtendedResourceIndex
ExtendedResourceIndex
Definition: compiler_backend.h:53
impeller::compiler::CompilerBackend::GetCompiler
spirv_cross::Compiler * GetCompiler()
Definition: compiler_backend.cc:51
impeller::compiler::CompilerBackend::SkSLCompiler
std::shared_ptr< CompilerSkSL > SkSLCompiler
Definition: compiler_backend.h:24
impeller::compiler::CompilerBackend::GLSLCompiler
std::shared_ptr< spirv_cross::CompilerGLSL > GLSLCompiler
Definition: compiler_backend.h:23
impeller::compiler::CompilerBackend::Type::kSkSL
@ kSkSL
impeller::compiler::CompilerBackend::CompilerBackend
CompilerBackend()
impeller::compiler::CompilerBackend::Type::kMSL
@ kMSL
impeller::compiler::CompilerBackend::~CompilerBackend
~CompilerBackend()
impeller::compiler::CompilerSkSL
Definition: spirv_sksl.h:19
impeller::compiler::CompilerBackend::ExtendedResourceIndex::kPrimary
@ kPrimary
impeller::compiler::CompilerBackend::operator->
const spirv_cross::Compiler * operator->() const
Definition: compiler_backend.cc:28
spirv_sksl.h
impeller
Definition: aiks_context.cc:10