Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
VkTestHelper.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 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 VkTestHelper_DEFINED
9#define VkTestHelper_DEFINED
10
12
13#ifdef SK_VULKAN
14
18
19class GrDirectContext;
20class SkSurface;
21struct SkISize;
22
23namespace skiatest {
24 enum class TestType : uint8_t;
25}
26
27namespace skgpu::graphite {
28 class Recorder;
29};
30
31#define DECLARE_VK_PROC(name) PFN_vk##name fVk##name
32
33class VkTestHelper {
34public:
35 static std::unique_ptr<VkTestHelper> Make(skiatest::TestType, bool isProtected);
36
37 virtual ~VkTestHelper();
38
39 virtual bool isValid() const = 0;
40
41 virtual sk_sp<SkSurface> createSurface(SkISize, bool textureable, bool isProtected) = 0;
42 virtual void submitAndWaitForCompletion(bool* completionMarker) = 0;
43
44 virtual GrDirectContext* directContext() { return nullptr; }
45 virtual skgpu::graphite::Recorder* recorder() { return nullptr; }
46
47protected:
48 VkTestHelper(bool isProtected) : fIsProtected(isProtected) {}
49
50 bool setupBackendContext();
51 virtual bool init() = 0;
52
53 DECLARE_VK_PROC(DestroyInstance);
54 DECLARE_VK_PROC(DeviceWaitIdle);
55 DECLARE_VK_PROC(DestroyDevice);
56 DECLARE_VK_PROC(GetDeviceProcAddr);
57
58 DECLARE_VK_PROC(GetPhysicalDeviceFormatProperties);
59 DECLARE_VK_PROC(GetPhysicalDeviceMemoryProperties);
60
61 DECLARE_VK_PROC(CreateImage);
62 DECLARE_VK_PROC(DestroyImage);
63 DECLARE_VK_PROC(GetImageMemoryRequirements);
64 DECLARE_VK_PROC(AllocateMemory);
65 DECLARE_VK_PROC(FreeMemory);
66 DECLARE_VK_PROC(BindImageMemory);
67 DECLARE_VK_PROC(MapMemory);
68 DECLARE_VK_PROC(UnmapMemory);
69 DECLARE_VK_PROC(FlushMappedMemoryRanges);
70 DECLARE_VK_PROC(GetImageSubresourceLayout);
71
72 bool fIsProtected = false;
73 VkDevice fDevice = VK_NULL_HANDLE;
74
75 skgpu::VulkanExtensions fExtensions;
76 VkPhysicalDeviceFeatures2 fFeatures = {};
77 VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
78 PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugCallback = nullptr;
79 skgpu::VulkanBackendContext fBackendContext;
80};
81
82#undef DECLARE_VK_PROC
83
84#endif // SK_VULKAN
85#endif // VkTestHelper_DEFINED
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
init(device_serial, adb_binary)
Definition _adb_path.py:12
void(VKAPI_PTR * PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator)
#define VK_NULL_HANDLE
Definition vulkan_core.h:46