Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
compiler_backend.cc
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
6
8
9namespace impeller {
10namespace compiler {
11
14
16 : CompilerBackend(compiler->get_common_options().vulkan_semantics
17 ? Type::kGLSLVulkan
18 : Type::kGLSL,
19 compiler) {}
20
23
25
28
30
31const spirv_cross::Compiler* CompilerBackend::operator->() const {
32 return GetCompiler();
33}
34
37 spirv_cross::ID id) const {
38 if (auto compiler = GetMSLCompiler()) {
39 switch (index) {
41 return compiler->get_automatic_msl_resource_binding(id);
43 return compiler->get_automatic_msl_resource_binding_secondary(id);
44 break;
45 }
46 }
47 if (auto compiler = GetGLSLCompiler()) {
48 return compiler->get_decoration(id, spv::Decoration::DecorationBinding);
49 }
50 const auto kOOBIndex = static_cast<uint32_t>(-1);
51 return kOOBIndex;
52}
53
54const spirv_cross::Compiler* CompilerBackend::GetCompiler() const {
55 if (auto compiler = GetGLSLCompiler()) {
56 return compiler;
57 }
58
59 if (auto compiler = GetMSLCompiler()) {
60 return compiler;
61 }
62
63 if (auto compiler = GetSkSLCompiler()) {
64 return compiler;
65 }
66
67 return nullptr;
68}
69
70spirv_cross::Compiler* CompilerBackend::GetCompiler() {
71 if (auto* msl = std::get_if<MSLCompiler>(&compiler_)) {
72 return msl->get();
73 }
74 if (auto* glsl = std::get_if<GLSLCompiler>(&compiler_)) {
75 return glsl->get();
76 }
77 if (auto* sksl = std::get_if<SkSLCompiler>(&compiler_)) {
78 return sksl->get();
79 }
80 return nullptr;
81}
82
83const spirv_cross::CompilerMSL* CompilerBackend::GetMSLCompiler() const {
84 if (auto* msl = std::get_if<MSLCompiler>(&compiler_)) {
85 return msl->get();
86 }
87 return nullptr;
88}
89
90const spirv_cross::CompilerGLSL* CompilerBackend::GetGLSLCompiler() const {
91 if (auto* glsl = std::get_if<GLSLCompiler>(&compiler_)) {
92 return glsl->get();
93 }
94 return nullptr;
95}
96
97const CompilerSkSL* CompilerBackend::GetSkSLCompiler() const {
98 if (auto* sksl = std::get_if<SkSLCompiler>(&compiler_)) {
99 return sksl->get();
100 }
101 return nullptr;
102}
103
104CompilerBackend::operator bool() const {
105 return !!GetCompiler();
106}
107
109 return type_;
110}
111
112} // namespace compiler
113} // namespace impeller
Definition ref_ptr.h:256
std::shared_ptr< CompilerSkSL > SkSLCompiler
const spirv_cross::Compiler * operator->() const
spirv_cross::Compiler * GetCompiler()
std::shared_ptr< spirv_cross::CompilerGLSL > GLSLCompiler
std::shared_ptr< spirv_cross::CompilerMSL > MSLCompiler
uint32_t GetExtendedMSLResourceBinding(ExtendedResourceIndex index, spirv_cross::ID id) const
std::variant< MSLCompiler, GLSLCompiler, SkSLCompiler > Compiler