| 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 #pragma once
6
7 #include <memory>
8 #include <variant>
9
10 #include "flutter/fml/logging.h"
11 #include "flutter/fml/macros.h"
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 kSkSL,
29 };
30
31 explicit CompilerBackend(MSLCompiler compiler);
32
33 explicit CompilerBackend(GLSLCompiler compiler);
34
35 explicit CompilerBackend(SkSLCompiler compiler);
36
37 CompilerBackend(Type type, Compiler compiler);
38
39 CompilerBackend();
40
41 ~CompilerBackend();
42
43 Type GetType() const;
44
45 const spirv_cross::Compiler* operator->() const;
46
47 spirv_cross::Compiler* GetCompiler();
48
49 operator bool() const;
50
51 enum class ExtendedResourceIndex {
52 kPrimary,
53 kSecondary,
54 };
55 uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index,
56 spirv_cross::ID id) const;
57
58 const spirv_cross::Compiler* GetCompiler() const;
59
60 private:
61 Type type_ = Type::kMSL;
62 Compiler compiler_;
63
64 const spirv_cross::CompilerMSL* GetMSLCompiler() const;
65
66 const spirv_cross::CompilerGLSL* GetGLSLCompiler() const;
67
68 const CompilerSkSL* GetSkSLCompiler() const;
69 };
70
71 } // namespace compiler
72 } // namespace impeller
impeller::compiler::Compiler
Definition: compiler.h:24
impeller::compiler::CompilerBackend
Definition: compiler_backend.h:19
impeller::compiler::CompilerBackend::Compiler
std::variant< MSLCompiler, GLSLCompiler, SkSLCompiler > Compiler
Definition: compiler_backend.h:23
impeller::compiler::CompilerBackend::Type
Type
Definition: compiler_backend.h:25
impeller::compiler::CompilerBackend::MSLCompiler
std::shared_ptr< spirv_cross::CompilerMSL > MSLCompiler
Definition: compiler_backend.h:20
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:51
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:22
impeller::compiler::CompilerBackend::GLSLCompiler
std::shared_ptr< spirv_cross::CompilerGLSL > GLSLCompiler
Definition: compiler_backend.h:21
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:18
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