Flutter Impeller
impeller::compiler::CompilerBackend Struct Reference

#include <compiler_backend.h>

Public Types

enum  Type {
  Type::kMSL,
  Type::kGLSL,
  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 19 of file compiler_backend.h.

Member Typedef Documentation

◆ Compiler

◆ 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 51 of file compiler_backend.h.

51  {
52  kPrimary,
53  kSecondary,
54  };

◆ Type

Enumerator
kMSL 
kGLSL 
kSkSL 

Definition at line 25 of file compiler_backend.h.

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

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(Type::kGLSL, compiler) {}

References impeller::compiler::kGLSL.

◆ CompilerBackend() [3/5]

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

Definition at line 18 of file compiler_backend.cc.

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

References impeller::compiler::kSkSL.

◆ CompilerBackend() [4/5]

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

Definition at line 23 of file compiler_backend.cc.

24  : 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 51 of file compiler_backend.cc.

51  {
52  if (auto compiler = GetGLSLCompiler()) {
53  return compiler;
54  }
55 
56  if (auto compiler = GetMSLCompiler()) {
57  return compiler;
58  }
59 
60  if (auto compiler = GetSkSLCompiler()) {
61  return compiler;
62  }
63 
64  return nullptr;
65 }

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

34  {
35  if (auto compiler = GetMSLCompiler()) {
36  switch (index) {
38  return compiler->get_automatic_msl_resource_binding(id);
40  return compiler->get_automatic_msl_resource_binding_secondary(id);
41  break;
42  }
43  }
44  if (auto compiler = GetGLSLCompiler()) {
45  return compiler->get_decoration(id, spv::Decoration::DecorationBinding);
46  }
47  const auto kOOBIndex = static_cast<uint32_t>(-1);
48  return kOOBIndex;
49 }

References kPrimary, and kSecondary.

◆ GetType()

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

Definition at line 105 of file compiler_backend.cc.

105  {
106  return type_;
107 }

◆ operator bool()

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

Definition at line 101 of file compiler_backend.cc.

101  {
102  return !!GetCompiler();
103 }

◆ operator->()

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

Definition at line 28 of file compiler_backend.cc.

28  {
29  return GetCompiler();
30 }

References GetCompiler().


The documentation for this struct was generated from the following files:
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:51
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