5#include "flutter/lib/gpu/shader.h"
9#include "flutter/lib/gpu/formats.h"
24 return member.name == name;
34Shader::Shader() =
default;
39 std::string entrypoint,
41 std::shared_ptr<fml::Mapping> code_mapping,
42 std::vector<impeller::ShaderStageIOSlot>
inputs,
43 std::vector<impeller::ShaderStageBufferLayout> layouts,
44 std::unordered_map<std::string, UniformBinding> uniform_structs,
45 std::unordered_map<std::string, impeller::SampledImageSlot>
47 std::vector<impeller::DescriptorSetLayout> descriptor_set_layouts) {
48 auto shader = fml::MakeRefCounted<Shader>();
49 shader->entrypoint_ = std::move(entrypoint);
50 shader->stage_ = stage;
51 shader->code_mapping_ = std::move(code_mapping);
52 shader->inputs_ = std::move(
inputs);
53 shader->layouts_ = std::move(layouts);
54 shader->uniform_structs_ = std::move(uniform_structs);
55 shader->uniform_textures_ = std::move(uniform_textures);
56 shader->descriptor_set_layouts_ = std::move(descriptor_set_layouts);
66 auto& lib = *context.
GetContext()->GetShaderLibrary();
75 auto& lib = *context.
GetContext()->GetShaderLibrary();
77 std::promise<bool> promise;
78 auto future = promise.get_future();
80 entrypoint_, stage_, code_mapping_,
92 auto vertex_descriptor = std::make_shared<impeller::VertexDescriptor>();
93 vertex_descriptor->SetStageInputs(inputs_, layouts_);
94 return vertex_descriptor;
101const std::vector<impeller::DescriptorSetLayout>&
103 return descriptor_set_layouts_;
107 const std::string&
name)
const {
108 auto uniform = uniform_structs_.find(
name);
109 if (uniform == uniform_structs_.end()) {
112 return &uniform->second;
116 const std::string&
name)
const {
117 auto uniform = uniform_textures_.find(
name);
118 if (uniform == uniform_textures_.end()) {
121 return &uniform->second;
136 if (uniform ==
nullptr) {
149 if (uniform ==
nullptr) {
154 const auto* member = uniform->GetMemberMetadata(member_name);
155 if (member ==
nullptr) {
159 return member->offset;
std::shared_ptr< impeller::Context > GetContext()
An immutable collection of shaders loaded from a shader bundle asset.
const Shader::UniformBinding * GetUniformStruct(const std::string &name) const
impeller::ShaderStage GetShaderStage() const
bool IsRegistered(Context &context)
bool RegisterSync(Context &context)
static fml::RefPtr< Shader > Make(std::string entrypoint, impeller::ShaderStage stage, std::shared_ptr< fml::Mapping > code_mapping, std::vector< impeller::ShaderStageIOSlot > inputs, std::vector< impeller::ShaderStageBufferLayout > layouts, std::unordered_map< std::string, UniformBinding > uniform_structs, std::unordered_map< std::string, impeller::SampledImageSlot > uniform_textures, std::vector< impeller::DescriptorSetLayout > descriptor_set_layouts)
std::shared_ptr< impeller::VertexDescriptor > CreateVertexDescriptor() const
const std::vector< impeller::DescriptorSetLayout > & GetDescriptorSetLayouts() const
const impeller::SampledImageSlot * GetUniformTexture(const std::string &name) const
std::shared_ptr< const impeller::ShaderFunction > GetFunctionFromLibrary(impeller::ShaderLibrary &library)
virtual std::shared_ptr< const ShaderFunction > GetFunction(std::string_view name, ShaderStage stage)=0
struct _Dart_Handle * Dart_Handle
int InternalFlutterGpu_Shader_GetUniformStructSize(flutter::gpu::Shader *wrapper, Dart_Handle struct_name_handle)
int InternalFlutterGpu_Shader_GetUniformMemberOffset(flutter::gpu::Shader *wrapper, Dart_Handle struct_name_handle, Dart_Handle member_name_handle)
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, CommandBuffer)
DEF_SWITCHES_START aot vmservice shared library name
internal::CopyableLambda< T > MakeCopyable(T lambda)
std::string StdStringFromDart(Dart_Handle handle)
Metadata required to bind a combined texture and sampler.