Flutter Engine
The Flutter Engine
VulkanTypes.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_VulkanTypes_DEFINED
9#define skgpu_VulkanTypes_DEFINED
10
13
14#include <cstddef>
15#include <cstdint>
16#include <functional>
17#include <string>
18#include <vector>
19
20#ifndef VK_VERSION_1_1
21#error Skia requires the use of Vulkan 1.1 headers
22#endif
23
24namespace skgpu {
25
27 const char*, // function name
28 VkInstance, // instance or VK_NULL_HANDLE
29 VkDevice // device or VK_NULL_HANDLE
30 )>;
31
32typedef intptr_t VulkanBackendMemory;
33
34/**
35 * Types for interacting with Vulkan resources created externally to Skia.
36 */
38 // can be VK_NULL_HANDLE iff is an RT and is borrowed
39 VkDeviceMemory fMemory = VK_NULL_HANDLE;
41 VkDeviceSize fSize = 0; // this can be indeterminate iff Tex uses borrow semantics
42 uint32_t fFlags = 0;
43 // handle to memory allocated via skgpu::VulkanMemoryAllocator.
45
46 enum Flag {
47 kNoncoherent_Flag = 0x1, // memory must be flushed to device after mapping
48 kMappable_Flag = 0x2, // memory is able to be mapped.
49 kLazilyAllocated_Flag = 0x4, // memory was created with lazy allocation
50 };
51
52 bool operator==(const VulkanAlloc& that) const {
53 return fMemory == that.fMemory && fOffset == that.fOffset && fSize == that.fSize &&
54 fFlags == that.fFlags && fUsesSystemHeap == that.fUsesSystemHeap;
55 }
56
57private:
58 bool fUsesSystemHeap = false;
59};
60
61// Used to pass in the necessary information to create a VkSamplerYcbcrConversion object for an
62// VkExternalFormatANDROID.
64 bool operator==(const VulkanYcbcrConversionInfo& that) const {
65 // Invalid objects are not required to have all other fields initialized or matching.
66 if (!this->isValid() && !that.isValid()) {
67 return true;
68 }
69
70 // Note that we do not need to check for fFormatFeatures equality. This is because the
71 // Vulkan spec dictates that Android hardware buffers with the same external format must
72 // have the same support for key features. See
73 // https://docs.vulkan.org/spec/latest/chapters/memory.html#_android_hardware_buffer_external_memory
74 // for more details.
75 return this->fFormat == that.fFormat &&
76 this->fExternalFormat == that.fExternalFormat &&
77 this->fYcbcrModel == that.fYcbcrModel &&
78 this->fYcbcrRange == that.fYcbcrRange &&
79 this->fXChromaOffset == that.fXChromaOffset &&
80 this->fYChromaOffset == that.fYChromaOffset &&
81 this->fChromaFilter == that.fChromaFilter &&
83 this->fComponents.r == that.fComponents.r &&
84 this->fComponents.g == that.fComponents.g &&
85 this->fComponents.b == that.fComponents.b &&
86 this->fComponents.a == that.fComponents.a;
87 }
88 bool operator!=(const VulkanYcbcrConversionInfo& that) const { return !(*this == that); }
89
90 bool isValid() const {
92 fExternalFormat != 0;
93 }
94
95 // Format of the source image. Must be set to VK_FORMAT_UNDEFINED for external images or
96 // a valid image format otherwise.
98
99 // The external format. Must be non-zero for external images, zero otherwise.
100 // Should be compatible to be used in a VkExternalFormatANDROID struct.
101 uint64_t fExternalFormat = 0;
102
109
110 // For external images format features here should be those returned by a call to
111 // vkAndroidHardwareBufferFormatPropertiesANDROID
113
114 // This is ignored when fExternalFormat is non-zero.
119};
120
123 const std::string& description,
124 const std::vector<VkDeviceFaultAddressInfoEXT>& addressInfos,
125 const std::vector<VkDeviceFaultVendorInfoEXT>& vendorInfos,
126 const std::vector<std::byte>& vendorBinaryData);
127
128} // namespace skgpu
129
130#endif // skgpu_VulkanTypes_DEFINED
Dart_NativeFunction function
Definition: fuchsia.cc:51
Definition: GpuTools.h:21
intptr_t VulkanBackendMemory
Definition: VulkanTypes.h:32
void * VulkanDeviceLostContext
Definition: VulkanTypes.h:121
std::function< PFN_vkVoidFunction(const char *, VkInstance, VkDevice)> VulkanGetProc
Definition: VulkanTypes.h:30
void(* VulkanDeviceLostProc)(VulkanDeviceLostContext faultContext, const std::string &description, const std::vector< VkDeviceFaultAddressInfoEXT > &addressInfos, const std::vector< VkDeviceFaultVendorInfoEXT > &vendorInfos, const std::vector< std::byte > &vendorBinaryData)
Definition: VulkanTypes.h:122
VkComponentSwizzle r
Definition: vulkan_core.h:3460
VkComponentSwizzle a
Definition: vulkan_core.h:3463
VkComponentSwizzle g
Definition: vulkan_core.h:3461
VkComponentSwizzle b
Definition: vulkan_core.h:3462
bool operator==(const VulkanAlloc &that) const
Definition: VulkanTypes.h:52
VkDeviceSize fSize
Definition: VulkanTypes.h:41
VulkanBackendMemory fBackendMemory
Definition: VulkanTypes.h:44
VkDeviceMemory fMemory
Definition: VulkanTypes.h:39
VkDeviceSize fOffset
Definition: VulkanTypes.h:40
VkSamplerYcbcrRange fYcbcrRange
Definition: VulkanTypes.h:104
VkSamplerYcbcrModelConversion fYcbcrModel
Definition: VulkanTypes.h:103
VkComponentMapping fComponents
Definition: VulkanTypes.h:115
bool operator==(const VulkanYcbcrConversionInfo &that) const
Definition: VulkanTypes.h:64
bool operator!=(const VulkanYcbcrConversionInfo &that) const
Definition: VulkanTypes.h:88
VkFormatFeatureFlags fFormatFeatures
Definition: VulkanTypes.h:112
uint64_t VkDeviceSize
Definition: vulkan_core.h:96
VkSamplerYcbcrModelConversion
Definition: vulkan_core.h:4945
@ VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY
Definition: vulkan_core.h:4946
VkChromaLocation
Definition: vulkan_core.h:4967
@ VK_CHROMA_LOCATION_COSITED_EVEN
Definition: vulkan_core.h:4968
@ VK_COMPONENT_SWIZZLE_IDENTITY
Definition: vulkan_core.h:1819
VkFlags VkFormatFeatureFlags
Definition: vulkan_core.h:2307
VkSamplerYcbcrRange
Definition: vulkan_core.h:4959
@ VK_SAMPLER_YCBCR_RANGE_ITU_FULL
Definition: vulkan_core.h:4960
VkFilter
Definition: vulkan_core.h:2100
@ VK_FILTER_NEAREST
Definition: vulkan_core.h:2101
void(VKAPI_PTR * PFN_vkVoidFunction)(void)
Definition: vulkan_core.h:2992
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
VkFormat
Definition: vulkan_core.h:1458
@ VK_FORMAT_UNDEFINED
Definition: vulkan_core.h:1459
uint32_t VkBool32
Definition: vulkan_core.h:94