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"
19 
20 namespace impeller {
21 
22 class ContextVK;
23 
24 class PipelineLibraryVK final
25  : public PipelineLibrary,
26  public BackendCast<PipelineLibraryVK, PipelineLibrary> {
27  public:
28  // |PipelineLibrary|
29  ~PipelineLibraryVK() override;
30 
32 
33  const std::shared_ptr<PipelineCacheVK>& GetPSOCache() const;
34 
35  const std::shared_ptr<fml::ConcurrentTaskRunner>& GetWorkerTaskRunner() const;
36 
37  private:
38  friend ContextVK;
39 
40  std::weak_ptr<DeviceHolderVK> device_holder_;
41  std::shared_ptr<PipelineCacheVK> pso_cache_;
42  std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner_;
43  Mutex pipelines_mutex_;
44  PipelineMap pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
45  Mutex compute_pipelines_mutex_;
46  ComputePipelineMap compute_pipelines_ IPLR_GUARDED_BY(
47  compute_pipelines_mutex_);
48  std::atomic_size_t frames_acquired_ = 0u;
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 
80  void PersistPipelineCacheToDisk();
81 
82  PipelineLibraryVK(const PipelineLibraryVK&) = delete;
83 
84  PipelineLibraryVK& operator=(const PipelineLibraryVK&) = delete;
85 };
86 
87 } // namespace impeller
88 
89 #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::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap