blob: fd4d8d2cc29bfd1f3fce6fe9027c84310e33eebc [file] [log] [blame]
bsalomon18a2f9d2016-05-11 10:09:18 -07001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "tools/gpu/TestContext.h"
bsalomon18a2f9d2016-05-11 10:09:18 -070012
13#ifdef SK_VULKAN
14
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "include/gpu/vk/GrVkBackendContext.h"
16#include "tools/gpu/vk/GrVulkanDefines.h"
bsalomon18a2f9d2016-05-11 10:09:18 -070017
Greg Daniel98bffae2018-08-01 13:25:41 -040018class GrVkExtensions;
19
bsalomon18a2f9d2016-05-11 10:09:18 -070020namespace sk_gpu_test {
21class VkTestContext : public TestContext {
22public:
Greg Danielbdf12ad2018-10-12 09:31:11 -040023 virtual GrBackendApi backend() override { return GrBackendApi::kVulkan; }
bsalomon18a2f9d2016-05-11 10:09:18 -070024
Greg Daniel98bffae2018-08-01 13:25:41 -040025 const GrVkBackendContext& getVkBackendContext() const {
Greg Daniel604b1972017-05-15 13:50:35 -040026 return fVk;
27 }
28
Greg Daniel98bffae2018-08-01 13:25:41 -040029 const GrVkExtensions* getVkExtensions() const {
30 return fExtensions;
31 }
bsalomon18a2f9d2016-05-11 10:09:18 -070032
Greg Daniela0651ac2018-08-08 09:23:18 -040033 const VkPhysicalDeviceFeatures2* getVkFeatures() const {
34 return fFeatures;
35 }
36
Greg Daniel98bffae2018-08-01 13:25:41 -040037protected:
Greg Daniela0651ac2018-08-08 09:23:18 -040038 VkTestContext(const GrVkBackendContext& vk, const GrVkExtensions* extensions,
39 const VkPhysicalDeviceFeatures2* features, bool ownsContext,
Greg Daniela31f4e52018-08-01 16:48:52 -040040 VkDebugReportCallbackEXT debugCallback,
41 PFN_vkDestroyDebugReportCallbackEXT destroyCallback)
Greg Daniel98bffae2018-08-01 13:25:41 -040042 : fVk(vk)
43 , fExtensions(extensions)
Greg Daniela0651ac2018-08-08 09:23:18 -040044 , fFeatures(features)
Greg Daniel98bffae2018-08-01 13:25:41 -040045 , fOwnsContext(ownsContext)
Greg Daniela31f4e52018-08-01 16:48:52 -040046 , fDebugCallback(debugCallback)
47 , fDestroyDebugReportCallbackEXT(destroyCallback) {}
Greg Daniel98bffae2018-08-01 13:25:41 -040048
Greg Daniela31f4e52018-08-01 16:48:52 -040049 GrVkBackendContext fVk;
50 const GrVkExtensions* fExtensions;
Greg Daniela0651ac2018-08-08 09:23:18 -040051 const VkPhysicalDeviceFeatures2* fFeatures;
Greg Daniela31f4e52018-08-01 16:48:52 -040052 bool fOwnsContext;
53 VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
54 PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
bsalomon18a2f9d2016-05-11 10:09:18 -070055
56private:
57 typedef TestContext INHERITED;
58};
59
60/**
61 * Creates Vk context object bound to the native Vk library.
62 */
Greg Daniel604b1972017-05-15 13:50:35 -040063VkTestContext* CreatePlatformVkTestContext(VkTestContext*);
bsalomon18a2f9d2016-05-11 10:09:18 -070064
65} // namespace sk_gpu_test
66
67#endif
68
69#endif