Flutter Impeller
pipeline_library_vk.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_BACKEND_VULKAN_PIPELINE_LIBRARY_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_LIBRARY_VK_H_
7 
8 #include <atomic>
9 
10 #include "flutter/fml/concurrent_message_loop.h"
11 #include "flutter/fml/unique_fd.h"
13 #include "impeller/base/thread.h"
20 
21 namespace impeller {
22 
23 class ContextVK;
24 
25 class PipelineLibraryVK final
26  : public PipelineLibrary,
27  public BackendCast<PipelineLibraryVK, PipelineLibrary> {
28  public:
29  // |PipelineLibrary|
30  ~PipelineLibraryVK() override;
31 
33 
34  const std::shared_ptr<PipelineCacheVK>& GetPSOCache() const;
35 
36  const std::shared_ptr<fml::ConcurrentTaskRunner>& GetWorkerTaskRunner() const;
37 
38  private:
39  friend ContextVK;
40 
41  std::weak_ptr<DeviceHolderVK> device_holder_;
42  std::shared_ptr<PipelineCacheVK> pso_cache_;
43  std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner_;
44  Mutex pipelines_mutex_;
45  PipelineMap pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
46  ComputePipelineMap compute_pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
47  std::atomic_size_t frames_acquired_ = 0u;
48  PipelineKey pipeline_key_ IPLR_GUARDED_BY(pipelines_mutex_) = 1;
49  bool is_valid_ = false;
50  bool cache_dirty_ = false;
51 
53  const std::shared_ptr<DeviceHolderVK>& device_holder,
54  std::shared_ptr<const Capabilities> caps,
55  fml::UniqueFD cache_directory,
56  std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);
57 
58  // |PipelineLibrary|
59  bool IsValid() const override;
60 
61  // |PipelineLibrary|
63  bool async) override;
64 
65  // |PipelineLibrary|
67  ComputePipelineDescriptor descriptor,
68  bool async) override;
69 
70  // |PipelineLibrary|
71  bool HasPipeline(const PipelineDescriptor& descriptor) override;
72 
73  // |PipelineLibrary|
74  void RemovePipelinesWithEntryPoint(
75  std::shared_ptr<const ShaderFunction> function) override;
76 
77  std::unique_ptr<ComputePipelineVK> CreateComputePipeline(
78  const ComputePipelineDescriptor& desc,
79  PipelineKey pipeline_key);
80 
81  void PersistPipelineCacheToDisk();
82 
83  PipelineLibraryVK(const PipelineLibraryVK&) = delete;
84 
85  PipelineLibraryVK& operator=(const PipelineLibraryVK&) = delete;
86 };
87 
88 } // namespace impeller
89 
90 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_LIBRARY_VK_H_
const std::shared_ptr< fml::ConcurrentTaskRunner > & GetWorkerTaskRunner() const
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
std::vector< std::pair< uint64_t, std::unique_ptr< GenericRenderPipelineHandle > > > pipelines_
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
int64_t PipelineKey
Definition: pipeline.h:21
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap