| 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 #pragma once
6
7 #include <atomic>
8
9 #include "flutter/fml/concurrent_message_loop.h"
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/mapping.h"
12 #include "flutter/fml/unique_fd.h"
13 #include "impeller/base/backend_cast.h"
14 #include "impeller/base/thread.h"
15 #include "impeller/renderer/backend/vulkan/compute_pipeline_vk.h"
16 #include "impeller/renderer/backend/vulkan/pipeline_cache_vk.h"
17 #include "impeller/renderer/backend/vulkan/pipeline_vk.h"
18 #include "impeller/renderer/backend/vulkan/vk.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 private:
35 friend ContextVK;
36
37 std::weak_ptr<DeviceHolder> device_holder_;
38 std::shared_ptr<PipelineCacheVK> pso_cache_;
39 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner_;
40 Mutex pipelines_mutex_;
41 PipelineMap pipelines_ IPLR_GUARDED_BY(pipelines_mutex_);
42 Mutex compute_pipelines_mutex_;
43 ComputePipelineMap compute_pipelines_
44 IPLR_GUARDED_BY(compute_pipelines_mutex_);
45 std::atomic_size_t frames_acquired_ = 0u;
46 bool is_valid_ = false;
47
48 PipelineLibraryVK(
49 const std::shared_ptr<DeviceHolder>& device_holder,
50 std::shared_ptr<const Capabilities> caps,
51 fml::UniqueFD cache_directory,
52 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner);
53
54 // |PipelineLibrary|
55 bool IsValid() const override;
56
57 // |PipelineLibrary|
58 PipelineFuture<PipelineDescriptor> GetPipeline(
59 PipelineDescriptor descriptor) override;
60
61 // |PipelineLibrary|
62 PipelineFuture<ComputePipelineDescriptor> GetPipeline(
63 ComputePipelineDescriptor descriptor) override;
64
65 // |PipelineLibrary|
66 void RemovePipelinesWithEntryPoint(
67 std::shared_ptr<const ShaderFunction> function) override;
68
69 std::unique_ptr<PipelineVK> CreatePipeline(const PipelineDescriptor& desc);
70
71 std::unique_ptr<ComputePipelineVK> CreateComputePipeline(
72 const ComputePipelineDescriptor& desc);
73
74 void PersistPipelineCacheToDisk();
75
76 FML_DISALLOW_COPY_AND_ASSIGN(PipelineLibraryVK);
77 };
78
79 } // namespace impeller
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:30
impeller::ComputePipelineDescriptor
Definition: compute_pipeline_descriptor.h:29
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:25
impeller::PipelineLibraryVK::~PipelineLibraryVK
~PipelineLibraryVK() override
pipeline_vk.h
impeller::PipelineLibraryVK::DidAcquireSurfaceFrame
void DidAcquireSurfaceFrame()
Definition: pipeline_library_vk.cc:679
vk.h
impeller::PipelineFuture
Definition: pipeline.h:24
impeller::PipelineLibrary
Definition: pipeline_library.h:29
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:36
impeller::ComputePipelineMap
std::unordered_map< ComputePipelineDescriptor, PipelineFuture< ComputePipelineDescriptor >, ComparableHash< ComputePipelineDescriptor >, ComparableEqual< ComputePipelineDescriptor > > ComputePipelineMap
Definition: pipeline_library.h:27
impeller::BackendCast
Definition: backend_cast.h:12
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:18
thread.h
impeller
Definition: aiks_context.cc:10