2020-06-11 12:51:50 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VkTestHelper_DEFINED
|
|
|
|
#define VkTestHelper_DEFINED
|
|
|
|
|
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
|
|
|
|
#ifdef SK_VULKAN
|
|
|
|
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/gpu/vk/GrVkBackendContext.h"
|
|
|
|
#include "include/gpu/vk/GrVkExtensions.h"
|
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
class GrDirectContext;
|
2020-06-11 12:51:50 +00:00
|
|
|
class SkSurface;
|
|
|
|
|
|
|
|
#define DECLARE_VK_PROC(name) PFN_vk##name fVk##name
|
|
|
|
|
|
|
|
class VkTestHelper {
|
|
|
|
public:
|
|
|
|
VkTestHelper(bool isProtected) : fIsProtected(isProtected) {}
|
|
|
|
|
|
|
|
~VkTestHelper() {
|
|
|
|
this->cleanup();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
|
2020-07-06 19:50:15 +00:00
|
|
|
GrDirectContext* directContext() { return fDirectContext.get(); }
|
2020-06-11 12:51:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
DECLARE_VK_PROC(DestroyInstance);
|
|
|
|
DECLARE_VK_PROC(DeviceWaitIdle);
|
|
|
|
DECLARE_VK_PROC(DestroyDevice);
|
|
|
|
|
2020-06-11 14:54:43 +00:00
|
|
|
DECLARE_VK_PROC(GetPhysicalDeviceFormatProperties);
|
|
|
|
DECLARE_VK_PROC(GetPhysicalDeviceMemoryProperties);
|
|
|
|
|
|
|
|
DECLARE_VK_PROC(CreateImage);
|
|
|
|
DECLARE_VK_PROC(DestroyImage);
|
|
|
|
DECLARE_VK_PROC(GetImageMemoryRequirements);
|
|
|
|
DECLARE_VK_PROC(AllocateMemory);
|
|
|
|
DECLARE_VK_PROC(FreeMemory);
|
|
|
|
DECLARE_VK_PROC(BindImageMemory);
|
|
|
|
DECLARE_VK_PROC(MapMemory);
|
|
|
|
DECLARE_VK_PROC(UnmapMemory);
|
|
|
|
DECLARE_VK_PROC(FlushMappedMemoryRanges);
|
|
|
|
DECLARE_VK_PROC(GetImageSubresourceLayout);
|
|
|
|
|
2020-06-11 12:51:50 +00:00
|
|
|
bool fIsProtected = false;
|
|
|
|
VkDevice fDevice = VK_NULL_HANDLE;
|
|
|
|
|
2020-06-11 14:54:43 +00:00
|
|
|
GrVkExtensions fExtensions;
|
|
|
|
VkPhysicalDeviceFeatures2 fFeatures = {};
|
2020-06-11 12:51:50 +00:00
|
|
|
VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
|
|
|
|
PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugCallback = nullptr;
|
|
|
|
GrVkBackendContext fBackendContext;
|
2020-07-06 19:50:15 +00:00
|
|
|
sk_sp<GrDirectContext> fDirectContext;
|
2020-06-11 12:51:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#undef DECLARE_VK_PROC
|
|
|
|
|
|
|
|
#endif // SK_VULKAN
|
|
|
|
#endif // VkTestHelper_DEFINED
|