Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
impeller::RuntimeStage Class Reference

#include <runtime_stage.h>

Public Types

using Map = std::map< RuntimeStageBackend, std::shared_ptr< RuntimeStage > >
 

Public Member Functions

 RuntimeStage (const fb::RuntimeStage *runtime_stage, const std::shared_ptr< fml::Mapping > &payload)
 
 ~RuntimeStage ()
 
 RuntimeStage (RuntimeStage &&)
 
RuntimeStageoperator= (RuntimeStage &&)
 
bool IsValid () const
 
RuntimeShaderStage GetShaderStage () const
 
const std::vector< RuntimeUniformDescription > & GetUniforms () const
 
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts () const
 
const std::string & GetEntrypoint () const
 
const RuntimeUniformDescriptionGetUniform (const std::string &name) const
 
const std::shared_ptr< fml::Mapping > & GetCodeMapping () const
 
bool IsDirty () const
 
void SetClean ()
 

Static Public Member Functions

static Map DecodeRuntimeStages (const std::shared_ptr< fml::Mapping > &payload)
 

Static Public Attributes

static const char * kVulkanUBOName
 

Detailed Description

Definition at line 20 of file runtime_stage.h.

Member Typedef Documentation

◆ Map

using impeller::RuntimeStage::Map = std::map<RuntimeStageBackend, std::shared_ptr<RuntimeStage> >

Definition at line 24 of file runtime_stage.h.

Constructor & Destructor Documentation

◆ RuntimeStage() [1/2]

impeller::RuntimeStage::RuntimeStage ( const fb::RuntimeStage *  runtime_stage,
const std::shared_ptr< fml::Mapping > &  payload 
)

Definition at line 83 of file runtime_stage.cc.

85 : payload_(payload) {
86 FML_DCHECK(runtime_stage);
87
88 stage_ = ToShaderStage(runtime_stage->stage());
89 entrypoint_ = runtime_stage->entrypoint()->str();
90
91 auto* uniforms = runtime_stage->uniforms();
92 if (uniforms) {
93 for (auto i = uniforms->begin(), end = uniforms->end(); i != end; i++) {
94 RuntimeUniformDescription desc;
95 desc.name = i->name()->str();
96 desc.location = i->location();
97 desc.binding = i->binding();
98 desc.type = ToType(i->type());
99 desc.dimensions = RuntimeUniformDimensions{
100 static_cast<size_t>(i->rows()), static_cast<size_t>(i->columns())};
101 desc.bit_width = i->bit_width();
102 desc.array_elements = i->array_elements();
103 if (i->struct_layout()) {
104 for (const auto& byte_type : *i->struct_layout()) {
105 desc.struct_layout.push_back(static_cast<uint8_t>(byte_type));
106 }
107 }
108 desc.binding = i->binding();
109 desc.struct_float_count = i->struct_float_count();
110 uniforms_.push_back(std::move(desc));
111 }
112 }
113
114 code_mapping_ = std::make_shared<fml::NonOwnedMapping>(
115 runtime_stage->shader()->data(), //
116 runtime_stage->shader()->size(), //
117 [payload = payload_](auto, auto) {} //
118 );
119
120 for (const auto& uniform : GetUniforms()) {
121 if (uniform.type == kStruct) {
122 descriptor_set_layouts_.push_back(DescriptorSetLayout{
123 static_cast<uint32_t>(uniform.location),
126 });
127 } else if (uniform.type == kSampledImage) {
128 descriptor_set_layouts_.push_back(DescriptorSetLayout{
129 static_cast<uint32_t>(uniform.binding),
132 });
133 }
134 }
135
136 is_valid_ = true;
137}
const std::vector< RuntimeUniformDescription > & GetUniforms() const
glong glong end
#define FML_DCHECK(condition)
Definition logging.h:103
constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage)
static RuntimeUniformType ToType(fb::UniformDataType type)

