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

#include <compiler_backend.h>

Public Types

enum class  Type { kMSL , kGLSL , kGLSLVulkan , kSkSL }
 
enum class  ExtendedResourceIndex { kPrimary , 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 19 of file compiler_backend.h.

Member Typedef Documentation

◆ Compiler

Definition at line 23 of file compiler_backend.h.

◆ GLSLCompiler

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

Definition at line 21 of file compiler_backend.h.

◆ MSLCompiler

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

Definition at line 20 of file compiler_backend.h.

◆ SkSLCompiler

Definition at line 22 of file compiler_backend.h.

Member Enumeration Documentation

◆ ExtendedResourceIndex

Enumerator
kPrimary 
kSecondary 

Definition at line 52 of file compiler_backend.h.

52 {
53 kPrimary,
54 kSecondary,
55 };

◆ Type

Enumerator
kMSL 
kGLSL 
kGLSLVulkan 
kSkSL 

Definition at line 25 of file compiler_backend.h.

25 {
26 kMSL,
27 kGLSL,
28 kGLSLVulkan,
29 kSkSL,
30 };

Constructor & Destructor Documentation

◆ CompilerBackend() [1/5]

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

◆ CompilerBackend() [2/5]

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

◆ CompilerBackend() [3/5]

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

◆ 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)){};
GLenum type

◆ 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 70 of file compiler_backend.cc.

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

◆ GetCompiler() [2/2]

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

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}
compiler
Definition: malisc.py:17

◆ 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) {
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}

◆ 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}
spirv_cross::Compiler * GetCompiler()

◆ operator->()

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

Definition at line 31 of file compiler_backend.cc.

31 {
32 return GetCompiler();
33}

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