xref: /aosp_15_r20/external/skia/tools/gpu/vk/VkTestUtils.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2017 Google Inc.
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 VkTestUtils_DEFINED
9 #define VkTestUtils_DEFINED
10 
11 #include "include/core/SkTypes.h"
12 
13 #ifdef SK_VULKAN
14 
15 #include "include/gpu/vk/VulkanBackendContext.h"
16 #include "tools/gpu/vk/GrVulkanDefines.h"
17 #include <functional>
18 
19 namespace skgpu {
20 struct VulkanBackendContext;
21 class VulkanExtensions;
22 }
23 
24 namespace sk_gpu_test {
25     bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr*);
26 
27     using CanPresentFn = std::function<bool(VkInstance, VkPhysicalDevice,
28                                             uint32_t queueFamilyIndex)>;
29 
30     bool CreateVkBackendContext(PFN_vkGetInstanceProcAddr getInstProc,
31                                 skgpu::VulkanBackendContext* ctx,
32                                 skgpu::VulkanExtensions*,
33                                 VkPhysicalDeviceFeatures2*,
34                                 VkDebugReportCallbackEXT* debugCallback,
35                                 uint32_t* presentQueueIndexPtr = nullptr,
36                                 const CanPresentFn& canPresent = CanPresentFn(),
37                                 bool isProtected = false);
38 
39     void FreeVulkanFeaturesStructs(const VkPhysicalDeviceFeatures2*);
40 
41 }  // namespace sk_gpu_test
42 
43 #endif
44 #endif
45