◆ ~RuntimeStage()

impeller::RuntimeStage::~RuntimeStage ( )
default

◆ RuntimeStage() [2/2]

impeller::RuntimeStage::RuntimeStage ( RuntimeStage &&  )
default

Member Function Documentation

◆ DecodeRuntimeStages()

RuntimeStage::Map impeller::RuntimeStage::DecodeRuntimeStages ( const std::shared_ptr< fml::Mapping > &  payload)
static

Definition at line 61 of file runtime_stage.cc.

62 {
63 if (payload == nullptr || !payload->GetMapping()) {
64 return {};
65 }
66 if (!fb::RuntimeStagesBufferHasIdentifier(payload->GetMapping())) {
67 return {};
68 }
69
70 auto raw_stages = fb::GetRuntimeStages(payload->GetMapping());
71 return {
73 RuntimeStageIfPresent(raw_stages->sksl(), payload)},
75 RuntimeStageIfPresent(raw_stages->metal(), payload)},
77 RuntimeStageIfPresent(raw_stages->opengles(), payload)},
79 RuntimeStageIfPresent(raw_stages->vulkan(), payload)},
80 };
81}

◆ GetCodeMapping()

const std::shared_ptr< fml::Mapping > & impeller::RuntimeStage::GetCodeMapping ( ) const

Definition at line 147 of file runtime_stage.cc.

147 {
148 return code_mapping_;
149}

◆ GetDescriptorSetLayouts()

const std::vector< DescriptorSetLayout > & impeller::RuntimeStage::GetDescriptorSetLayouts ( ) const

Definition at line 182 of file runtime_stage.cc.

183 {
184 return descriptor_set_layouts_;
185}

◆ GetEntrypoint()

const std::string & impeller::RuntimeStage::GetEntrypoint ( ) const

Definition at line 166 of file runtime_stage.cc.

166 {
167 return entrypoint_;
168}

◆ GetShaderStage()

RuntimeShaderStage impeller::RuntimeStage::GetShaderStage ( ) const

Definition at line 170 of file runtime_stage.cc.

170 {
171 return stage_;
172}

◆ GetUniform()

const RuntimeUniformDescription * impeller::RuntimeStage::GetUniform ( const std::string &  name) const

Definition at line 156 of file runtime_stage.cc.

157 {
158 for (const auto& uniform : uniforms_) {
159 if (uniform.name == name) {
160 return &uniform;
161 }
162 }
163 return nullptr;
164}
const char * name
Definition fuchsia.cc:50

◆ GetUniforms()

const std::vector< RuntimeUniformDescription > & impeller::RuntimeStage::GetUniforms ( ) const

Definition at line 151 of file runtime_stage.cc.

152 {
153 return uniforms_;
154}

◆ IsDirty()

bool impeller::RuntimeStage::IsDirty ( ) const

Definition at line 174 of file runtime_stage.cc.

174 {
175 return is_dirty_;
176}

◆ IsValid()

bool impeller::RuntimeStage::IsValid ( ) const

Definition at line 143 of file runtime_stage.cc.

143 {
144 return is_valid_;
145}

◆ operator=()

RuntimeStage & impeller::RuntimeStage::operator= ( RuntimeStage &&  )
default

◆ SetClean()

void impeller::RuntimeStage::SetClean ( )

Definition at line 178 of file runtime_stage.cc.

178 {
179 is_dirty_ = false;
180}

Member Data Documentation

◆ kVulkanUBOName

const char * impeller::RuntimeStage::kVulkanUBOName
static
Initial value:
=
"_RESERVED_IDENTIFIER_FIXUP_gl_DefaultUniformBlock"

The generated name from GLSLang/shaderc for the UBO containing non-opaque uniforms specified in the user-written runtime effect shader.

Vulkan does not allow non-opaque uniforms outside of a UBO.

Definition at line 22 of file runtime_stage.h.


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