4
4
5
5
#include " impeller/renderer/pipeline.h"
6
6
7
+ #include " impeller/base/base.h"
7
8
#include " impeller/renderer/context.h"
8
9
#include " impeller/renderer/pipeline_library.h"
9
10
10
11
namespace impeller {
11
12
12
- Pipeline::Pipeline (PipelineDescriptor desc) : desc_(std::move(desc)) {}
13
+ Pipeline::Pipeline (std::weak_ptr<PipelineLibrary> library,
14
+ PipelineDescriptor desc)
15
+ : library_(std::move(library)), desc_(std::move(desc)) {}
13
16
14
17
Pipeline::~Pipeline () = default ;
15
18
16
19
PipelineFuture CreatePipelineFuture (const Context& context,
17
20
std::optional<PipelineDescriptor> desc) {
18
21
if (!context.IsValid ()) {
19
- std::promise<std::shared_ptr<Pipeline>> promise;
20
- auto future = promise.get_future ();
21
- promise.set_value (nullptr );
22
- return future;
22
+ return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr );
23
23
}
24
24
25
25
return context.GetPipelineLibrary ()->GetRenderPipeline (std::move (desc));
@@ -29,4 +29,24 @@ const PipelineDescriptor& Pipeline::GetDescriptor() const {
29
29
return desc_;
30
30
}
31
31
32
+ PipelineFuture Pipeline::CreateVariant (
33
+ std::function<void (PipelineDescriptor& desc)> descriptor_callback) const {
34
+ if (!descriptor_callback) {
35
+ return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr );
36
+ }
37
+
38
+ auto copied_desc = desc_;
39
+
40
+ descriptor_callback (copied_desc);
41
+
42
+ auto library = library_.lock ();
43
+ if (!library) {
44
+ VALIDATION_LOG << " The library from which this pipeline was created was "
45
+ " already collected." ;
46
+ return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr );
47
+ }
48
+
49
+ return library->GetRenderPipeline (std::move (copied_desc));
50
+ }
51
+
32
52
} // namespace impeller
0 commit comments