5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_PIPELINE_LIBRARY_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_PIPELINE_LIBRARY_GLES_H_
8 #include <unordered_map>
11 #include "flutter/fml/hash_combine.h"
25 public BackendCast<PipelineLibraryGLES, PipelineLibrary> {
45 std::shared_ptr<const ShaderFunction> vertex_shader;
46 std::shared_ptr<const ShaderFunction> fragment_shader;
51 std::vector<Scalar> specialization_constants;
53 ProgramKey(std::shared_ptr<const ShaderFunction> p_vertex_shader,
54 std::shared_ptr<const ShaderFunction> p_fragment_shader,
55 std::vector<Scalar> p_specialization_constants)
56 : vertex_shader(std::move(p_vertex_shader)),
57 fragment_shader(std::move(p_fragment_shader)),
58 specialization_constants(std::move(p_specialization_constants)) {}
62 auto seed = fml::HashCombine();
63 if (key.vertex_shader) {
64 fml::HashCombineSeed(seed, key.vertex_shader->GetHash());
66 if (key.fragment_shader) {
67 fml::HashCombineSeed(seed, key.fragment_shader->GetHash());
69 for (
const auto& constant : key.specialization_constants) {
70 fml::HashCombineSeed(seed, constant);
77 bool operator()(
const ProgramKey& lhs,
const ProgramKey& rhs)
const {
80 lhs.specialization_constants == rhs.specialization_constants;
85 using ProgramMap = std::unordered_map<ProgramKey,
86 std::shared_ptr<UniqueHandleGLES>,
90 std::shared_ptr<ReactorGLES> reactor_;
92 Mutex programs_mutex_;
93 ProgramMap programs_ IPLR_GUARDED_BY(programs_mutex_);
98 bool IsValid()
const override;
102 bool async)
override;
107 bool async)
override;
113 void RemovePipelinesWithEntryPoint(
114 std::shared_ptr<const ShaderFunction>
function)
override;
116 const std::shared_ptr<ReactorGLES>& GetReactor()
const;
118 static std::shared_ptr<PipelineGLES> CreatePipeline(
119 const std::weak_ptr<PipelineLibrary>& weak_library,
121 const std::shared_ptr<const ShaderFunction>& vert_shader,
122 const std::shared_ptr<const ShaderFunction>& frag_shader);
124 std::shared_ptr<UniqueHandleGLES> GetProgramForKey(
const ProgramKey& key);
126 void SetProgramForKey(
const ProgramKey& key,
127 std::shared_ptr<UniqueHandleGLES> program);
~PipelineLibraryGLES() override
PipelineLibraryGLES(const PipelineLibraryGLES &)=delete
PipelineLibraryGLES & operator=(const PipelineLibraryGLES &)=delete
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
bool operator()(const ProgramKey &lhs, const ProgramKey &rhs) const
std::size_t operator()(const ProgramKey &key) const