| Flutter Impeller |

pipeline_library.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_RENDERER_PIPELINE_LIBRARY_H_
6 #define FLUTTER_IMPELLER_RENDERER_PIPELINE_LIBRARY_H_
7
8 #include <optional>
9 #include <unordered_map>
10
11 #include "compute_pipeline_descriptor.h"
12 #include "impeller/renderer/pipeline.h"
13 #include "impeller/renderer/pipeline_descriptor.h"
14
15 namespace impeller {
16
17 class Context;
18
19 using PipelineMap = std::unordered_map<PipelineDescriptor,
20 PipelineFuture<PipelineDescriptor>,
21 ComparableHash<PipelineDescriptor>,
22 ComparableEqual<PipelineDescriptor>>;
23
24 using ComputePipelineMap =
25 std::unordered_map<ComputePipelineDescriptor,
26 PipelineFuture<ComputePipelineDescriptor>,
27 ComparableHash<ComputePipelineDescriptor>,
28 ComparableEqual<ComputePipelineDescriptor>>;
29
30 class PipelineLibrary : public std::enable_shared_from_this<PipelineLibrary> {
31 public:
32 virtual ~PipelineLibrary();
33
34 PipelineFuture<PipelineDescriptor> GetPipeline(
35 std::optional<PipelineDescriptor> descriptor,
36 bool async = true);
37
38 PipelineFuture<ComputePipelineDescriptor> GetPipeline(
39 std::optional<ComputePipelineDescriptor> descriptor,
40 bool async = true);
41
42 virtual bool IsValid() const = 0;
43
44 //------------------------------------------------------------------------------
45 /// @brief Creates a pipeline.
46 ///
47 /// @param[in] descriptor The descriptor of the texture to create.
48 /// @param[in] async Whether to allow pipeline creation to be deferred.
49 /// If `false`, pipeline creation will block on the
50 /// current thread.
51 ///
52 /// @param[in] threadsafe Whether mutations to this texture should be
53 /// protected with a threadsafe barrier.
54 ///
55 /// This parameter only affects the OpenGLES rendering
56 /// backend.
57 ///
58 /// If any interaction with this texture (including
59 /// creation) will be done on a thread other than
60 /// where the OpenGLES context resides, then
61 /// `threadsafe`, must be set to `true`.
62 ///
63 virtual PipelineFuture<PipelineDescriptor> GetPipeline(
64 PipelineDescriptor descriptor,
65 bool async = true,
66 bool threadsafe = false) = 0;
67
68 virtual PipelineFuture<ComputePipelineDescriptor> GetPipeline(
69 ComputePipelineDescriptor descriptor,
70 bool async = true) = 0;
71
72 virtual bool HasPipeline(const PipelineDescriptor& descriptor) = 0;
73
74 virtual void RemovePipelinesWithEntryPoint(
75 std::shared_ptr<const ShaderFunction> function) = 0;
76
77 protected:
78 PipelineLibrary();
79
80 private:
81 PipelineLibrary(const PipelineLibrary&) = delete;
82
83 PipelineLibrary& operator=(const PipelineLibrary&) = delete;
84 };
85
86 } // namespace impeller
87
88 #endif // FLUTTER_IMPELLER_RENDERER_PIPELINE_LIBRARY_H_
impeller::ComputePipelineDescriptor
Definition: compute_pipeline_descriptor.h:21
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineLibrary
Definition: pipeline_library.h:30
impeller::PipelineLibrary::PipelineLibrary
PipelineLibrary()
impeller::PipelineLibrary::HasPipeline
virtual bool HasPipeline(const PipelineDescriptor &descriptor)=0
impeller::PipelineLibrary::RemovePipelinesWithEntryPoint
virtual void RemovePipelinesWithEntryPoint(std::shared_ptr< const ShaderFunction > function)=0
impeller::PipelineLibrary::GetPipeline
virtual PipelineFuture< ComputePipelineDescriptor > GetPipeline(ComputePipelineDescriptor descriptor, bool async=true)=0
impeller::PipelineLibrary::GetPipeline
virtual PipelineFuture< PipelineDescriptor > GetPipeline(PipelineDescriptor descriptor, bool async=true, bool threadsafe=false)=0
Creates a pipeline.
impeller::PipelineLibrary::IsValid
virtual bool IsValid() const =0
impeller::PipelineLibrary::~PipelineLibrary
virtual ~PipelineLibrary()
impeller::PipelineLibrary::GetPipeline
PipelineFuture< PipelineDescriptor > GetPipeline(std::optional< PipelineDescriptor > descriptor, bool async=true)
Definition: pipeline_library.cc:13
compute_pipeline_descriptor.h
impeller
Definition: allocation.cc:12
impeller::ComputePipelineMap
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
Definition: pipeline_library.h:28
impeller::PipelineMap
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap
Definition: pipeline_library.h:22
pipeline.h
pipeline_descriptor.h
impeller::ComparableEqual
Definition: comparable.h:48
impeller::ComparableHash
Definition: comparable.h:39
impeller::PipelineFuture
Definition: pipeline.h:28