Flutter Engine
The Flutter Engine
yuv_conversion_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_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_VK_H_
7
8#include <unordered_map>
9
10#include "flutter/fml/build_config.h"
17
18namespace impeller {
19
20//------------------------------------------------------------------------------
21/// A descriptor used to create a new YUV conversion in a conversion library.
22///
24 vk::StructureChain<vk::SamplerYcbcrConversionCreateInfo
25#if FML_OS_ANDROID
26 // For VK_ANDROID_external_memory_android_hardware_buffer
27 ,
28 vk::ExternalFormatANDROID
29#endif // FML_OS_ANDROID
30 >;
31
33
34//------------------------------------------------------------------------------
35/// @brief It is sometimes necessary to deal with formats not native to
36/// Vulkan. In such cases, extra information is necessary to access
37/// images. A YUV conversion object is needed in such instances.
38///
39/// There are usually only a handful of viable conversions in a
40/// given context. However, due to the way the Vulkan spec. treats
41/// "identically defined" conversions, only a single conversion
42/// object is valid for an equivalent `YUVConversionDescriptorVK`.
43/// Because of this restriction, it is not possible to just create a
44/// conversion from a descriptor (as the underlying handles will be
45/// equivalent but different). Instead, a conversion may only be
46/// obtained from a conversion library. Libraries handle hashing and
47/// caching conversions by descriptor. Caller can find a library on
48/// the top-level context. They may not create their own (the
49/// constructor is private).
50///
51class YUVConversionVK final {
52 public:
54
56
58
59 //----------------------------------------------------------------------------
60 /// @return `true` if this conversion is valid for use with images and
61 /// samplers.
62 ///
63 bool IsValid() const;
64
65 //----------------------------------------------------------------------------
66 /// @brief Get the descriptor used to create this conversion.
67 ///
69
70 //----------------------------------------------------------------------------
71 /// @return The Vulkan handle of the YUV conversion.
72 ///
73 vk::SamplerYcbcrConversion GetConversion() const;
74
75 private:
77
79 vk::UniqueSamplerYcbcrConversion conversion_;
80
81 YUVConversionVK(const vk::Device& device,
82 const YUVConversionDescriptorVK& chain);
83};
84
86 std::size_t operator()(const YUVConversionDescriptorVK& object) const;
87};
88
91 const YUVConversionDescriptorVK& rhs) const;
92};
93
94struct ImmutableSamplerKeyVK : public Comparable<ImmutableSamplerKeyVK> {
97
99
100 // |Comparable<ImmutableSamplerKey>|
101 std::size_t GetHash() const override;
102
103 // |Comparable<ImmutableSamplerKey>|
104 bool IsEqual(const ImmutableSamplerKeyVK& other) const override;
105};
106
107} // namespace impeller
108
109#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_VK_H_
Due the way the Vulkan spec. treats "identically defined" conversions, creating two conversion with i...
It is sometimes necessary to deal with formats not native to Vulkan. In such cases,...
YUVConversionVK & operator=(const YUVConversionVK &)=delete
vk::SamplerYcbcrConversion GetConversion() const
const YUVConversionDescriptorVK & GetDescriptor() const
Get the descriptor used to create this conversion.
YUVConversionVK(const YUVConversionVK &)=delete
VkDevice device
Definition: main.cc:53
vk::StructureChain< vk::SamplerYcbcrConversionCreateInfo > YUVConversionDescriptorVK
ImmutableSamplerKeyVK(const SamplerVK &sampler)
bool IsEqual(const ImmutableSamplerKeyVK &other) const override
YUVConversionDescriptorVK yuv_conversion
std::size_t GetHash() const override
bool operator()(const YUVConversionDescriptorVK &lhs, const YUVConversionDescriptorVK &rhs) const
std::size_t operator()(const YUVConversionDescriptorVK &object) const