forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vulkan_proc_table.h
86 lines (66 loc) · 2.32 KB
/
vulkan_proc_table.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_VULKAN_VULKAN_PROC_TABLE_H_
#define FLUTTER_VULKAN_VULKAN_PROC_TABLE_H_
#include "lib/ftl/macros.h"
#include "vulkan_interface.h"
namespace vulkan {
class VulkanProcTable {
public:
template <class T>
class Proc {
public:
using Proto = T;
Proc(T proc = nullptr) : proc_(proc) {}
~Proc() { proc_ = nullptr; }
Proc operator=(T proc) {
proc_ = proc;
return *this;
}
operator bool() const { return proc_ != nullptr; }
operator T() const { return proc_; }
private:
T proc_;
};
VulkanProcTable();
~VulkanProcTable();
bool IsValid() const;
Proc<PFN_vkCreateInstance> createInstance;
Proc<PFN_vkDestroyInstance> destroyInstance;
Proc<PFN_vkEnumeratePhysicalDevices> enumeratePhysicalDevices;
Proc<PFN_vkCreateDevice> createDevice;
Proc<PFN_vkDestroyDevice> destroyDevice;
Proc<PFN_vkGetDeviceQueue> getDeviceQueue;
Proc<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>
getPhysicalDeviceSurfaceCapabilitiesKHR;
Proc<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>
getPhysicalDeviceSurfaceFormatsKHR;
Proc<PFN_vkCreateSwapchainKHR> createSwapchainKHR;
Proc<PFN_vkGetSwapchainImagesKHR> getSwapchainImagesKHR;
Proc<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>
getPhysicalDeviceSurfacePresentModesKHR;
Proc<PFN_vkDestroySurfaceKHR> destroySurfaceKHR;
Proc<PFN_vkDestroySwapchainKHR> destroySwapchainKHR;
Proc<PFN_vkCreateCommandPool> createCommandPool;
Proc<PFN_vkDestroyCommandPool> destroyCommandPool;
Proc<PFN_vkCreateSemaphore> createSemaphore;
Proc<PFN_vkDestroySemaphore> destroySemaphore;
Proc<PFN_vkAllocateCommandBuffers> allocateCommandBuffers;
Proc<PFN_vkFreeCommandBuffers> freeCommandBuffers;
Proc<PFN_vkCreateFence> createFence;
Proc<PFN_vkDestroyFence> destroyFence;
Proc<PFN_vkWaitForFences> waitForFences;
#if OS_ANDROID
Proc<PFN_vkCreateAndroidSurfaceKHR> createAndroidSurfaceKHR;
#endif // OS_ANDROID
private:
bool valid_;
void* handle_;
bool OpenLibraryHandle();
bool CloseLibraryHandle();
bool AcquireProcs();
FTL_DISALLOW_COPY_AND_ASSIGN(VulkanProcTable);
};
} // namespace vulkan
#endif // FLUTTER_VULKAN_VULKAN_PROC_TABLE_H_