| 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 "spirv_glsl.hpp"
13 #include "spirv_msl.hpp"
14 #include "spirv_sksl.h"
15
16 namespace impeller {
17 namespace compiler {
18
19 struct CompilerBackend {
20 using MSLCompiler = std::shared_ptr<spirv_cross::CompilerMSL>;
21 using GLSLCompiler = std::shared_ptr<spirv_cross::CompilerGLSL>;
22 using SkSLCompiler = std::shared_ptr<CompilerSkSL>;
23 using Compiler = std::variant<MSLCompiler, GLSLCompiler, SkSLCompiler>;
24
25 enum class Type {
26 kMSL,
27 kGLSL,
28 kGLSLVulkan,
29 kSkSL,
30 };
31
32 explicit CompilerBackend(MSLCompiler compiler);
33
34 explicit CompilerBackend(GLSLCompiler compiler);
35
36 explicit CompilerBackend(SkSLCompiler compiler);
37
38 CompilerBackend(Type type, Compiler compiler);
39
40 CompilerBackend();
41
42 ~CompilerBackend();
43
44 Type GetType() const;
45
46 const spirv_cross::Compiler* operator->() const;
47
48 spirv_cross::Compiler* GetCompiler();
49
50 explicit operator bool() const;
51
52 enum class ExtendedResourceIndex {
53 kPrimary,
54 kSecondary,
55 };
56 uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index,
57 spirv_cross::ID id) const;
58
59 const spirv_cross::Compiler* GetCompiler() const;
60
61 private:
62 Type type_ = Type::kMSL;
63 Compiler compiler_;
64
65 const spirv_cross::CompilerMSL* GetMSLCompiler() const;
66
67 const spirv_cross::CompilerGLSL* GetGLSLCompiler() const;
68
69 const CompilerSkSL* GetSkSLCompiler() const;
70 };
71
72 } // namespace compiler
73 } // namespace impeller
74
75 #endif // FLUTTER_IMPELLER_COMPILER_COMPILER_BACKEND_H_
type
GLenum type
Definition: blit_command_gles.cc:153
impeller::compiler::Compiler
Definition: compiler.h:24
impeller::compiler::CompilerSkSL
Definition: spirv_sksl.h:19
impeller
Definition: allocation.cc:12
spirv_sksl.h
impeller::compiler::CompilerBackend
Definition: compiler_backend.h:19
impeller::compiler::CompilerBackend::SkSLCompiler
std::shared_ptr< CompilerSkSL > SkSLCompiler
Definition: compiler_backend.h:22
impeller::compiler::CompilerBackend::GetType
Type GetType() const
Definition: compiler_backend.cc:108
impeller::compiler::CompilerBackend::CompilerBackend
CompilerBackend()
impeller::compiler::CompilerBackend::operator->
const spirv_cross::Compiler * operator->() const
Definition: compiler_backend.cc:31
impeller::compiler::CompilerBackend::GetCompiler
spirv_cross::Compiler * GetCompiler()
Definition: compiler_backend.cc:70
impeller::compiler::CompilerBackend::GLSLCompiler
std::shared_ptr< spirv_cross::CompilerGLSL > GLSLCompiler
Definition: compiler_backend.h:21
impeller::compiler::CompilerBackend::MSLCompiler
std::shared_ptr< spirv_cross::CompilerMSL > MSLCompiler
Definition: compiler_backend.h:20
impeller::compiler::CompilerBackend::~CompilerBackend
~CompilerBackend()
impeller::compiler::CompilerBackend::Type
Type
Definition: compiler_backend.h:25
impeller::compiler::CompilerBackend::Type::kGLSLVulkan
@ kGLSLVulkan
impeller::compiler::CompilerBackend::Type::kGLSL
@ kGLSL
impeller::compiler::CompilerBackend::Type::kMSL
@ kMSL
impeller::compiler::CompilerBackend::Type::kSkSL
@ kSkSL
impeller::compiler::CompilerBackend::GetExtendedMSLResourceBinding
uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index, spirv_cross::ID id) const
Definition: compiler_backend.cc:35
impeller::compiler::CompilerBackend::Compiler
std::variant< MSLCompiler, GLSLCompiler, SkSLCompiler > Compiler
Definition: compiler_backend.h:23
impeller::compiler::CompilerBackend::ExtendedResourceIndex
ExtendedResourceIndex
Definition: compiler_backend.h:52
impeller::compiler::CompilerBackend::ExtendedResourceIndex::kSecondary
@ kSecondary
impeller::compiler::CompilerBackend::ExtendedResourceIndex::kPrimary
@ kPrimary