| 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_library.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
31 void DidAcquireSurfaceFrame();
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
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
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_
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::ComputePipelineDescriptor
Definition: compute_pipeline_descriptor.h:20
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:24
impeller::PipelineLibraryVK::~PipelineLibraryVK
~PipelineLibraryVK() override
pipeline_vk.h
impeller::PipelineLibraryVK::DidAcquireSurfaceFrame
void DidAcquireSurfaceFrame()
Definition: pipeline_library_vk.cc:279
impeller::PipelineLibraryVK::GetPSOCache
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
Definition: pipeline_library_vk.cc:300
vk.h
impeller::PipelineFuture
Definition: pipeline.h:25
impeller::PipelineLibrary
Definition: pipeline_library.h:29
impeller::PipelineLibraryVK::GetWorkerTaskRunner
const std::shared_ptr< fml::ConcurrentTaskRunner > & GetWorkerTaskRunner() const
Definition: pipeline_library_vk.cc:305
compute_pipeline_vk.h
backend_cast.h
pipeline_cache_vk.h
impeller::PipelineMap
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap
Definition: pipeline_library.h:21
pipeline_library.h
impeller::ContextVK
Definition: context_vk.h:42
impeller::ComputePipelineMap
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
Definition: pipeline_library.h:27
impeller::BackendCast
Definition: backend_cast.h:11
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
thread.h
impeller
Definition: allocation.cc:12