| 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/core/texture.h"
14 #include "impeller/renderer/backend/vulkan/device_holder_vk.h"
15 #include "impeller/renderer/backend/vulkan/formats_vk.h"
16 #include "impeller/renderer/backend/vulkan/pipeline_cache_vk.h"
17 #include "impeller/renderer/backend/vulkan/sampler_vk.h"
18 #include "impeller/renderer/backend/vulkan/vk.h"
19 #include "impeller/renderer/backend/vulkan/yuv_conversion_vk.h"
20 #include "impeller/renderer/pipeline.h"
21
22 namespace impeller {
23
24 // Limit on the total number of buffer and image bindings that allow the Vulkan
25 // backend to avoid dynamic heap allocations.
26 static constexpr size_t kMaxBindings = 32;
27
28 class PipelineVK final
29 : public Pipeline<PipelineDescriptor>,
30 public BackendCast<PipelineVK, Pipeline<PipelineDescriptor>> {
31 public:
32 static std::unique_ptr<PipelineVK> Create(
33 const PipelineDescriptor& desc,
34 const std::shared_ptr<DeviceHolderVK>& device_holder,
35 const std::weak_ptr<PipelineLibrary>& weak_library,
36 std::shared_ptr<SamplerVK> immutable_sampler = {});
37
38 // |Pipeline|
39 ~PipelineVK() override;
40
41 vk::Pipeline GetPipeline() const;
42
43 const vk::PipelineLayout& GetPipelineLayout() const;
44
45 const vk::DescriptorSetLayout& GetDescriptorSetLayout() const;
46
47 std::shared_ptr<PipelineVK> CreateVariantForImmutableSamplers(
48 const std::shared_ptr<SamplerVK>& immutable_sampler) const;
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 mutable Mutex immutable_sampler_variants_mutex_;
66 mutable ImmutableSamplerVariants immutable_sampler_variants_ IPLR_GUARDED_BY(
67 immutable_sampler_variants_mutex_);
68 bool is_valid_ = false;
69
70 PipelineVK(std::weak_ptr<DeviceHolderVK> device_holder,
71 std::weak_ptr<PipelineLibrary> library,
72 const PipelineDescriptor& desc,
73 vk::UniquePipeline pipeline,
74 vk::UniqueRenderPass render_pass,
75 vk::UniquePipelineLayout layout,
76 vk::UniqueDescriptorSetLayout descriptor_set_layout,
77 std::shared_ptr<SamplerVK> immutable_sampler);
78
79 // |Pipeline|
80 bool IsValid() const override;
81
82 PipelineVK(const PipelineVK&) = delete;
83
84 PipelineVK& operator=(const PipelineVK&) = delete;
85 };
86
87 } // namespace impeller
88
89 #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:50
impeller::PipelineLibraryVK
Definition: pipeline_library_vk.h:26
impeller::PipelineVK
Definition: pipeline_vk.h:30
impeller::PipelineVK::CreateVariantForImmutableSamplers
std::shared_ptr< PipelineVK > CreateVariantForImmutableSamplers(const std::shared_ptr< SamplerVK > &immutable_sampler) const
Definition: pipeline_vk.cc:565
impeller::PipelineVK::~PipelineVK
~PipelineVK() override
Definition: pipeline_vk.cc:540
impeller::PipelineVK::GetPipelineLayout
const vk::PipelineLayout & GetPipelineLayout() const
Definition: pipeline_vk.cc:557
impeller::PipelineVK::GetDescriptorSetLayout
const vk::DescriptorSetLayout & GetDescriptorSetLayout() const
Definition: pipeline_vk.cc:561
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, std::shared_ptr< SamplerVK > immutable_sampler={})
Definition: pipeline_vk.cc:464
impeller::PipelineVK::GetPipeline
vk::Pipeline GetPipeline() const
Definition: pipeline_vk.cc:553
texture.h
device_holder_vk.h
formats_vk.h
impeller
Definition: allocation.cc:12
impeller::kMaxBindings
static constexpr size_t kMaxBindings
Definition: pipeline_vk.h:26
pipeline.h
pipeline_cache_vk.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