| Flutter Impeller |

yuv_conversion_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_YUV_CONVERSION_LIBRARY_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_LIBRARY_VK_H_
7
8 #include "impeller/renderer/backend/vulkan/yuv_conversion_vk.h"
9
10 namespace impeller {
11
12 class DeviceHolderVK;
13
14 //------------------------------------------------------------------------------
15 /// @brief Due the way the Vulkan spec. treats "identically defined"
16 /// conversions, creating two conversion with identical descriptors,
17 /// using one with the image and the other with the sampler, is
18 /// invalid use.
19 ///
20 /// A conversion library hashes and caches identical descriptors to
21 /// de-duplicate conversions.
22 ///
23 /// There can only be one conversion library (the constructor is
24 /// private to force this) and it found in the context.
25 ///
26 class YUVConversionLibraryVK {
27 public:
28 ~YUVConversionLibraryVK();
29
30 YUVConversionLibraryVK(const YUVConversionLibraryVK&) = delete;
31
32 YUVConversionLibraryVK& operator=(const YUVConversionLibraryVK&) = delete;
33
34 //----------------------------------------------------------------------------
35 /// @brief Get a conversion for the given descriptor. If there is already
36 /// a conversion created for an equivalent descriptor, a reference
37 /// to that descriptor is returned instead.
38 ///
39 /// @param[in] desc The descriptor.
40 ///
41 /// @return The conversion. A previously created conversion if one was
42 /// present and a new one if not. A newly created conversion is
43 /// cached for subsequent accesses.
44 ///
45 std::shared_ptr<YUVConversionVK> GetConversion(
46 const YUVConversionDescriptorVK& chain);
47
48 private:
49 friend class ContextVK;
50
51 using ConversionsMap = std::unordered_map<YUVConversionDescriptorVK,
52 std::shared_ptr<YUVConversionVK>,
53 YUVConversionDescriptorVKHash,
54 YUVConversionDescriptorVKEqual>;
55
56 std::weak_ptr<DeviceHolderVK> device_holder_;
57 Mutex conversions_mutex_;
58 ConversionsMap conversions_ IPLR_GUARDED_BY(conversions_mutex_);
59
60 explicit YUVConversionLibraryVK(std::weak_ptr<DeviceHolderVK> device_holder);
61 };
62
63 } // namespace impeller
64
65 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_LIBRARY_VK_H_
impeller::ContextVK
Definition: context_vk.h:66
impeller::YUVConversionLibraryVK
Due the way the Vulkan spec. treats "identically defined" conversions, creating two conversion with i...
Definition: yuv_conversion_library_vk.h:26
impeller::YUVConversionLibraryVK::operator=
YUVConversionLibraryVK & operator=(const YUVConversionLibraryVK &)=delete
impeller::YUVConversionLibraryVK::GetConversion
std::shared_ptr< YUVConversionVK > GetConversion(const YUVConversionDescriptorVK &chain)
Get a conversion for the given descriptor. If there is already a conversion created for an equivalent...
Definition: yuv_conversion_library_vk.cc:18
impeller::YUVConversionLibraryVK::YUVConversionLibraryVK
YUVConversionLibraryVK(const YUVConversionLibraryVK &)=delete
impeller::YUVConversionLibraryVK::~YUVConversionLibraryVK
~YUVConversionLibraryVK()
impeller
Definition: allocation.cc:12
impeller::YUVConversionDescriptorVK
vk::StructureChain< vk::SamplerYcbcrConversionCreateInfo > YUVConversionDescriptorVK
Definition: yuv_conversion_vk.h:30
impeller::YUVConversionDescriptorVKEqual
Definition: yuv_conversion_vk.h:89
impeller::YUVConversionDescriptorVKHash
Definition: yuv_conversion_vk.h:85
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
yuv_conversion_vk.h