| 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/macros.h"
12 #include "flutter/fml/mapping.h"
13 #include "flutter/fml/unique_fd.h"
14 #include "impeller/base/backend_cast.h"
15 #include "impeller/base/thread.h"
16 #include "impeller/renderer/backend/vulkan/compute_pipeline_vk.h"
17 #include "impeller/renderer/backend/vulkan/pipeline_cache_vk.h"
18 #include "impeller/renderer/backend/vulkan/pipeline_vk.h"
19 #include "impeller/renderer/backend/vulkan/vk.h"
20 #include "impeller/renderer/pipeline_library.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
33 void DidAcquireSurfaceFrame();
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 Mutex compute_pipelines_mutex_;
48 ComputePipelineMap compute_pipelines_ IPLR_GUARDED_BY(
49 compute_pipelines_mutex_);
50 std::atomic_size_t frames_acquired_ = 0u;
51 bool is_valid_ = false;
52
53 PipelineLibraryVK(
54 const std::shared_ptr<DeviceHolderVK>& device_holder,
55 std::shared_ptr<const Capabilities> caps,
56 fml::UniqueFD cache_directory,
57 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);
58
59 // |PipelineLibrary|
60 bool IsValid() const override;
61
62 // |PipelineLibrary|
63 PipelineFuture<PipelineDescriptor> GetPipeline(
64 PipelineDescriptor descriptor) override;
65
66 // |PipelineLibrary|
67 PipelineFuture<ComputePipelineDescriptor> GetPipeline(
68 ComputePipelineDescriptor descriptor) override;
69
70 // |PipelineLibrary|
71 void RemovePipelinesWithEntryPoint(
72 std::shared_ptr<const ShaderFunction> function) override;
73
74 std::unique_ptr<ComputePipelineVK> CreateComputePipeline(
75 const ComputePipelineDescriptor& desc);
76
77 void PersistPipelineCacheToDisk();
78
79 PipelineLibraryVK(const PipelineLibraryVK&) = delete;
80
81 PipelineLibraryVK& operator=(const PipelineLibraryVK&) = delete;
82 };
83
84 } // namespace impeller
85
86 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_LIBRARY_VK_H_
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::ComputePipelineDescriptor
Definition: compute_pipeline_descriptor.h:30
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:26
impeller::PipelineLibraryVK::~PipelineLibraryVK
~PipelineLibraryVK() override
pipeline_vk.h
impeller::PipelineLibraryVK::DidAcquireSurfaceFrame
void DidAcquireSurfaceFrame()
Definition: pipeline_library_vk.cc:257
impeller::PipelineLibraryVK::GetPSOCache
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
Definition: pipeline_library_vk.cc:274
vk.h
impeller::PipelineFuture
Definition: pipeline.h:24
impeller::PipelineLibrary
Definition: pipeline_library.h:30
impeller::PipelineLibraryVK::GetWorkerTaskRunner
const std::shared_ptr< fml::ConcurrentTaskRunner > & GetWorkerTaskRunner() const
Definition: pipeline_library_vk.cc:279
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:22
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:28
impeller::BackendCast
Definition: backend_cast.h:11
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
thread.h
impeller
Definition: aiks_blur_unittests.cc:20