| 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_compile_queue.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 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
54 PipelineLibraryVK(
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|
64 PipelineFuture<PipelineDescriptor> GetPipeline(
65 PipelineDescriptor descriptor,
66 bool async,
67 bool threadsafe = false) override;
68
69 // |PipelineLibrary|
70 PipelineFuture<ComputePipelineDescriptor> GetPipeline(
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_
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::PipelineCompileQueue
A task queue designed for managing compilation of pipeline state objects.
Definition: pipeline_compile_queue.h:43
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineLibrary
Definition: pipeline_library.h:33
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:28
impeller::PipelineLibraryVK::~PipelineLibraryVK
~PipelineLibraryVK() override
impeller::PipelineLibraryVK::DidAcquireSurfaceFrame
void DidAcquireSurfaceFrame()
Definition: pipeline_library_vk.cc:277
impeller::PipelineLibraryVK::GetWorkerTaskRunner
const std::shared_ptr< fml::ConcurrentTaskRunner > & GetWorkerTaskRunner() const
Definition: pipeline_library_vk.cc:303
impeller::PipelineLibraryVK::GetPSOCache
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
Definition: pipeline_library_vk.cc:298
compute_pipeline_vk.h
pipelines_
std::vector< std::pair< uint64_t, std::unique_ptr< GenericRenderPipelineHandle > > > pipelines_
Definition: content_context.cc:80
impeller
Definition: allocation.cc:12
impeller::ComputePipelineMap
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
Definition: pipeline_library.h:31
impeller::PipelineKey
int64_t PipelineKey
Definition: pipeline.h:22
impeller::PipelineMap
std::unordered_map< PipelineDescriptor, PipelineFuture< PipelineDescriptor >, ComparableHash< PipelineDescriptor >, ComparableEqual< PipelineDescriptor > > PipelineMap
Definition: pipeline_library.h:25
pipeline.h
pipeline_cache_vk.h
pipeline_compile_queue.h
pipeline_library.h
pipeline_vk.h
impeller::PipelineFuture
Definition: pipeline.h:29
thread.h
vk.h