blob: 62a8d8e812a5849c009054b674fb6e9d5e8b5857 [file] [log] [blame]
Corentin Wallezf2adf6d2017-11-17 17:52:04 -05001// Copyright 2017 The NXT Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "backend/vulkan/VulkanFunctions.h"
16
Corentin Wallez6d9a3b82017-11-20 10:51:23 -050017#include "backend/vulkan/VulkanInfo.h"
Corentin Wallezf2adf6d2017-11-17 17:52:04 -050018#include "common/DynamicLib.h"
19
20namespace backend {
21namespace vulkan {
22
23 #define GET_GLOBAL_PROC(name) \
24 name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(nullptr, "vk" #name)); \
25 if (name == nullptr) { \
26 return false; \
27 }
28
29 bool VulkanFunctions::LoadGlobalProcs(const DynamicLib& vulkanLib) {
30 if (!vulkanLib.GetProc(&GetInstanceProcAddr, "vkGetInstanceProcAddr")) {
31 return false;
32 }
33
34 GET_GLOBAL_PROC(CreateInstance);
35 GET_GLOBAL_PROC(DestroyInstance);
36 GET_GLOBAL_PROC(EnumerateInstanceExtensionProperties);
37 GET_GLOBAL_PROC(EnumerateInstanceLayerProperties);
38
39 return true;
40 }
41
Corentin Wallez6d9a3b82017-11-20 10:51:23 -050042 #define GET_INSTANCE_PROC(name) \
43 name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(instance, "vk" #name)); \
44 if (name == nullptr) { \
45 return false; \
46 }
47
48 bool VulkanFunctions::LoadInstanceProcs(VkInstance instance, const KnownGlobalVulkanExtensions& usedGlobals) {
49 GET_INSTANCE_PROC(CreateDevice);
50 GET_INSTANCE_PROC(DestroyDevice);
51 GET_INSTANCE_PROC(EnumerateDeviceExtensionProperties);
52 GET_INSTANCE_PROC(EnumerateDeviceLayerProperties);
53 GET_INSTANCE_PROC(EnumeratePhysicalDevices);
54 GET_INSTANCE_PROC(GetPhysicalDeviceFeatures);
55 GET_INSTANCE_PROC(GetPhysicalDeviceFormatProperties);
56 GET_INSTANCE_PROC(GetPhysicalDeviceImageFormatProperties);
57 GET_INSTANCE_PROC(GetPhysicalDeviceMemoryProperties);
58 GET_INSTANCE_PROC(GetPhysicalDeviceProperties);
59 GET_INSTANCE_PROC(GetPhysicalDeviceQueueFamilyProperties);
60 GET_INSTANCE_PROC(GetPhysicalDeviceSparseImageFormatProperties);
61
62 if (usedGlobals.debugReport) {
63 GET_INSTANCE_PROC(CreateDebugReportCallbackEXT);
64 GET_INSTANCE_PROC(DebugReportMessageEXT);
65 GET_INSTANCE_PROC(DestroyDebugReportCallbackEXT);
66 }
67
68 return true;
69 }
70
Corentin Wallezf2adf6d2017-11-17 17:52:04 -050071}
72}