Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jesse Hall | 0a40209 | 2016-02-01 14:43:47 -0800 | [diff] [blame] | 17 | // WARNING: This file is generated. See ../README.md for instructions. |
| 18 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 19 | #include <log/log.h> |
| 20 | #include <algorithm> |
| 21 | #include "loader.h" |
| 22 | |
| 23 | #define UNLIKELY(expr) __builtin_expect((expr), 0) |
| 24 | |
| 25 | using namespace vulkan; |
| 26 | |
| 27 | namespace { |
| 28 | |
| 29 | struct NameProc { |
| 30 | const char* name; |
| 31 | PFN_vkVoidFunction proc; |
| 32 | }; |
| 33 | |
| 34 | PFN_vkVoidFunction Lookup(const char* name, |
| 35 | const NameProc* begin, |
| 36 | const NameProc* end) { |
| 37 | const auto& entry = std::lower_bound( |
| 38 | begin, end, name, |
| 39 | [](const NameProc& e, const char* n) { return strcmp(e.name, n) < 0; }); |
| 40 | if (entry == end || strcmp(entry->name, name) != 0) |
| 41 | return nullptr; |
| 42 | return entry->proc; |
| 43 | } |
| 44 | |
| 45 | template <size_t N> |
| 46 | PFN_vkVoidFunction Lookup(const char* name, const NameProc (&procs)[N]) { |
| 47 | return Lookup(name, procs, procs + N); |
| 48 | } |
| 49 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 50 | const NameProc kLoaderBottomProcs[] = { |
| 51 | // clang-format off |
| 52 | {"vkAcquireNextImageKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkAcquireNextImageKHR>(AcquireNextImageKHR_Bottom))}, |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame^] | 53 | {"vkAllocateCommandBuffers", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkAllocateCommandBuffers>(AllocateCommandBuffers_Bottom))}, |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 54 | {"vkCreateAndroidSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkCreateAndroidSurfaceKHR>(CreateAndroidSurfaceKHR_Bottom))}, |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 55 | {"vkCreateDebugReportCallbackEXT", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkCreateDebugReportCallbackEXT>(CreateDebugReportCallbackEXT_Bottom))}, |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 56 | {"vkCreateDevice", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkCreateDevice>(CreateDevice_Bottom))}, |
| 57 | {"vkCreateInstance", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkCreateInstance>(CreateInstance_Bottom))}, |
| 58 | {"vkCreateSwapchainKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkCreateSwapchainKHR>(CreateSwapchainKHR_Bottom))}, |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 59 | {"vkDebugReportMessageEXT", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkDebugReportMessageEXT>(DebugReportMessageEXT_Bottom))}, |
| 60 | {"vkDestroyDebugReportCallbackEXT", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkDestroyDebugReportCallbackEXT>(DestroyDebugReportCallbackEXT_Bottom))}, |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame^] | 61 | {"vkDestroyDevice", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkDestroyDevice>(DestroyDevice_Bottom))}, |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 62 | {"vkDestroyInstance", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkDestroyInstance>(DestroyInstance_Bottom))}, |
| 63 | {"vkDestroySurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkDestroySurfaceKHR>(DestroySurfaceKHR_Bottom))}, |
| 64 | {"vkDestroySwapchainKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkDestroySwapchainKHR>(DestroySwapchainKHR_Bottom))}, |
| 65 | {"vkEnumerateDeviceExtensionProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkEnumerateDeviceExtensionProperties>(EnumerateDeviceExtensionProperties_Bottom))}, |
| 66 | {"vkEnumerateDeviceLayerProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkEnumerateDeviceLayerProperties>(EnumerateDeviceLayerProperties_Bottom))}, |
| 67 | {"vkEnumeratePhysicalDevices", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkEnumeratePhysicalDevices>(EnumeratePhysicalDevices_Bottom))}, |
| 68 | {"vkGetDeviceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetDeviceProcAddr>(GetDeviceProcAddr_Bottom))}, |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame^] | 69 | {"vkGetDeviceQueue", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetDeviceQueue>(GetDeviceQueue_Bottom))}, |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 70 | {"vkGetInstanceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetInstanceProcAddr>(GetInstanceProcAddr_Bottom))}, |
| 71 | {"vkGetPhysicalDeviceFeatures", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceFeatures>(GetPhysicalDeviceFeatures_Bottom))}, |
| 72 | {"vkGetPhysicalDeviceFormatProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceFormatProperties>(GetPhysicalDeviceFormatProperties_Bottom))}, |
| 73 | {"vkGetPhysicalDeviceImageFormatProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceImageFormatProperties>(GetPhysicalDeviceImageFormatProperties_Bottom))}, |
| 74 | {"vkGetPhysicalDeviceMemoryProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(GetPhysicalDeviceMemoryProperties_Bottom))}, |
| 75 | {"vkGetPhysicalDeviceProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceProperties>(GetPhysicalDeviceProperties_Bottom))}, |
| 76 | {"vkGetPhysicalDeviceQueueFamilyProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceQueueFamilyProperties>(GetPhysicalDeviceQueueFamilyProperties_Bottom))}, |
| 77 | {"vkGetPhysicalDeviceSparseImageFormatProperties", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceSparseImageFormatProperties>(GetPhysicalDeviceSparseImageFormatProperties_Bottom))}, |
| 78 | {"vkGetPhysicalDeviceSurfaceCapabilitiesKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>(GetPhysicalDeviceSurfaceCapabilitiesKHR_Bottom))}, |
| 79 | {"vkGetPhysicalDeviceSurfaceFormatsKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>(GetPhysicalDeviceSurfaceFormatsKHR_Bottom))}, |
| 80 | {"vkGetPhysicalDeviceSurfacePresentModesKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>(GetPhysicalDeviceSurfacePresentModesKHR_Bottom))}, |
| 81 | {"vkGetPhysicalDeviceSurfaceSupportKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>(GetPhysicalDeviceSurfaceSupportKHR_Bottom))}, |
| 82 | {"vkGetSwapchainImagesKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetSwapchainImagesKHR>(GetSwapchainImagesKHR_Bottom))}, |
| 83 | {"vkQueuePresentKHR", reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkQueuePresentKHR>(QueuePresentKHR_Bottom))}, |
| 84 | // clang-format on |
| 85 | }; |
| 86 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 87 | } // anonymous namespace |
| 88 | |
| 89 | namespace vulkan { |
| 90 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 91 | PFN_vkVoidFunction GetLoaderBottomProcAddr(const char* name) { |
| 92 | return Lookup(name, kLoaderBottomProcs); |
| 93 | } |
| 94 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 95 | bool LoadDriverDispatchTable(VkInstance instance, |
| 96 | PFN_vkGetInstanceProcAddr get_proc_addr, |
Jesse Hall | 6bd5dfa | 2016-01-16 17:13:30 -0800 | [diff] [blame] | 97 | const InstanceExtensionSet& extensions, |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 98 | DriverDispatchTable& dispatch) { |
| 99 | bool success = true; |
| 100 | // clang-format off |
| 101 | dispatch.DestroyInstance = reinterpret_cast<PFN_vkDestroyInstance>(get_proc_addr(instance, "vkDestroyInstance")); |
| 102 | if (UNLIKELY(!dispatch.DestroyInstance)) { |
| 103 | ALOGE("missing driver proc: %s", "vkDestroyInstance"); |
| 104 | success = false; |
| 105 | } |
| 106 | dispatch.EnumeratePhysicalDevices = reinterpret_cast<PFN_vkEnumeratePhysicalDevices>(get_proc_addr(instance, "vkEnumeratePhysicalDevices")); |
| 107 | if (UNLIKELY(!dispatch.EnumeratePhysicalDevices)) { |
| 108 | ALOGE("missing driver proc: %s", "vkEnumeratePhysicalDevices"); |
| 109 | success = false; |
| 110 | } |
| 111 | dispatch.GetPhysicalDeviceProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>(get_proc_addr(instance, "vkGetPhysicalDeviceProperties")); |
| 112 | if (UNLIKELY(!dispatch.GetPhysicalDeviceProperties)) { |
| 113 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceProperties"); |
| 114 | success = false; |
| 115 | } |
| 116 | dispatch.GetPhysicalDeviceQueueFamilyProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceQueueFamilyProperties>(get_proc_addr(instance, "vkGetPhysicalDeviceQueueFamilyProperties")); |
| 117 | if (UNLIKELY(!dispatch.GetPhysicalDeviceQueueFamilyProperties)) { |
| 118 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceQueueFamilyProperties"); |
| 119 | success = false; |
| 120 | } |
| 121 | dispatch.GetPhysicalDeviceMemoryProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(get_proc_addr(instance, "vkGetPhysicalDeviceMemoryProperties")); |
| 122 | if (UNLIKELY(!dispatch.GetPhysicalDeviceMemoryProperties)) { |
| 123 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceMemoryProperties"); |
| 124 | success = false; |
| 125 | } |
| 126 | dispatch.GetPhysicalDeviceFeatures = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures>(get_proc_addr(instance, "vkGetPhysicalDeviceFeatures")); |
| 127 | if (UNLIKELY(!dispatch.GetPhysicalDeviceFeatures)) { |
| 128 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceFeatures"); |
| 129 | success = false; |
| 130 | } |
| 131 | dispatch.GetPhysicalDeviceFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties>(get_proc_addr(instance, "vkGetPhysicalDeviceFormatProperties")); |
| 132 | if (UNLIKELY(!dispatch.GetPhysicalDeviceFormatProperties)) { |
| 133 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceFormatProperties"); |
| 134 | success = false; |
| 135 | } |
| 136 | dispatch.GetPhysicalDeviceImageFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceImageFormatProperties>(get_proc_addr(instance, "vkGetPhysicalDeviceImageFormatProperties")); |
| 137 | if (UNLIKELY(!dispatch.GetPhysicalDeviceImageFormatProperties)) { |
| 138 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceImageFormatProperties"); |
| 139 | success = false; |
| 140 | } |
| 141 | dispatch.CreateDevice = reinterpret_cast<PFN_vkCreateDevice>(get_proc_addr(instance, "vkCreateDevice")); |
| 142 | if (UNLIKELY(!dispatch.CreateDevice)) { |
| 143 | ALOGE("missing driver proc: %s", "vkCreateDevice"); |
| 144 | success = false; |
| 145 | } |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 146 | dispatch.EnumerateDeviceExtensionProperties = reinterpret_cast<PFN_vkEnumerateDeviceExtensionProperties>(get_proc_addr(instance, "vkEnumerateDeviceExtensionProperties")); |
| 147 | if (UNLIKELY(!dispatch.EnumerateDeviceExtensionProperties)) { |
| 148 | ALOGE("missing driver proc: %s", "vkEnumerateDeviceExtensionProperties"); |
| 149 | success = false; |
| 150 | } |
| 151 | dispatch.GetPhysicalDeviceSparseImageFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceSparseImageFormatProperties>(get_proc_addr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties")); |
| 152 | if (UNLIKELY(!dispatch.GetPhysicalDeviceSparseImageFormatProperties)) { |
| 153 | ALOGE("missing driver proc: %s", "vkGetPhysicalDeviceSparseImageFormatProperties"); |
| 154 | success = false; |
| 155 | } |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 156 | if (extensions[kEXT_debug_report]) { |
| 157 | dispatch.CreateDebugReportCallbackEXT = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(get_proc_addr(instance, "vkCreateDebugReportCallbackEXT")); |
| 158 | if (UNLIKELY(!dispatch.CreateDebugReportCallbackEXT)) { |
| 159 | ALOGE("missing driver proc: %s", "vkCreateDebugReportCallbackEXT"); |
| 160 | success = false; |
| 161 | } |
| 162 | } |
| 163 | if (extensions[kEXT_debug_report]) { |
| 164 | dispatch.DestroyDebugReportCallbackEXT = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(get_proc_addr(instance, "vkDestroyDebugReportCallbackEXT")); |
| 165 | if (UNLIKELY(!dispatch.DestroyDebugReportCallbackEXT)) { |
| 166 | ALOGE("missing driver proc: %s", "vkDestroyDebugReportCallbackEXT"); |
| 167 | success = false; |
| 168 | } |
| 169 | } |
| 170 | if (extensions[kEXT_debug_report]) { |
| 171 | dispatch.DebugReportMessageEXT = reinterpret_cast<PFN_vkDebugReportMessageEXT>(get_proc_addr(instance, "vkDebugReportMessageEXT")); |
| 172 | if (UNLIKELY(!dispatch.DebugReportMessageEXT)) { |
| 173 | ALOGE("missing driver proc: %s", "vkDebugReportMessageEXT"); |
| 174 | success = false; |
| 175 | } |
| 176 | } |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 177 | dispatch.GetDeviceProcAddr = reinterpret_cast<PFN_vkGetDeviceProcAddr>(get_proc_addr(instance, "vkGetDeviceProcAddr")); |
| 178 | if (UNLIKELY(!dispatch.GetDeviceProcAddr)) { |
| 179 | ALOGE("missing driver proc: %s", "vkGetDeviceProcAddr"); |
| 180 | success = false; |
| 181 | } |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame^] | 182 | dispatch.DestroyDevice = reinterpret_cast<PFN_vkDestroyDevice>(get_proc_addr(instance, "vkDestroyDevice")); |
| 183 | if (UNLIKELY(!dispatch.DestroyDevice)) { |
| 184 | ALOGE("missing driver proc: %s", "vkDestroyDevice"); |
| 185 | success = false; |
| 186 | } |
| 187 | dispatch.GetDeviceQueue = reinterpret_cast<PFN_vkGetDeviceQueue>(get_proc_addr(instance, "vkGetDeviceQueue")); |
| 188 | if (UNLIKELY(!dispatch.GetDeviceQueue)) { |
| 189 | ALOGE("missing driver proc: %s", "vkGetDeviceQueue"); |
| 190 | success = false; |
| 191 | } |
| 192 | dispatch.AllocateCommandBuffers = reinterpret_cast<PFN_vkAllocateCommandBuffers>(get_proc_addr(instance, "vkAllocateCommandBuffers")); |
| 193 | if (UNLIKELY(!dispatch.AllocateCommandBuffers)) { |
| 194 | ALOGE("missing driver proc: %s", "vkAllocateCommandBuffers"); |
| 195 | success = false; |
| 196 | } |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 197 | dispatch.CreateImage = reinterpret_cast<PFN_vkCreateImage>(get_proc_addr(instance, "vkCreateImage")); |
| 198 | if (UNLIKELY(!dispatch.CreateImage)) { |
| 199 | ALOGE("missing driver proc: %s", "vkCreateImage"); |
| 200 | success = false; |
| 201 | } |
| 202 | dispatch.DestroyImage = reinterpret_cast<PFN_vkDestroyImage>(get_proc_addr(instance, "vkDestroyImage")); |
| 203 | if (UNLIKELY(!dispatch.DestroyImage)) { |
| 204 | ALOGE("missing driver proc: %s", "vkDestroyImage"); |
| 205 | success = false; |
| 206 | } |
Jesse Hall | d913282 | 2016-01-14 15:50:52 -0800 | [diff] [blame] | 207 | dispatch.GetSwapchainGrallocUsageANDROID = reinterpret_cast<PFN_vkGetSwapchainGrallocUsageANDROID>(get_proc_addr(instance, "vkGetSwapchainGrallocUsageANDROID")); |
| 208 | if (UNLIKELY(!dispatch.GetSwapchainGrallocUsageANDROID)) { |
| 209 | ALOGE("missing driver proc: %s", "vkGetSwapchainGrallocUsageANDROID"); |
| 210 | success = false; |
| 211 | } |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 212 | dispatch.AcquireImageANDROID = reinterpret_cast<PFN_vkAcquireImageANDROID>(get_proc_addr(instance, "vkAcquireImageANDROID")); |
| 213 | if (UNLIKELY(!dispatch.AcquireImageANDROID)) { |
| 214 | ALOGE("missing driver proc: %s", "vkAcquireImageANDROID"); |
| 215 | success = false; |
| 216 | } |
| 217 | dispatch.QueueSignalReleaseImageANDROID = reinterpret_cast<PFN_vkQueueSignalReleaseImageANDROID>(get_proc_addr(instance, "vkQueueSignalReleaseImageANDROID")); |
| 218 | if (UNLIKELY(!dispatch.QueueSignalReleaseImageANDROID)) { |
| 219 | ALOGE("missing driver proc: %s", "vkQueueSignalReleaseImageANDROID"); |
| 220 | success = false; |
| 221 | } |
| 222 | // clang-format on |
| 223 | return success; |
| 224 | } |
| 225 | |
| 226 | } // namespace vulkan |