| 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"
12 #include "impeller/base/backend_cast.h"
13 #include "impeller/base/thread.h"
14 #include "impeller/renderer/backend/vulkan/compute_pipeline_vk.h"
15 #include "impeller/renderer/backend/vulkan/pipeline_cache_vk.h"
16 #include "impeller/renderer/backend/vulkan/pipeline_vk.h"
17 #include "impeller/renderer/backend/vulkan/vk.h"
18 #include "impeller/renderer/pipeline.h"
19 #include "impeller/renderer/pipeline_library.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
32 void DidAcquireSurfaceFrame();
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
52 PipelineLibraryVK(
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|
62 PipelineFuture<PipelineDescriptor> GetPipeline(PipelineDescriptor descriptor,
63 bool async) override;
64
65 // |PipelineLibrary|
66 PipelineFuture<ComputePipelineDescriptor> GetPipeline(
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_
backend_cast.h
impeller::BackendCast
Definition: backend_cast.h:11
impeller::ComputePipelineDescriptor
Definition: compute_pipeline_descriptor.h:21
impeller::ContextVK
Definition: context_vk.h:66
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineLibrary
Definition: pipeline_library.h:30
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:27
impeller::PipelineLibraryVK::~PipelineLibraryVK
~PipelineLibraryVK() override
impeller::PipelineLibraryVK::DidAcquireSurfaceFrame
void DidAcquireSurfaceFrame()
Definition: pipeline_library_vk.cc:276
impeller::PipelineLibraryVK::GetWorkerTaskRunner
const std::shared_ptr< fml::ConcurrentTaskRunner > & GetWorkerTaskRunner() const
Definition: pipeline_library_vk.cc:302
impeller::PipelineLibraryVK::GetPSOCache
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
Definition: pipeline_library_vk.cc:297
compute_pipeline_vk.h
pipelines_
std::vector< std::pair< uint64_t, std::unique_ptr< GenericRenderPipelineHandle > > > pipelines_
Definition: content_context.cc:78
impeller
Definition: allocation.cc:12
impeller::ComputePipelineMap
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
Definition: pipeline_library.h:28
impeller::PipelineKey
int64_t PipelineKey
Definition: pipeline.h:21
impeller::PipelineMap
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap
Definition: pipeline_library.h:22
pipeline.h
pipeline_cache_vk.h
pipeline_library.h
pipeline_vk.h
impeller::PipelineFuture
Definition: pipeline.h:28
thread.h
vk.h