Debian Codegraph @

include/gpu/vk/VulkanBackendContext.h

raw
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_VulkanBackendContext_DEFINED
9 #define skgpu_VulkanBackendContext_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "include/gpu/GpuTypes.h"
13 #include "include/gpu/vk/VulkanMemoryAllocator.h"
14 #include "include/gpu/vk/VulkanTypes.h"
15 #include "include/private/base/SkAPI.h"
16 #include "include/private/gpu/vk/SkiaVulkan.h"
17
18 #include <cstdint>
19
20 namespace skgpu {
21
22 class VulkanExtensions;
23
24 // The VkBackendContext contains all of the base Vk objects needed by the skia Vulkan context.
25 struct SK_API VulkanBackendContext {
26 VkInstance fInstance = VK_NULL_HANDLE;
27 VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE;
28 VkDevice fDevice = VK_NULL_HANDLE;
29 VkQueue fQueue = VK_NULL_HANDLE;
30 uint32_t fGraphicsQueueIndex = 0;
31 // The max api version set here should match the value set in VkApplicationInfo::apiVersion when
32 // then VkInstance was created. Skia requires Vulkan 1.1 as the minimum version.
33 uint32_t fMaxAPIVersion = 0;
34 const skgpu::VulkanExtensions* fVkExtensions = nullptr;
35 // The client can create their VkDevice with either a VkPhysicalDeviceFeatures or
36 // VkPhysicalDeviceFeatures2 struct, thus we have to support taking both. The
37 // VkPhysicalDeviceFeatures2 struct is needed so we know if the client enabled any extension
38 // specific features. If fDeviceFeatures2 is not null then we ignore fDeviceFeatures. If both
39 // fDeviceFeatures and fDeviceFeatures2 are null we will assume no features are enabled.
40 const VkPhysicalDeviceFeatures* fDeviceFeatures = nullptr;
41 const VkPhysicalDeviceFeatures2* fDeviceFeatures2 = nullptr;
42 // Optional. The client may provide an inplementation of a VulkanMemoryAllocator for Skia to use
43 // for allocating Vulkan resources that use VkDeviceMemory.
44 sk_sp<VulkanMemoryAllocator> fMemoryAllocator;
45 skgpu::VulkanGetProc fGetProc;
46 Protected fProtectedContext = Protected::kNo;
47 // Optional callback which will be invoked if a VK_ERROR_DEVICE_LOST error code is received from
48 // the driver. Debug information from the driver will be provided to the callback if the
49 // VK_EXT_device_fault extension is supported and enabled (VkPhysicalDeviceFaultFeaturesEXT must
50 // be in the pNext chain of VkDeviceCreateInfo).
51 skgpu::VulkanDeviceLostContext fDeviceLostContext = nullptr;
52 skgpu::VulkanDeviceLostProc fDeviceLostProc = nullptr;
53 };
54
55 } // namespace skgpu
56
57 #endif // skgpu_VulkanBackendContext_DEFINED