| Flutter Impeller |

pipeline_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_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_VK_H_
7
8 #include <future>
9 #include <memory>
10
11 #include "impeller/base/backend_cast.h"
12 #include "impeller/base/thread.h"
13 #include "impeller/renderer/backend/vulkan/device_holder_vk.h"
14 #include "impeller/renderer/backend/vulkan/sampler_vk.h"
15 #include "impeller/renderer/backend/vulkan/vk.h"
16 #include "impeller/renderer/backend/vulkan/yuv_conversion_vk.h"
17 #include "impeller/renderer/pipeline.h"
18
19 namespace impeller {
20
21 // Limit on the total number of buffer and image bindings that allow the Vulkan
22 // backend to avoid dynamic heap allocations.
23 static constexpr size_t kMaxBindings = 32;
24
25 class PipelineVK final
26 : public Pipeline<PipelineDescriptor>,
27 public BackendCast<PipelineVK, Pipeline<PipelineDescriptor>> {
28 public:
29 static std::unique_ptr<PipelineVK> Create(
30 const PipelineDescriptor& desc,
31 const std::shared_ptr<DeviceHolderVK>& device_holder,
32 const std::weak_ptr<PipelineLibrary>& weak_library,
33 PipelineKey pipeline_key,
34 std::shared_ptr<SamplerVK> immutable_sampler = {});
35
36 // |Pipeline|
37 ~PipelineVK() override;
38
39 vk::Pipeline GetPipeline() const;
40
41 const vk::PipelineLayout& GetPipelineLayout() const;
42
43 const vk::DescriptorSetLayout& GetDescriptorSetLayout() const;
44
45 std::shared_ptr<PipelineVK> CreateVariantForImmutableSamplers(
46 const std::shared_ptr<SamplerVK>& immutable_sampler) const;
47
48 PipelineKey GetPipelineKey() const { return pipeline_key_; }
49
50 private:
51 friend class PipelineLibraryVK;
52
53 using ImmutableSamplerVariants =
54 std::unordered_map<ImmutableSamplerKeyVK,
55 std::shared_ptr<PipelineVK>,
56 ComparableHash<ImmutableSamplerKeyVK>,
57 ComparableEqual<ImmutableSamplerKeyVK>>;
58
59 std::weak_ptr<DeviceHolderVK> device_holder_;
60 vk::UniquePipeline pipeline_;
61 vk::UniqueRenderPass render_pass_;
62 vk::UniquePipelineLayout layout_;
63 vk::UniqueDescriptorSetLayout descriptor_set_layout_;
64 std::shared_ptr<SamplerVK> immutable_sampler_;
65 const PipelineKey pipeline_key_;
66 mutable Mutex immutable_sampler_variants_mutex_;
67 mutable ImmutableSamplerVariants immutable_sampler_variants_ IPLR_GUARDED_BY(
68 immutable_sampler_variants_mutex_);
69 bool is_valid_ = false;
70
71 PipelineVK(std::weak_ptr<DeviceHolderVK> device_holder,
72 std::weak_ptr<PipelineLibrary> library,
73 const PipelineDescriptor& desc,
74 vk::UniquePipeline pipeline,
75 vk::UniqueRenderPass render_pass,
76 vk::UniquePipelineLayout layout,
77 vk::UniqueDescriptorSetLayout descriptor_set_layout,
78 PipelineKey pipeline_key,
79 std::shared_ptr<SamplerVK> immutable_sampler);
80
81 // |Pipeline|
82 bool IsValid() const override;
83
84 PipelineVK(const PipelineVK&) = delete;
85
86 PipelineVK& operator=(const PipelineVK&) = delete;
87 };
88
89 } // namespace impeller
90
91 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_PIPELINE_VK_H_
backend_cast.h
impeller::BackendCast
Definition: backend_cast.h:11
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::Pipeline
Describes the fixed function and programmable aspects of rendering and compute operations performed b...
Definition: pipeline.h:52
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:27
impeller::PipelineVK
Definition: pipeline_vk.h:27
impeller::PipelineVK::CreateVariantForImmutableSamplers
std::shared_ptr< PipelineVK > CreateVariantForImmutableSamplers(const std::shared_ptr< SamplerVK > &immutable_sampler) const
Definition: pipeline_vk.cc:570
impeller::PipelineVK::~PipelineVK
~PipelineVK() override
Definition: pipeline_vk.cc:545
impeller::PipelineVK::GetPipelineKey
PipelineKey GetPipelineKey() const
Definition: pipeline_vk.h:48
impeller::PipelineVK::GetPipelineLayout
const vk::PipelineLayout & GetPipelineLayout() const
Definition: pipeline_vk.cc:562
impeller::PipelineVK::GetDescriptorSetLayout
const vk::DescriptorSetLayout & GetDescriptorSetLayout() const
Definition: pipeline_vk.cc:566
impeller::PipelineVK::GetPipeline
vk::Pipeline GetPipeline() const
Definition: pipeline_vk.cc:558
impeller::PipelineVK::Create
static std::unique_ptr< PipelineVK > Create(const PipelineDescriptor &desc, const std::shared_ptr< DeviceHolderVK > &device_holder, const std::weak_ptr< PipelineLibrary > &weak_library, PipelineKey pipeline_key, std::shared_ptr< SamplerVK > immutable_sampler={})
Definition: pipeline_vk.cc:464
device_holder_vk.h
impeller
Definition: allocation.cc:12
impeller::PipelineKey
int64_t PipelineKey
Definition: pipeline.h:21
impeller::kMaxBindings
static constexpr size_t kMaxBindings
Definition: pipeline_vk.h:23
pipeline.h
sampler_vk.h
impeller::ComparableEqual
Definition: comparable.h:48
impeller::ComparableHash
Definition: comparable.h:39
impeller::ImmutableSamplerKeyVK
Definition: yuv_conversion_vk.h:94
thread.h
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
vk.h
yuv_conversion_vk.h