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/gpu/GpuTypes.h" 12 #include "include/gpu/vk/VulkanMemoryAllocator.h" 13 #include "include/gpu/vk/VulkanTypes.h" 14 15 namespace skgpu { 16 17 class VulkanExtensions; 18 19 // The VkBackendContext contains all of the base Vk objects needed by the skia Vulkan context. 20 struct SK_API VulkanBackendContext { 21 VkInstance fInstance; 22 VkPhysicalDevice fPhysicalDevice; 23 VkDevice fDevice; 24 VkQueue fQueue; 25 uint32_t fGraphicsQueueIndex; 26 // The max api version set here should match the value set in VkApplicationInfo::apiVersion when 27 // then VkInstance was created. 28 uint32_t fMaxAPIVersion; 29 const skgpu::VulkanExtensions* fVkExtensions = nullptr; 30 // The client can create their VkDevice with either a VkPhysicalDeviceFeatures or 31 // VkPhysicalDeviceFeatures2 struct, thus we have to support taking both. The 32 // VkPhysicalDeviceFeatures2 struct is needed so we know if the client enabled any extension 33 // specific features. If fDeviceFeatures2 is not null then we ignore fDeviceFeatures. If both 34 // fDeviceFeatures and fDeviceFeatures2 are null we will assume no features are enabled. 35 const VkPhysicalDeviceFeatures* fDeviceFeatures = nullptr; 36 const VkPhysicalDeviceFeatures2* fDeviceFeatures2 = nullptr; 37 // Optional. The client may provide an inplementation of a VulkanMemoryAllocator for Skia to use 38 // for allocating Vulkan resources that use VkDeviceMemory. 39 sk_sp<VulkanMemoryAllocator> fMemoryAllocator; 40 skgpu::VulkanGetProc fGetProc; 41 Protected fProtectedContext; 42 }; 43 44 } // namespace skgpu::graphite 45 46 #endif // skgpu_VulkanBackendContext_DEFINED 47