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"
21 
22 namespace impeller {
23 
24 class ContextVK;
25 
26 class PipelineLibraryVK final
27  : public PipelineLibrary,
28  public BackendCast<PipelineLibraryVK, PipelineLibrary> {
29  public:
30  // |PipelineLibrary|
31  ~PipelineLibraryVK() override;
32 
34 
35  const std::shared_ptr<PipelineCacheVK>& GetPSOCache() const;
36 
37  const std::shared_ptr<fml::ConcurrentTaskRunner>& GetWorkerTaskRunner() const;
38 
39  private:
40  friend ContextVK;
41 
42  std::weak_ptr<DeviceHolderVK> device_holder_;
43  std::shared_ptr<PipelineCacheVK> pso_cache_;
44  std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner_;
45  Mutex pipelines_mutex_;
46  PipelineMap pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
47  ComputePipelineMap compute_pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
48  std::atomic_size_t frames_acquired_ = 0u;
49  PipelineKey pipeline_key_ IPLR_GUARDED_BY(pipelines_mutex_) = 1;
50  bool is_valid_ = false;
51  bool cache_dirty_ = false;
52  std::shared_ptr<PipelineCompileQueue> compile_queue_;
53 
55  const std::shared_ptr<DeviceHolderVK>& device_holder,
56  std::shared_ptr<const Capabilities> caps,
57  fml::UniqueFD cache_directory,
58  std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);
59 
60  // |PipelineLibrary|
61  bool IsValid() const override;
62 
63  // |PipelineLibrary|
65  PipelineDescriptor descriptor,
66  bool async,
67  bool threadsafe = false) override;
68 
69  // |PipelineLibrary|
71  ComputePipelineDescriptor descriptor,
72  bool async) override;
73 
74  // |PipelineLibrary|
75  bool HasPipeline(const PipelineDescriptor& descriptor) override;
76 
77  // |PipelineLibrary|
78  void RemovePipelinesWithEntryPoint(
79  std::shared_ptr<const ShaderFunction> function) override;
80 
81  // |PipelineLibrary|
82  PipelineCompileQueue* GetPipelineCompileQueue() const override;
83 
84  std::unique_ptr<ComputePipelineVK> CreateComputePipeline(
85  const ComputePipelineDescriptor& desc,
86  PipelineKey pipeline_key);
87 
88  void PersistPipelineCacheToDisk();
89 
90  PipelineLibraryVK(const PipelineLibraryVK&) = delete;
91 
92  PipelineLibraryVK& operator=(const PipelineLibraryVK&) = delete;
93 };
94 
95 } // namespace impeller
96 
97 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_LIBRARY_VK_H_
A task queue designed for managing compilation of pipeline state objects.
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:22
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap