| Flutter Impeller |

Public Types | Public Member Functions | List of all members
impeller::compiler::CompilerBackend Struct Reference

`#include <compiler_backend.h>`

## Public Types
enum | Type { Type::kMSL, Type::kGLSL, Type::kGLSLVulkan, Type::kSkSL }
enum | ExtendedResourceIndex { ExtendedResourceIndex::kPrimary, ExtendedResourceIndex::kSecondary }
using | MSLCompiler = std::shared_ptr< spirv_cross::CompilerMSL >
using | GLSLCompiler = std::shared_ptr< spirv_cross::CompilerGLSL >
using | SkSLCompiler = std::shared_ptr< CompilerSkSL >
using | Compiler = std::variant< MSLCompiler, GLSLCompiler, SkSLCompiler >

## Public Member Functions
| CompilerBackend (MSLCompiler compiler)
| CompilerBackend (GLSLCompiler compiler)
| CompilerBackend (SkSLCompiler compiler)
| CompilerBackend (Type type, Compiler compiler)
| CompilerBackend ()
| ~CompilerBackend ()
Type | GetType () const
const spirv_cross::Compiler * | operator-> () const
spirv_cross::Compiler * | GetCompiler ()
| operator bool () const
uint32_t | GetExtendedMSLResourceBinding (ExtendedResourceIndex index, spirv_cross::ID id) const
const spirv_cross::Compiler * | GetCompiler () const

## Detailed Description

Definition at line 21 of file compiler_backend.h.

## Member Typedef Documentation

## ◆ Compiler

using impeller::compiler::CompilerBackend::Compiler = std::variant<MSLCompiler, GLSLCompiler, SkSLCompiler>

Definition at line 25 of file compiler_backend.h.

## ◆ GLSLCompiler

using impeller::compiler::CompilerBackend::GLSLCompiler = std::shared_ptr<spirv_cross::CompilerGLSL>

Definition at line 23 of file compiler_backend.h.

## ◆ MSLCompiler

using impeller::compiler::CompilerBackend::MSLCompiler = std::shared_ptr<spirv_cross::CompilerMSL>

Definition at line 22 of file compiler_backend.h.

## ◆ SkSLCompiler

using impeller::compiler::CompilerBackend::SkSLCompiler = std::shared_ptr<CompilerSkSL>

Definition at line 24 of file compiler_backend.h.

## Member Enumeration Documentation

## ◆ ExtendedResourceIndex

enum impeller::compiler::CompilerBackend::ExtendedResourceIndex
| strong

Enumerator
kPrimary |
kSecondary |

Definition at line 54 of file compiler_backend.h.

54 {
55 kPrimary,
56 kSecondary,
57 };

## ◆ Type

enum impeller::compiler::CompilerBackend::Type
| strong

Enumerator
kMSL |
kGLSL |
kGLSLVulkan |
kSkSL |

Definition at line 27 of file compiler_backend.h.

27 {
28 kMSL,
29 kGLSL,
30 kGLSLVulkan,
31 kSkSL,
32 };

## Constructor & Destructor Documentation

## ◆ CompilerBackend() [1/5]

impeller::compiler::CompilerBackend::CompilerBackend | ( | MSLCompiler | compiler | ) |
| explicit

Definition at line 12 of file compiler_backend.cc.

13 : CompilerBackend(Type::kMSL, compiler) {}

## ◆ CompilerBackend() [2/5]

impeller::compiler::CompilerBackend::CompilerBackend | ( | GLSLCompiler | compiler | ) |
| explicit

Definition at line 15 of file compiler_backend.cc.

16 : CompilerBackend(compiler->get_common_options().vulkan_semantics
17 ? Type::kGLSLVulkan
18 : Type::kGLSL,
19 compiler) {}

References impeller::compiler::kGLSL.

## ◆ CompilerBackend() [3/5]

impeller::compiler::CompilerBackend::CompilerBackend | ( | SkSLCompiler | compiler | ) |
| explicit

Definition at line 21 of file compiler_backend.cc.

22 : CompilerBackend(Type::kSkSL, compiler) {}

References impeller::compiler::kSkSL.

## ◆ CompilerBackend() [4/5]

impeller::compiler::CompilerBackend::CompilerBackend | ( | Type | type,
|  | Compiler | compiler
| ) |  |

Definition at line 26 of file compiler_backend.cc.

27 : type_(type), compiler_(std::move(compiler)){};

## ◆ CompilerBackend() [5/5]

impeller::compiler::CompilerBackend::CompilerBackend | ( |  | ) |
| default

## ◆ ~CompilerBackend()

impeller::compiler::CompilerBackend::~CompilerBackend | ( |  | ) |
| default

## Member Function Documentation

## ◆ GetCompiler() [1/2]

spirv_cross::Compiler * impeller::compiler::CompilerBackend::GetCompiler | ( |  | ) |

Definition at line 54 of file compiler_backend.cc.

54 {
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 }

Referenced by impeller::compiler::CreateCompiler(), and operator->().

## ◆ GetCompiler() [2/2]

const spirv_cross::Compiler* impeller::compiler::CompilerBackend::GetCompiler | ( |  | ) | const

## ◆ GetExtendedMSLResourceBinding()

uint32_t impeller::compiler::CompilerBackend::GetExtendedMSLResourceBinding | ( | ExtendedResourceIndex | index,
|  | spirv_cross::ID | id
| ) |  | const

Definition at line 35 of file compiler_backend.cc.

37 {
38 if (auto compiler = GetMSLCompiler()) {
39 switch (index) {
40 case ExtendedResourceIndex::kPrimary:
41 return compiler->get_automatic_msl_resource_binding(id);
42 case ExtendedResourceIndex::kSecondary:
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 }

References kPrimary, and kSecondary.

## ◆ GetType()

CompilerBackend::Type impeller::compiler::CompilerBackend::GetType | ( |  | ) | const

Definition at line 108 of file compiler_backend.cc.

108 {
109 return type_;
110 }

## ◆ operator bool()

impeller::compiler::CompilerBackend::operator bool | ( |  | ) | const
| explicit

Definition at line 104 of file compiler_backend.cc.

104 {
105 return !!GetCompiler();
106 }

## ◆ operator->()

const spirv_cross::Compiler * impeller::compiler::CompilerBackend::operator-> | ( |  | ) | const

Definition at line 31 of file compiler_backend.cc.

31 {
32 return GetCompiler();
33 }

References GetCompiler().

The documentation for this struct was generated from the following files:

- impeller/compiler/compiler_backend.h
- impeller/compiler/compiler_backend.cc

impeller::compiler::CompilerBackend::Type::kGLSLVulkan
@ kGLSLVulkan
impeller::compiler::SourceLanguage::kGLSL
@ kGLSL
impeller::compiler::CompilerBackend::ExtendedResourceIndex::kSecondary
@ kSecondary
impeller::compiler::CompilerBackend::Type::kGLSL
@ kGLSL
impeller::compiler::CompilerBackend::GetCompiler
spirv_cross::Compiler * GetCompiler()
Definition: compiler_backend.cc:54
impeller::compiler::CompilerBackend::Type::kSkSL
@ kSkSL
impeller::compiler::CompilerBackend::CompilerBackend
CompilerBackend()
impeller::compiler::CompilerBackend::Type::kMSL
@ kMSL
impeller::compiler::CompilerBackend::ExtendedResourceIndex::kPrimary
@ kPrimary
impeller::compiler::TargetPlatform::kSkSL
@ kSkSL