25 return member.name == name;
35Shader::Shader() =
default;
40 std::string library_id,
41 std::string entrypoint,
43 std::shared_ptr<fml::Mapping> code_mapping,
44 std::vector<impeller::ShaderStageIOSlot> inputs,
45 std::vector<impeller::ShaderStageBufferLayout> layouts,
46 std::unordered_map<std::string, UniformBinding> uniform_structs,
47 std::unordered_map<std::string, TextureBinding> uniform_textures,
48 std::vector<impeller::DescriptorSetLayout> descriptor_set_layouts) {
49 auto shader = fml::MakeRefCounted<Shader>();
50 shader->library_id_ = std::move(library_id);
51 shader->entrypoint_ = std::move(entrypoint);
52 shader->stage_ = stage;
53 shader->code_mapping_ = std::move(code_mapping);
54 shader->inputs_ = std::move(inputs);
55 shader->layouts_ = std::move(layouts);
56 shader->uniform_structs_ = std::move(uniform_structs);
57 shader->uniform_textures_ = std::move(uniform_textures);
58 shader->descriptor_set_layouts_ = std::move(descriptor_set_layouts);
62std::string Shader::GetScopedName()
const {
69 return library.
GetFunction(GetScopedName(), stage_);
84 std::promise<bool> promise;
85 auto future = promise.get_future();
87 GetScopedName(), stage_, code_mapping_,
89 promise.set_value(result);
99 auto vertex_descriptor = std::make_shared<impeller::VertexDescriptor>();
100 vertex_descriptor->SetStageInputs(inputs_, layouts_);
101 return vertex_descriptor;
108const std::vector<impeller::ShaderStageBufferLayout>&
117const std::vector<impeller::DescriptorSetLayout>&
119 return descriptor_set_layouts_;
123 const std::string&
name)
const {
124 auto uniform = uniform_structs_.find(
name);
125 if (uniform == uniform_structs_.end()) {
128 return &uniform->second;
132 const std::string&
name)
const {
133 auto uniform = uniform_textures_.find(
name);
134 if (uniform == uniform_textures_.end()) {
137 return &uniform->second;
149 Dart_Handle struct_name_handle) {
152 if (uniform ==
nullptr) {
161 Dart_Handle struct_name_handle,
162 Dart_Handle member_name_handle) {
165 if (uniform ==
nullptr) {
170 const auto* member = uniform->GetMemberMetadata(member_name);
171 if (member ==
nullptr) {
175 return member->offset;
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)
const std::vector< impeller::ShaderStageIOSlot > & GetStageInputs() const
std::shared_ptr< impeller::VertexDescriptor > CreateVertexDescriptor() const
static fml::RefPtr< Shader > Make(std::string library_id, 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, TextureBinding > uniform_textures, std::vector< impeller::DescriptorSetLayout > descriptor_set_layouts)
const std::vector< impeller::ShaderStageBufferLayout > & GetStageBufferLayouts() const
const std::vector< impeller::DescriptorSetLayout > & GetDescriptorSetLayouts() const
const Shader::TextureBinding * GetUniformTexture(const std::string &name) const
std::shared_ptr< const impeller::ShaderFunction > GetFunctionFromLibrary(impeller::ShaderLibrary &library)
virtual std::shared_ptr< ShaderLibrary > GetShaderLibrary() const =0
Returns the library of shaders used to specify the programmable stages of a pipeline.
virtual std::shared_ptr< const ShaderFunction > GetFunction(std::string_view name, ShaderStage stage)=0
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
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)
DEF_SWITCHES_START aot vmservice shared library name
internal::CopyableLambda< T > MakeCopyable(T lambda)
std::string StdStringFromDart(Dart_Handle handle)
static constexpr std::string_view kScopeFlutterGPU
Scope tag for Flutter GPU user shader bundles.
static std::string MakeUserScopedName(std::string_view scope, std::string_view library_id, std::string_view entrypoint)