| 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 kGLSLVulkan,
31 kSkSL,
32 };
33
34 explicit CompilerBackend(MSLCompiler compiler);
35
36 explicit CompilerBackend(GLSLCompiler compiler);
37
38 explicit CompilerBackend(SkSLCompiler compiler);
39
40 CompilerBackend(Type type, Compiler compiler);
41
42 CompilerBackend();
43
44 ~CompilerBackend();
45
46 Type GetType() const;
47
48 const spirv_cross::Compiler* operator->() const;
49
50 spirv_cross::Compiler* GetCompiler();
51
52 explicit operator bool() const;
53
54 enum class ExtendedResourceIndex {
55 kPrimary,
56 kSecondary,
57 };
58 uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index,
59 spirv_cross::ID id) const;
60
61 const spirv_cross::Compiler* GetCompiler() const;
62
63 private:
64 Type type_ = Type::kMSL;
65 Compiler compiler_;
66
67 const spirv_cross::CompilerMSL* GetMSLCompiler() const;
68
69 const spirv_cross::CompilerGLSL* GetGLSLCompiler() const;
70
71 const CompilerSkSL* GetSkSLCompiler() const;
72 };
73
74 } // namespace compiler
75 } // namespace impeller
76
77 #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::Type::kGLSLVulkan
@ kGLSLVulkan
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:35
impeller::compiler::CompilerBackend::Type::kGLSL
@ kGLSL
impeller::compiler::CompilerBackend::GetType
Type GetType() const
Definition: compiler_backend.cc:108
impeller::compiler::CompilerBackend::ExtendedResourceIndex
ExtendedResourceIndex
Definition: compiler_backend.h:54
impeller::compiler::CompilerBackend::GetCompiler
spirv_cross::Compiler * GetCompiler()
Definition: compiler_backend.cc:54
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:31
spirv_sksl.h
impeller
Definition: aiks_blur_unittests.cc:20