| 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 private:
36 friend ContextVK;
37
38 std::weak_ptr<DeviceHolder> device_holder_;
39 bool supports_framebuffer_fetch_ = false;
40 std::shared_ptr<PipelineCacheVK> pso_cache_;
41 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner_;
42 Mutex pipelines_mutex_;
43 PipelineMap pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
44 Mutex compute_pipelines_mutex_;
45 ComputePipelineMap compute_pipelines_
46 IPLR_GUARDED_BY(compute_pipelines_mutex_);
47 std::atomic_size_t frames_acquired_ = 0u;
48 bool is_valid_ = false;
49
50 PipelineLibraryVK(
51 const std::shared_ptr<DeviceHolder>& device_holder,
52 std::shared_ptr<const Capabilities> caps,
53 fml::UniqueFD cache_directory,
54 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);
55
56 // |PipelineLibrary|
57 bool IsValid() const override;
58
59 // |PipelineLibrary|
60 PipelineFuture<PipelineDescriptor> GetPipeline(
61 PipelineDescriptor descriptor) override;
62
63 // |PipelineLibrary|
64 PipelineFuture<ComputePipelineDescriptor> GetPipeline(
65 ComputePipelineDescriptor descriptor) override;
66
67 // |PipelineLibrary|
68 void RemovePipelinesWithEntryPoint(
69 std::shared_ptr<const ShaderFunction> function) override;
70
71 std::unique_ptr<PipelineVK> CreatePipeline(const PipelineDescriptor& desc);
72
73 std::unique_ptr<ComputePipelineVK> CreateComputePipeline(
74 const ComputePipelineDescriptor& desc);
75
76 void PersistPipelineCacheToDisk();
77
78 PipelineLibraryVK(const PipelineLibraryVK&) = delete;
79
80 PipelineLibraryVK& operator=(const PipelineLibraryVK&) = delete;
81 };
82
83 } // namespace impeller
84
85 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_LIBRARY_VK_H_
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:29
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:727
vk.h
impeller::PipelineFuture
Definition: pipeline.h:24
impeller::PipelineLibrary
Definition: pipeline_library.h:30
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:40
impeller::ComputePipelineMap
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
Definition: pipeline_library.h:28
impeller::BackendCast
Definition: backend_cast.h:13
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
thread.h
impeller
Definition: aiks_context.cc:10