14#include "impeller/runtime_stage/runtime_stage_flatbuffers.h"
15#include "runtime_stage_types_flatbuffers.h"
33 case fb::Stage::kVertex:
35 case fb::Stage::kFragment:
37 case fb::Stage::kCompute:
48 "_RESERVED_IDENTIFIER_FIXUP_gl_DefaultUniformBlock";
50std::unique_ptr<RuntimeStage> RuntimeStage::RuntimeStageIfPresent(
51 const fb::RuntimeStage* runtime_stage,
52 const std::shared_ptr<fml::Mapping>& payload) {
57 return std::unique_ptr<RuntimeStage>(
62 const std::shared_ptr<fml::Mapping>& payload) {
63 if (payload ==
nullptr || !payload->GetMapping()) {
66 if (!fb::RuntimeStagesBufferHasIdentifier(payload->GetMapping())) {
70 auto raw_stages = fb::GetRuntimeStages(payload->GetMapping());
73 RuntimeStageIfPresent(raw_stages->sksl(), payload)},
75 RuntimeStageIfPresent(raw_stages->metal(), payload)},
77 RuntimeStageIfPresent(raw_stages->opengles(), payload)},
79 RuntimeStageIfPresent(raw_stages->vulkan(), payload)},
84 const std::shared_ptr<fml::Mapping>& payload)
89 entrypoint_ = runtime_stage->entrypoint()->str();
91 auto* uniforms = runtime_stage->uniforms();
97 std::optional<size_t> ubo_id;
99 for (
auto i = uniforms->begin(),
end = uniforms->end();
i !=
end;
i++) {
101 desc.name =
i->name()->str();
102 desc.location =
i->location();
103 desc.binding =
i->binding();
106 ubo_id =
desc.location;
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 if (
i->struct_layout()) {
114 for (
const auto& byte_type : *
i->struct_layout()) {
115 desc.struct_layout.push_back(
static_cast<uint8_t
>(byte_type));
118 desc.struct_float_count =
i->struct_float_count();
119 uniforms_.push_back(std::move(
desc));
123 code_mapping_ = std::make_shared<fml::NonOwnedMapping>(
124 runtime_stage->shader()->data(),
125 runtime_stage->shader()->size(),
126 [payload = payload_](
auto,
auto) {}
130 if (ubo_id.has_value() && ubo_id.value() == binding) {
133 for (
auto& uniform : uniforms_) {
135 uniform.binding = binding;
137 if (ubo_id.has_value() && ubo_id.value() == binding) {
146 static_cast<uint32_t
>(uniform.location),
152 static_cast<uint32_t
>(uniform.binding),
170 return code_mapping_;
179 const std::string&
name)
const {
180 for (
const auto& uniform : uniforms_) {
181 if (uniform.name ==
name) {
206 return descriptor_set_layouts_;
const std::string & GetEntrypoint() const
RuntimeStage & operator=(RuntimeStage &&)
const std::vector< RuntimeUniformDescription > & GetUniforms() const
const RuntimeUniformDescription * GetUniform(const std::string &name) const
std::map< RuntimeStageBackend, std::shared_ptr< RuntimeStage > > Map
static const char * kVulkanUBOName
static Map DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)
const std::shared_ptr< fml::Mapping > & GetCodeMapping() const
const std::vector< DescriptorSetLayout > & GetDescriptorSetLayouts() const
RuntimeShaderStage GetShaderStage() const
RuntimeStage(const fb::RuntimeStage *runtime_stage, const std::shared_ptr< fml::Mapping > &payload)
#define FML_UNREACHABLE()
#define FML_DCHECK(condition)
void(ABI *)(Params *, SkRasterPipelineStage *program, F r, F g, F b, F a) Stage
DEF_SWITCHES_START aot vmservice shared library name
constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage)
static RuntimeUniformType ToType(fb::UniformDataType type)