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/VulkanBackendContext.h" 16 #include "tools/gpu/vk/GrVulkanDefines.h" 17 18 namespace skgpu { class VulkanExtensions; } 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 skgpu::VulkanBackendContext& getVkBackendContext() const { return fVk; } 26 getVkExtensions()27 const skgpu::VulkanExtensions* getVkExtensions() const { 28 return fExtensions; 29 } 30 getVkFeatures()31 const VkPhysicalDeviceFeatures2* getVkFeatures() const { 32 return fFeatures; 33 } 34 35 protected: VkTestContext(const skgpu::VulkanBackendContext & vk,const skgpu::VulkanExtensions * extensions,const VkPhysicalDeviceFeatures2 * features,bool ownsContext,VkDebugReportCallbackEXT debugCallback,PFN_vkDestroyDebugReportCallbackEXT destroyCallback)36 VkTestContext(const skgpu::VulkanBackendContext& vk, 37 const skgpu::VulkanExtensions* extensions, 38 const VkPhysicalDeviceFeatures2* features, 39 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 skgpu::VulkanBackendContext fVk; 50 const skgpu::VulkanExtensions* 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