| Flutter Impeller |

Public Types | Public Member Functions | Static Public Member Functions | 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 &&)
RuntimeStage & | operator= (RuntimeStage &&)
bool | IsValid () const
RuntimeShaderStage | GetShaderStage () const
const std::vector< RuntimeUniformDescription > & | GetUniforms () const
const std::string & | GetEntrypoint () const
const RuntimeUniformDescription * | GetUniform (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)

## 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 22 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 94 of file runtime_stage.cc.

96 : payload_(payload) {
97 FML_DCHECK(runtime_stage);
98
99 stage_ = ToShaderStage(runtime_stage->stage());
100 entrypoint_ = runtime_stage->entrypoint()->str();
101
102 auto* uniforms = runtime_stage->uniforms();
103 if (uniforms) {
104 for (auto i = uniforms->begin(), end = uniforms->end(); i != end; i++) {
105 RuntimeUniformDescription desc;
106 desc.name = i->name()->str();
107 desc.location = i->location();
108 desc.type = ToType(i->type());
109 desc.dimensions = RuntimeUniformDimensions{
110 static_cast<size_t>(i->rows()), static_cast<size_t>(i->columns())};
111 desc.bit_width = i->bit_width();
112 desc.array_elements = i->array_elements();
113 uniforms_.emplace_back(std::move(desc));
114 }
115 }
116
117 code_mapping_ = std::make_shared<fml::NonOwnedMapping>(
118 runtime_stage->shader()->data(), //
119 runtime_stage->shader()->size(), //
120 [payload = payload_](auto, auto) {} //
121 );
122
123 is_valid_ = true;
124 }

References impeller::RuntimeUniformDescription::array_elements, impeller::RuntimeUniformDescription::bit_width, impeller::RuntimeUniformDescription::dimensions, impeller::RuntimeUniformDescription::location, impeller::RuntimeUniformDescription::name, impeller::ToShaderStage(), impeller::ToType(), and impeller::RuntimeUniformDescription::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 72 of file runtime_stage.cc.

73 {
74 if (payload == nullptr || !payload->GetMapping()) {
75 return {};
76 }
77 if (!fb::RuntimeStagesBufferHasIdentifier(payload->GetMapping())) {
78 return {};
79 }
80
81 auto raw_stages = fb::GetRuntimeStages(payload->GetMapping());
82 return {
83 {RuntimeStageBackend::kSkSL,
84 RuntimeStageIfPresent(raw_stages->sksl(), payload)},
85 {RuntimeStageBackend::kMetal,
86 RuntimeStageIfPresent(raw_stages->metal(), payload)},
87 {RuntimeStageBackend::kOpenGLES,
88 RuntimeStageIfPresent(raw_stages->opengles(), payload)},
89 {RuntimeStageBackend::kVulkan,
90 RuntimeStageIfPresent(raw_stages->vulkan(), payload)},
91 };
92 }

References impeller::kMetal, impeller::kOpenGLES, impeller::kSkSL, and impeller::kVulkan.

Referenced by impeller::PlaygroundTest::OpenAssetAsRuntimeStage(), impeller::GoldenPlaygroundTest::OpenAssetAsRuntimeStage(), and impeller::testing::TEST_P().

## ◆ GetCodeMapping()

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

Definition at line 134 of file runtime_stage.cc.

134 {
135 return code_mapping_;
136 }

Referenced by impeller::RuntimeStagePlayground::RegisterStage().

## ◆ GetEntrypoint()

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

Definition at line 153 of file runtime_stage.cc.

153 {
154 return entrypoint_;
155 }

Referenced by impeller::RuntimeStagePlayground::RegisterStage().

## ◆ GetShaderStage()

RuntimeShaderStage impeller::RuntimeStage::GetShaderStage | ( |  | ) | const

Definition at line 157 of file runtime_stage.cc.

157 {
158 return stage_;
159 }

Referenced by impeller::RuntimeStagePlayground::RegisterStage().

## ◆ GetUniform()

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

Definition at line 143 of file runtime_stage.cc.

144 {
145 for (const auto& uniform : uniforms_) {
146 if (uniform.name == name) {
147 return &uniform;
148 }
149 }
150 return nullptr;
151 }

## ◆ GetUniforms()

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

Definition at line 138 of file runtime_stage.cc.

139 {
140 return uniforms_;
141 }

## ◆ IsDirty()

bool impeller::RuntimeStage::IsDirty | ( |  | ) | const

Definition at line 161 of file runtime_stage.cc.

161 {
162 return is_dirty_;
163 }

## ◆ IsValid()

bool impeller::RuntimeStage::IsValid | ( |  | ) | const

Definition at line 130 of file runtime_stage.cc.

130 {
131 return is_valid_;
132 }

## ◆ operator=()

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

## ◆ SetClean()

void impeller::RuntimeStage::SetClean | ( |  | ) |

Definition at line 165 of file runtime_stage.cc.

165 {
166 is_dirty_ = false;
167 }

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

- impeller/runtime_stage/runtime_stage.h
- impeller/runtime_stage/runtime_stage.cc

impeller::ToType
static RuntimeUniformType ToType(fb::UniformDataType type)
Definition: runtime_stage.cc:17
impeller::RuntimeStageBackend::kVulkan
@ kVulkan
impeller::ToShaderStage
constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage)
Definition: shader_types.h:29
impeller::RuntimeStageBackend::kOpenGLES
@ kOpenGLES
impeller::RuntimeStageBackend::kSkSL
@ kSkSL
impeller::RuntimeStageBackend::kMetal
@ kMetal