bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "tools/gpu/TestContext.h" |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 12 | |
| 13 | #ifdef SK_VULKAN |
| 14 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "include/gpu/vk/GrVkBackendContext.h" |
| 16 | #include "tools/gpu/vk/GrVulkanDefines.h" |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 17 | |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 18 | class GrVkExtensions; |
| 19 | |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 20 | namespace sk_gpu_test { |
| 21 | class VkTestContext : public TestContext { |
| 22 | public: |
Greg Daniel | bdf12ad | 2018-10-12 09:31:11 -0400 | [diff] [blame] | 23 | virtual GrBackendApi backend() override { return GrBackendApi::kVulkan; } |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 24 | |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 25 | const GrVkBackendContext& getVkBackendContext() const { |
Greg Daniel | 604b197 | 2017-05-15 13:50:35 -0400 | [diff] [blame] | 26 | return fVk; |
| 27 | } |
| 28 | |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 29 | const GrVkExtensions* getVkExtensions() const { |
| 30 | return fExtensions; |
| 31 | } |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 32 | |
Greg Daniel | a0651ac | 2018-08-08 09:23:18 -0400 | [diff] [blame] | 33 | const VkPhysicalDeviceFeatures2* getVkFeatures() const { |
| 34 | return fFeatures; |
| 35 | } |
| 36 | |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 37 | protected: |
Greg Daniel | a0651ac | 2018-08-08 09:23:18 -0400 | [diff] [blame] | 38 | VkTestContext(const GrVkBackendContext& vk, const GrVkExtensions* extensions, |
| 39 | const VkPhysicalDeviceFeatures2* features, bool ownsContext, |
Greg Daniel | a31f4e5 | 2018-08-01 16:48:52 -0400 | [diff] [blame] | 40 | VkDebugReportCallbackEXT debugCallback, |
| 41 | PFN_vkDestroyDebugReportCallbackEXT destroyCallback) |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 42 | : fVk(vk) |
| 43 | , fExtensions(extensions) |
Greg Daniel | a0651ac | 2018-08-08 09:23:18 -0400 | [diff] [blame] | 44 | , fFeatures(features) |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 45 | , fOwnsContext(ownsContext) |
Greg Daniel | a31f4e5 | 2018-08-01 16:48:52 -0400 | [diff] [blame] | 46 | , fDebugCallback(debugCallback) |
| 47 | , fDestroyDebugReportCallbackEXT(destroyCallback) {} |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 48 | |
Greg Daniel | a31f4e5 | 2018-08-01 16:48:52 -0400 | [diff] [blame] | 49 | GrVkBackendContext fVk; |
| 50 | const GrVkExtensions* fExtensions; |
Greg Daniel | a0651ac | 2018-08-08 09:23:18 -0400 | [diff] [blame] | 51 | const VkPhysicalDeviceFeatures2* fFeatures; |
Greg Daniel | a31f4e5 | 2018-08-01 16:48:52 -0400 | [diff] [blame] | 52 | bool fOwnsContext; |
| 53 | VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE; |
| 54 | PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr; |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 55 | |
| 56 | private: |
| 57 | typedef TestContext INHERITED; |
| 58 | }; |
| 59 | |
| 60 | /** |
| 61 | * Creates Vk context object bound to the native Vk library. |
| 62 | */ |
Greg Daniel | 604b197 | 2017-05-15 13:50:35 -0400 | [diff] [blame] | 63 | VkTestContext* CreatePlatformVkTestContext(VkTestContext*); |
bsalomon | 18a2f9d | 2016-05-11 10:09:18 -0700 | [diff] [blame] | 64 | |
| 65 | } // namespace sk_gpu_test |
| 66 | |
| 67 | #endif |
| 68 | |
| 69 | #endif |