• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 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 VkTestContext_DEFINED
9 #define VkTestContext_DEFINED
10 
11 #include "tools/gpu/TestContext.h"
12 
13 #ifdef SK_VULKAN
14 
15 #include "include/gpu/vk/GrVkBackendContext.h"
16 #include "tools/gpu/vk/GrVulkanDefines.h"
17 
18 class GrVkExtensions;
19 
20 namespace sk_gpu_test {
21 class VkTestContext : public TestContext {
22 public:
backend()23     GrBackendApi backend() override { return GrBackendApi::kVulkan; }
24 
getVkBackendContext()25     const GrVkBackendContext& getVkBackendContext() const {
26         return fVk;
27     }
28 
getVkExtensions()29     const GrVkExtensions* getVkExtensions() const {
30         return fExtensions;
31     }
32 
getVkFeatures()33     const VkPhysicalDeviceFeatures2* getVkFeatures() const {
34         return fFeatures;
35     }
36 
37 protected:
VkTestContext(const GrVkBackendContext & vk,const GrVkExtensions * extensions,const VkPhysicalDeviceFeatures2 * features,bool ownsContext,VkDebugReportCallbackEXT debugCallback,PFN_vkDestroyDebugReportCallbackEXT destroyCallback)38     VkTestContext(const GrVkBackendContext& vk, const GrVkExtensions* extensions,
39                   const VkPhysicalDeviceFeatures2* features, bool ownsContext,
40                   VkDebugReportCallbackEXT debugCallback,
41                   PFN_vkDestroyDebugReportCallbackEXT destroyCallback)
42             : fVk(vk)
43             , fExtensions(extensions)
44             , fFeatures(features)
45             , fOwnsContext(ownsContext)
46             , fDebugCallback(debugCallback)
47             , fDestroyDebugReportCallbackEXT(destroyCallback) {}
48 
49     GrVkBackendContext                  fVk;
50     const GrVkExtensions*               fExtensions;
51     const VkPhysicalDeviceFeatures2*    fFeatures;
52     bool                                fOwnsContext;
53     VkDebugReportCallbackEXT            fDebugCallback = VK_NULL_HANDLE;
54     PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
55 
56 private:
57     using INHERITED = TestContext;
58 };
59 
60 /**
61  * Creates Vk context object bound to the native Vk library.
62  */
63 VkTestContext* CreatePlatformVkTestContext(VkTestContext*);
64 
65 }  // namespace sk_gpu_test
66 
67 #endif
68 
69 #endif
70