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::shared_ptr<impeller::VertexDescriptor> vertex_desc,
43 std::unordered_map<std::string, UniformBinding> uniform_structs,
44 std::unordered_map<std::string, impeller::SampledImageSlot>
46 auto shader = fml::MakeRefCounted<Shader>();
47 shader->entrypoint_ = std::move(entrypoint);
48 shader->stage_ = stage;
49 shader->code_mapping_ = std::move(code_mapping);
50 shader->vertex_desc_ = std::move(vertex_desc);
51 shader->uniform_structs_ = std::move(uniform_structs);
52 shader->uniform_textures_ = std::move(uniform_textures);
62 auto& lib = *context.
GetContext()->GetShaderLibrary();
71 auto& lib = *context.
GetContext()->GetShaderLibrary();
73 std::promise<bool> promise;
74 auto future = promise.get_future();
76 entrypoint_, stage_, code_mapping_,
96 const std::string&
name)
const {
97 auto uniform = uniform_structs_.find(
name);
98 if (uniform == uniform_structs_.end()) {
101 return &uniform->second;
105 const std::string&
name)
const {
106 auto uniform = uniform_textures_.find(
name);
107 if (uniform == uniform_textures_.end()) {
110 return &uniform->second;
125 if (uniform ==
nullptr) {
138 if (uniform ==
nullptr) {
143 const auto* member = uniform->GetMemberMetadata(member_name);
144 if (member ==
nullptr) {
148 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)
std::shared_ptr< impeller::VertexDescriptor > GetVertexDescriptor() const
const impeller::SampledImageSlot * GetUniformTexture(const std::string &name) const
static fml::RefPtr< Shader > Make(std::string entrypoint, impeller::ShaderStage stage, std::shared_ptr< fml::Mapping > code_mapping, std::shared_ptr< impeller::VertexDescriptor > vertex_desc, std::unordered_map< std::string, UniformBinding > uniform_structs, std::unordered_map< std::string, impeller::SampledImageSlot > uniform_textures)
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
#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)
Metadata required to bind a combined texture and sampler.