Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1 | /* |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2 | * |
Courtney Goeltzenleuchter | fcbe16f | 2015-10-29 13:50:34 -0600 | [diff] [blame] | 3 | * Copyright (C) 2015 Valve Corporation |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included |
| 13 | * in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | * |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 23 | * Author: Ian Elliott <ian@lunarg.com> |
| 24 | * |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 25 | */ |
| 26 | |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 27 | #include <stdio.h> |
| 28 | #include <string.h> |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 29 | #include <vk_loader_platform.h> |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 30 | #include <vk_icd.h> |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 31 | #include "swapchain.h" |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 32 | #include "vk_layer_extension_utils.h" |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 33 | #include "vk_enum_string_helper.h" |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 34 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 35 | // FIXME/TODO: Make sure this layer is thread-safe! |
| 36 | |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 37 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 38 | // The following is for logging error messages: |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 39 | static std::unordered_map<void *, layer_data *> layer_data_map; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 40 | |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 41 | template layer_data *get_my_data_ptr<layer_data>( |
| 42 | void *data_key, |
| 43 | std::unordered_map<void *, layer_data *> &data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 44 | |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 45 | static const VkExtensionProperties instance_extensions[] = { |
| 46 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 47 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, |
| 48 | VK_EXT_DEBUG_REPORT_REVISION |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 49 | } |
| 50 | }; |
| 51 | |
| 52 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( |
| 53 | const char *pLayerName, |
| 54 | uint32_t *pCount, |
| 55 | VkExtensionProperties* pProperties) |
| 56 | { |
| 57 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 58 | } |
| 59 | |
| 60 | static const VkLayerProperties swapchain_global_layers[] = { |
| 61 | { |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 62 | "swapchain", |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 63 | VK_API_VERSION, |
| 64 | VK_MAKE_VERSION(0, 1, 0), |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 65 | "Validation layer: swapchain", |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 66 | } |
| 67 | }; |
| 68 | |
| 69 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( |
| 70 | uint32_t *pCount, |
| 71 | VkLayerProperties* pProperties) |
| 72 | { |
| 73 | return util_GetLayerProperties(ARRAY_SIZE(swapchain_global_layers), |
| 74 | swapchain_global_layers, |
| 75 | pCount, pProperties); |
| 76 | } |
| 77 | |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 78 | // This function validates a VkSurfaceKHR object: |
| 79 | static VkBool32 validateSurface(layer_data *my_data, VkSurfaceKHR surface, char *fn) |
| 80 | { |
| 81 | VkBool32 skipCall = VK_FALSE; |
| 82 | bool found_error = false; |
| 83 | |
| 84 | SwpSurface *pSurface = &my_data->surfaceMap[surface]; |
| 85 | if ((pSurface == NULL) || (pSurface->surface != surface)) { |
| 86 | found_error = true; |
| 87 | } else { |
| 88 | #if !defined(__ANDROID__) |
| 89 | VkIcdSurfaceBase *pIcdSurface = (VkIcdSurfaceBase *) surface; |
| 90 | if (pSurface->platform != pIcdSurface->platform) { |
| 91 | found_error = true; |
| 92 | } |
| 93 | #else // !defined(__ANDROID__) |
| 94 | if (pSurface->platform != VK_ICD_WSI_PLATFORM_ANDROID) { |
| 95 | found_error = true; |
| 96 | } |
| 97 | #endif // !defined(__ANDROID__) |
| 98 | } |
| 99 | if (found_error) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 100 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT, surface, "VkSurfaceKHR", |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 101 | SWAPCHAIN_INVALID_HANDLE, |
| 102 | "%s() called with an invalid surface object.", |
| 103 | fn); |
| 104 | } |
| 105 | return skipCall; |
| 106 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 107 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 108 | static void createDeviceRegisterExtensions(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 109 | { |
| 110 | uint32_t i; |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 111 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 112 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 113 | |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 114 | VkLayerDispatchTable *pDisp = my_device_data->device_dispatch_table; |
| 115 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
| 116 | |
| 117 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR"); |
| 118 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR"); |
| 119 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR"); |
| 120 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR"); |
| 121 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR"); |
| 122 | |
| 123 | SwpPhysicalDevice *pPhysicalDevice = &my_instance_data->physicalDeviceMap[physicalDevice]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 124 | if (pPhysicalDevice) { |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 125 | my_device_data->deviceMap[device].pPhysicalDevice = pPhysicalDevice; |
| 126 | pPhysicalDevice->pDevice = &my_device_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 127 | } else { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 128 | log_msg(my_instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | 80e774f | 2016-01-04 15:54:59 -0700 | [diff] [blame] | 129 | (uint64_t)physicalDevice , __LINE__, SWAPCHAIN_INVALID_HANDLE, "Swapchain", |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 130 | "vkCreateDevice() called with a non-valid VkPhysicalDevice."); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 131 | } |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 132 | my_device_data->deviceMap[device].device = device; |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 133 | my_device_data->deviceMap[device].swapchainExtensionEnabled = false; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 134 | |
| 135 | // Record whether the WSI device extension was enabled for this VkDevice. |
| 136 | // No need to check if the extension was advertised by |
| 137 | // vkEnumerateDeviceExtensionProperties(), since the loader handles that. |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 138 | for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 139 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 140 | |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 141 | my_device_data->deviceMap[device].swapchainExtensionEnabled = true; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance) |
| 147 | { |
| 148 | uint32_t i; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 149 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 150 | VkLayerInstanceDispatchTable *pDisp = my_data->instance_dispatch_table; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 151 | PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 152 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 153 | pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR"); |
| 154 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 155 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 156 | pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR"); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 157 | pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR"); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 158 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 159 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 160 | pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR"); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 161 | pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 162 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 163 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 164 | pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR"); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 165 | pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 166 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 167 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 168 | pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR"); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 169 | pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 170 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 171 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 172 | pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR"); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 173 | pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 174 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 175 | pDisp->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) gpa(instance, "vkDestroySurfaceKHR"); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 176 | pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 177 | pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); |
| 178 | pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"); |
| 179 | pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 180 | |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 181 | // Remember this instance, and whether the VK_KHR_surface extension |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 182 | // was enabled for it: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 183 | my_data->instanceMap[instance].instance = instance; |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 184 | my_data->instanceMap[instance].surfaceExtensionEnabled = false; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 185 | |
| 186 | // Record whether the WSI instance extension was enabled for this |
| 187 | // VkInstance. No need to check if the extension was advertised by |
| 188 | // vkEnumerateInstanceExtensionProperties(), since the loader handles that. |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 189 | for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 190 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 191 | |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 192 | my_data->instanceMap[instance].surfaceExtensionEnabled = true; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | |
| 198 | #include "vk_dispatch_table_helper.h" |
Courtney Goeltzenleuchter | 6d8e818 | 2015-11-25 14:31:49 -0700 | [diff] [blame] | 199 | static void initSwapchain(layer_data *my_data, const VkAllocationCallbacks *pAllocator) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 200 | { |
| 201 | uint32_t report_flags = 0; |
| 202 | uint32_t debug_action = 0; |
| 203 | FILE *log_output = NULL; |
| 204 | const char *option_str; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 205 | VkDebugReportCallbackEXT callback; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 206 | |
| 207 | // Initialize Swapchain options: |
| 208 | report_flags = getLayerOptionFlags("SwapchainReportFlags", 0); |
| 209 | getLayerOptionEnum("SwapchainDebugAction", (uint32_t *) &debug_action); |
| 210 | |
| 211 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 212 | { |
| 213 | // Turn on logging, since it was requested: |
| 214 | option_str = getLayerOption("SwapchainLogFilename"); |
| 215 | log_output = getLayerLogOutput(option_str, "Swapchain"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 216 | VkDebugReportCallbackCreateInfoEXT dbgInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 217 | memset(&dbgInfo, 0, sizeof(dbgInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 218 | dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 219 | dbgInfo.pfnCallback = log_callback; |
| 220 | dbgInfo.pUserData = log_output; |
| 221 | dbgInfo.flags = report_flags; |
| 222 | layer_create_msg_callback(my_data->report_data, |
| 223 | &dbgInfo, |
| 224 | pAllocator, |
Courtney Goeltzenleuchter | cf60e0a | 2015-10-08 17:07:25 -0600 | [diff] [blame] | 225 | &callback); |
| 226 | my_data->logging_callback.push_back(callback); |
| 227 | } |
| 228 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 229 | VkDebugReportCallbackCreateInfoEXT dbgInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 230 | memset(&dbgInfo, 0, sizeof(dbgInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 231 | dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 232 | dbgInfo.pfnCallback = win32_debug_output_msg; |
| 233 | dbgInfo.pUserData = log_output; |
| 234 | dbgInfo.flags = report_flags; |
| 235 | layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &callback); |
Courtney Goeltzenleuchter | cf60e0a | 2015-10-08 17:07:25 -0600 | [diff] [blame] | 236 | my_data->logging_callback.push_back(callback); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 240 | static const char *surfaceTransformStr(VkSurfaceTransformFlagBitsKHR value) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 241 | { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 242 | // Return a string corresponding to the value: |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 243 | return string_VkSurfaceTransformFlagBitsKHR(value); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 244 | } |
| 245 | |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 246 | static const char *surfaceCompositeAlphaStr(VkCompositeAlphaFlagBitsKHR value) |
| 247 | { |
| 248 | // Return a string corresponding to the value: |
| 249 | return string_VkCompositeAlphaFlagBitsKHR(value); |
| 250 | } |
| 251 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 252 | static const char *presentModeStr(VkPresentModeKHR value) |
| 253 | { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 254 | // Return a string corresponding to the value: |
Ian Elliott | 24491af | 2015-12-28 15:04:49 -0700 | [diff] [blame] | 255 | return string_VkPresentModeKHR(value); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 256 | } |
| 257 | |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 258 | static const char *sharingModeStr(VkSharingMode value) |
| 259 | { |
| 260 | // Return a string corresponding to the value: |
| 261 | return string_VkSharingMode(value); |
| 262 | } |
| 263 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 264 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 265 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 266 | { |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 267 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 268 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 269 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 270 | VkResult result = pTable->CreateInstance(pCreateInfo, pAllocator, pInstance); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 271 | if (result == VK_SUCCESS) { |
| 272 | // Since it succeeded, do layer-specific work: |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 273 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 274 | my_data->report_data = debug_report_create_instance( |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 275 | pTable, |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 276 | *pInstance, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 277 | pCreateInfo->enabledExtensionNameCount, |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 278 | pCreateInfo->ppEnabledExtensionNames); |
| 279 | // Call the following function after my_data is initialized: |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 280 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
Courtney Goeltzenleuchter | 6d8e818 | 2015-11-25 14:31:49 -0700 | [diff] [blame] | 281 | initSwapchain(my_data, pAllocator); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 282 | } |
| 283 | return result; |
| 284 | } |
| 285 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 286 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 287 | { |
| 288 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 289 | dispatch_key key = get_dispatch_key(instance); |
| 290 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 291 | // Validate that a valid VkInstance was used: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 292 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 293 | if (!pInstance) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 294 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 295 | instance, |
| 296 | "VkInstance"); |
| 297 | } |
| 298 | |
| 299 | if (VK_FALSE == skipCall) { |
| 300 | // Call down the call chain: |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 301 | my_data->instance_dispatch_table->DestroyInstance(instance, pAllocator); |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 302 | |
| 303 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | cf60e0a | 2015-10-08 17:07:25 -0600 | [diff] [blame] | 304 | while (my_data->logging_callback.size() > 0) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 305 | VkDebugReportCallbackEXT callback = my_data->logging_callback.back(); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 306 | layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); |
Courtney Goeltzenleuchter | cf60e0a | 2015-10-08 17:07:25 -0600 | [diff] [blame] | 307 | my_data->logging_callback.pop_back(); |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 308 | } |
| 309 | layer_debug_report_destroy_instance(my_data->report_data); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | // Regardless of skipCall value, do some internal cleanup: |
| 313 | if (pInstance) { |
| 314 | // Delete all of the SwpPhysicalDevice's and the SwpInstance associated |
| 315 | // with this instance: |
| 316 | for (auto it = pInstance->physicalDevices.begin() ; |
| 317 | it != pInstance->physicalDevices.end() ; it++) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 318 | |
| 319 | // Free memory that was allocated for/by this SwpPhysicalDevice: |
| 320 | SwpPhysicalDevice *pPhysicalDevice = it->second; |
| 321 | free(pPhysicalDevice->pSurfaceFormats); |
| 322 | free(pPhysicalDevice->pPresentModes); |
| 323 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 324 | // Erase the SwpPhysicalDevice's from the my_data->physicalDeviceMap (which |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 325 | // are simply pointed to by the SwpInstance): |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 326 | my_data->physicalDeviceMap.erase(it->second->physicalDevice); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 327 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 328 | my_data->instanceMap.erase(instance); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 329 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 330 | delete my_data->instance_dispatch_table; |
| 331 | layer_data_map.erase(key); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 332 | } |
| 333 | |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 334 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 335 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( |
| 336 | VkInstance instance, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 337 | const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 338 | const VkAllocationCallbacks* pAllocator, |
| 339 | VkSurfaceKHR* pSurface) |
| 340 | { |
| 341 | VkResult result = VK_SUCCESS; |
| 342 | VkBool32 skipCall = VK_FALSE; |
| 343 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 344 | |
| 345 | // Validate that a valid VkInstance was used: |
| 346 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 347 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 348 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 349 | instance, |
| 350 | "VkInstance"); |
| 351 | } |
| 352 | |
| 353 | if (VK_FALSE == skipCall) { |
| 354 | // Call down the call chain: |
| 355 | result = my_data->instance_dispatch_table->CreateAndroidSurfaceKHR( |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 356 | instance, pCreateInfo, pAllocator, pSurface); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 357 | |
| 358 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 359 | // Record the VkSurfaceKHR returned by the ICD: |
| 360 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 361 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 362 | my_data->surfaceMap[*pSurface].platform = VK_ICD_WSI_PLATFORM_ANDROID; |
| 363 | // Point to the associated SwpInstance: |
| 364 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 365 | skipCall |= validateSurface(my_data, *pSurface, (char *) __FUNCTION__); |
| 366 | } |
| 367 | return result; |
| 368 | } |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 369 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 370 | } |
| 371 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 372 | |
| 373 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 374 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( |
| 375 | VkInstance instance, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 376 | const VkMirSurfaceCreateInfoKHR* pCreateInfo, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 377 | const VkAllocationCallbacks* pAllocator, |
| 378 | VkSurfaceKHR* pSurface) |
| 379 | { |
| 380 | VkResult result = VK_SUCCESS; |
| 381 | VkBool32 skipCall = VK_FALSE; |
| 382 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 383 | |
| 384 | // Validate that a valid VkInstance was used: |
| 385 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 386 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 387 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 388 | instance, |
| 389 | "VkInstance"); |
| 390 | } |
| 391 | |
| 392 | if (VK_FALSE == skipCall) { |
| 393 | // Call down the call chain: |
| 394 | result = my_data->instance_dispatch_table->CreateMirSurfaceKHR( |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 395 | instance, pCreateInfo, pAllocator, pSurface); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 396 | |
| 397 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 398 | // Record the VkSurfaceKHR returned by the ICD: |
| 399 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 400 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 401 | my_data->surfaceMap[*pSurface].platform = VK_ICD_WSI_PLATFORM_MIR; |
| 402 | // Point to the associated SwpInstance: |
| 403 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 404 | skipCall |= validateSurface(my_data, *pSurface, (char *) __FUNCTION__); |
| 405 | } |
| 406 | return result; |
| 407 | } |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 408 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 409 | } |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 410 | |
| 411 | VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR( |
| 412 | VkPhysicalDevice physicalDevice, |
| 413 | uint32_t queueFamilyIndex, |
| 414 | MirConnection* connection) |
| 415 | { |
| 416 | VkBool32 result = VK_FALSE; |
| 417 | VkBool32 skipCall = VK_FALSE; |
| 418 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 419 | |
| 420 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
| 421 | // extension was enabled: |
| 422 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 423 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
| 424 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
| 425 | physicalDevice, |
| 426 | "VkPhysicalDevice"); |
| 427 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
| 428 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 429 | pPhysicalDevice->pInstance, |
| 430 | "VkInstance", |
| 431 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 432 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 433 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
| 434 | } |
| 435 | |
| 436 | if (VK_FALSE == skipCall) { |
| 437 | // Call down the call chain: |
| 438 | result = my_data->instance_dispatch_table->GetPhysicalDeviceMirPresentationSupportKHR( |
| 439 | physicalDevice, queueFamilyIndex, connection); |
| 440 | |
| 441 | if (pPhysicalDevice) { |
| 442 | // Record the result of this query: |
| 443 | pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; |
| 444 | } |
| 445 | } |
| 446 | return result; |
| 447 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 448 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 449 | |
| 450 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 451 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( |
| 452 | VkInstance instance, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 453 | const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 454 | const VkAllocationCallbacks* pAllocator, |
| 455 | VkSurfaceKHR* pSurface) |
| 456 | { |
| 457 | VkResult result = VK_SUCCESS; |
| 458 | VkBool32 skipCall = VK_FALSE; |
| 459 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 460 | |
| 461 | // Validate that a valid VkInstance was used: |
| 462 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 463 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 464 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 465 | instance, |
| 466 | "VkInstance"); |
| 467 | } |
| 468 | |
| 469 | if (VK_FALSE == skipCall) { |
| 470 | // Call down the call chain: |
| 471 | result = my_data->instance_dispatch_table->CreateWaylandSurfaceKHR( |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 472 | instance, pCreateInfo, pAllocator, pSurface); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 473 | |
| 474 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 475 | // Record the VkSurfaceKHR returned by the ICD: |
| 476 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 477 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 478 | my_data->surfaceMap[*pSurface].platform = VK_ICD_WSI_PLATFORM_WAYLAND; |
| 479 | // Point to the associated SwpInstance: |
| 480 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 481 | skipCall |= validateSurface(my_data, *pSurface, (char *) __FUNCTION__); |
| 482 | } |
| 483 | return result; |
| 484 | } |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 485 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 486 | } |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 487 | |
| 488 | VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( |
| 489 | VkPhysicalDevice physicalDevice, |
| 490 | uint32_t queueFamilyIndex, |
| 491 | struct wl_display* display) |
| 492 | { |
| 493 | VkBool32 result = VK_FALSE; |
| 494 | VkBool32 skipCall = VK_FALSE; |
| 495 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 496 | |
| 497 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
| 498 | // extension was enabled: |
| 499 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 500 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
| 501 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
| 502 | physicalDevice, |
| 503 | "VkPhysicalDevice"); |
| 504 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
| 505 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 506 | pPhysicalDevice->pInstance, |
| 507 | "VkInstance", |
| 508 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 509 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 510 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
| 511 | } |
| 512 | |
| 513 | if (VK_FALSE == skipCall) { |
| 514 | // Call down the call chain: |
| 515 | result = my_data->instance_dispatch_table->GetPhysicalDeviceWaylandPresentationSupportKHR( |
| 516 | physicalDevice, queueFamilyIndex, display); |
| 517 | |
| 518 | if (pPhysicalDevice) { |
| 519 | // Record the result of this query: |
| 520 | pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; |
| 521 | } |
| 522 | } |
| 523 | return result; |
| 524 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 525 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 526 | |
| 527 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 528 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( |
| 529 | VkInstance instance, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 530 | const VkWin32SurfaceCreateInfoKHR* pCreateInfo, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 531 | const VkAllocationCallbacks* pAllocator, |
| 532 | VkSurfaceKHR* pSurface) |
| 533 | { |
| 534 | VkResult result = VK_SUCCESS; |
| 535 | VkBool32 skipCall = VK_FALSE; |
| 536 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 537 | |
| 538 | // Validate that a valid VkInstance was used: |
| 539 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 540 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 541 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 542 | instance, |
| 543 | "VkInstance"); |
| 544 | } |
| 545 | |
| 546 | if (VK_FALSE == skipCall) { |
| 547 | // Call down the call chain: |
| 548 | result = my_data->instance_dispatch_table->CreateWin32SurfaceKHR( |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 549 | instance, pCreateInfo, pAllocator, pSurface); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 550 | |
| 551 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 552 | // Record the VkSurfaceKHR returned by the ICD: |
| 553 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 554 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 555 | my_data->surfaceMap[*pSurface].platform = VK_ICD_WSI_PLATFORM_WIN32; |
| 556 | // Point to the associated SwpInstance: |
| 557 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 558 | skipCall |= validateSurface(my_data, *pSurface, (char *) __FUNCTION__); |
| 559 | } |
| 560 | return result; |
| 561 | } |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 562 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 563 | } |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 564 | |
| 565 | VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( |
| 566 | VkPhysicalDevice physicalDevice, |
| 567 | uint32_t queueFamilyIndex) |
| 568 | { |
| 569 | VkBool32 result = VK_FALSE; |
| 570 | VkBool32 skipCall = VK_FALSE; |
| 571 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 572 | |
| 573 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
| 574 | // extension was enabled: |
| 575 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 576 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
| 577 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
| 578 | physicalDevice, |
| 579 | "VkPhysicalDevice"); |
| 580 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
| 581 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 582 | pPhysicalDevice->pInstance, |
| 583 | "VkInstance", |
| 584 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 585 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 586 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
| 587 | } |
| 588 | |
| 589 | if (VK_FALSE == skipCall) { |
| 590 | // Call down the call chain: |
| 591 | result = my_data->instance_dispatch_table->GetPhysicalDeviceWin32PresentationSupportKHR( |
| 592 | physicalDevice, queueFamilyIndex); |
| 593 | |
| 594 | if (pPhysicalDevice) { |
| 595 | // Record the result of this query: |
| 596 | pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; |
| 597 | } |
| 598 | } |
| 599 | return result; |
| 600 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 601 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 602 | |
| 603 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 604 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( |
| 605 | VkInstance instance, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 606 | const VkXcbSurfaceCreateInfoKHR* pCreateInfo, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 607 | const VkAllocationCallbacks* pAllocator, |
| 608 | VkSurfaceKHR* pSurface) |
| 609 | { |
| 610 | VkResult result = VK_SUCCESS; |
| 611 | VkBool32 skipCall = VK_FALSE; |
| 612 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 613 | |
| 614 | // Validate that a valid VkInstance was used: |
| 615 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 616 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 617 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 618 | instance, |
| 619 | "VkInstance"); |
| 620 | } |
| 621 | |
| 622 | if (VK_FALSE == skipCall) { |
| 623 | // Call down the call chain: |
| 624 | result = my_data->instance_dispatch_table->CreateXcbSurfaceKHR( |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 625 | instance, pCreateInfo, pAllocator, pSurface); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 626 | |
| 627 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 628 | // Record the VkSurfaceKHR returned by the ICD: |
| 629 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 630 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 631 | my_data->surfaceMap[*pSurface].platform = VK_ICD_WSI_PLATFORM_XCB; |
| 632 | // Point to the associated SwpInstance: |
| 633 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 634 | skipCall |= validateSurface(my_data, *pSurface, (char *) __FUNCTION__); |
| 635 | } |
| 636 | return result; |
| 637 | } |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 638 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 639 | } |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 640 | |
| 641 | VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( |
| 642 | VkPhysicalDevice physicalDevice, |
| 643 | uint32_t queueFamilyIndex, |
| 644 | xcb_connection_t* connection, |
| 645 | xcb_visualid_t visual_id) |
| 646 | { |
| 647 | VkBool32 result = VK_FALSE; |
| 648 | VkBool32 skipCall = VK_FALSE; |
| 649 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 650 | |
| 651 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
| 652 | // extension was enabled: |
| 653 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 654 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
| 655 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
| 656 | physicalDevice, |
| 657 | "VkPhysicalDevice"); |
| 658 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
| 659 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 660 | pPhysicalDevice->pInstance, |
| 661 | "VkInstance", |
| 662 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 663 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 664 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
| 665 | } |
| 666 | |
| 667 | if (VK_FALSE == skipCall) { |
| 668 | // Call down the call chain: |
| 669 | result = my_data->instance_dispatch_table->GetPhysicalDeviceXcbPresentationSupportKHR( |
| 670 | physicalDevice, queueFamilyIndex, connection, visual_id); |
| 671 | |
| 672 | if (pPhysicalDevice) { |
| 673 | // Record the result of this query: |
| 674 | pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; |
| 675 | } |
| 676 | } |
| 677 | return result; |
| 678 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 679 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 680 | |
| 681 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 682 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( |
| 683 | VkInstance instance, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 684 | const VkXlibSurfaceCreateInfoKHR* pCreateInfo, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 685 | const VkAllocationCallbacks* pAllocator, |
| 686 | VkSurfaceKHR* pSurface) |
| 687 | { |
| 688 | VkResult result = VK_SUCCESS; |
| 689 | VkBool32 skipCall = VK_FALSE; |
| 690 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 691 | |
| 692 | // Validate that a valid VkInstance was used: |
| 693 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 694 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 695 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 696 | instance, |
| 697 | "VkInstance"); |
| 698 | } |
| 699 | |
| 700 | if (VK_FALSE == skipCall) { |
| 701 | // Call down the call chain: |
| 702 | result = my_data->instance_dispatch_table->CreateXlibSurfaceKHR( |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 703 | instance, pCreateInfo, pAllocator, pSurface); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 704 | |
| 705 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 706 | // Record the VkSurfaceKHR returned by the ICD: |
| 707 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 708 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 709 | my_data->surfaceMap[*pSurface].platform = VK_ICD_WSI_PLATFORM_XLIB; |
| 710 | // Point to the associated SwpInstance: |
| 711 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 712 | skipCall |= validateSurface(my_data, *pSurface, (char *) __FUNCTION__); |
| 713 | } |
| 714 | return result; |
| 715 | } |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 716 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 717 | } |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 718 | |
| 719 | VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( |
| 720 | VkPhysicalDevice physicalDevice, |
| 721 | uint32_t queueFamilyIndex, |
| 722 | Display* dpy, |
| 723 | VisualID visualID) |
| 724 | { |
| 725 | VkBool32 result = VK_FALSE; |
| 726 | VkBool32 skipCall = VK_FALSE; |
| 727 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 728 | |
| 729 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
| 730 | // extension was enabled: |
| 731 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 732 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
| 733 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
| 734 | physicalDevice, |
| 735 | "VkPhysicalDevice"); |
| 736 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
| 737 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 738 | pPhysicalDevice->pInstance, |
| 739 | "VkInstance", |
| 740 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 741 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 742 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
| 743 | } |
| 744 | |
| 745 | if (VK_FALSE == skipCall) { |
| 746 | // Call down the call chain: |
| 747 | result = my_data->instance_dispatch_table->GetPhysicalDeviceXlibPresentationSupportKHR( |
| 748 | physicalDevice, queueFamilyIndex, dpy, visualID); |
| 749 | |
| 750 | if (pPhysicalDevice) { |
| 751 | // Record the result of this query: |
| 752 | pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; |
| 753 | } |
| 754 | } |
| 755 | return result; |
| 756 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 757 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 758 | |
| 759 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator) |
| 760 | { |
| 761 | VkBool32 skipCall = VK_FALSE; |
| 762 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 763 | |
| 764 | // Validate that a valid VkInstance was used: |
| 765 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 766 | if (!pInstance) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 767 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 768 | instance, |
| 769 | "VkInstance"); |
| 770 | } |
| 771 | |
| 772 | if (VK_FALSE == skipCall) { |
| 773 | // Validate that a valid VkSurfaceKHR was used: |
| 774 | skipCall |= validateSurface(my_data, surface, (char *) __FUNCTION__); |
| 775 | } |
| 776 | |
| 777 | if (VK_FALSE == skipCall) { |
| 778 | // Call down the call chain: |
| 779 | my_data->instance_dispatch_table->DestroySurfaceKHR( |
| 780 | instance, surface, pAllocator); |
| 781 | } |
| 782 | |
| 783 | // Regardless of skipCall value, do some internal cleanup: |
| 784 | SwpSurface *pSurface = &my_data->surfaceMap[surface]; |
| 785 | if (pSurface && pSurface->pInstance) { |
| 786 | pSurface->pInstance->surfaces.erase(surface); |
| 787 | } |
| 788 | my_data->surfaceMap.erase(surface); |
| 789 | } |
| 790 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 791 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 792 | { |
| 793 | VkResult result = VK_SUCCESS; |
| 794 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 795 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 796 | |
| 797 | // Validate that a valid VkInstance was used: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 798 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 799 | if (!pInstance) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 800 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 801 | instance, |
| 802 | "VkInstance"); |
| 803 | } |
| 804 | |
| 805 | if (VK_FALSE == skipCall) { |
| 806 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 807 | result = my_data->instance_dispatch_table->EnumeratePhysicalDevices( |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 808 | instance, pPhysicalDeviceCount, pPhysicalDevices); |
| 809 | |
| 810 | if ((result == VK_SUCCESS) && pInstance && pPhysicalDevices && |
| 811 | (*pPhysicalDeviceCount > 0)) { |
| 812 | // Record the VkPhysicalDevices returned by the ICD: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 813 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 814 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 815 | my_data->physicalDeviceMap[pPhysicalDevices[i]].physicalDevice = |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 816 | pPhysicalDevices[i]; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 817 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pInstance = pInstance; |
| 818 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pDevice = NULL; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 819 | my_data->physicalDeviceMap[pPhysicalDevices[i]].gotSurfaceCapabilities = false; |
| 820 | my_data->physicalDeviceMap[pPhysicalDevices[i]].surfaceFormatCount = 0; |
| 821 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pSurfaceFormats = NULL; |
| 822 | my_data->physicalDeviceMap[pPhysicalDevices[i]].presentModeCount = 0; |
| 823 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pPresentModes = NULL; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 824 | // Point to the associated SwpInstance: |
| 825 | pInstance->physicalDevices[pPhysicalDevices[i]] = |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 826 | &my_data->physicalDeviceMap[pPhysicalDevices[i]]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 827 | } |
| 828 | } |
| 829 | |
| 830 | return result; |
| 831 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 832 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 833 | } |
| 834 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 835 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 836 | { |
| 837 | VkResult result = VK_SUCCESS; |
| 838 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 839 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 840 | |
| 841 | // Validate that a valid VkPhysicalDevice was used: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 842 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 843 | if (!pPhysicalDevice) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 844 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | 6c1cb5a | 2015-11-05 15:27:03 -0700 | [diff] [blame] | 845 | physicalDevice, "VkPhysicalDevice"); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 846 | } |
| 847 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 848 | if (VK_TRUE == skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 849 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 850 | |
| 851 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 852 | // Call down the call chain: |
| 853 | result = my_device_data->device_dispatch_table->CreateDevice( |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 854 | physicalDevice, pCreateInfo, pAllocator, pDevice); |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 855 | if (result == VK_SUCCESS) { |
| 856 | // Since it succeeded, do layer-specific work: |
Mark Lobodzinski | 6c1cb5a | 2015-11-05 15:27:03 -0700 | [diff] [blame] | 857 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 858 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
| 859 | createDeviceRegisterExtensions(physicalDevice, pCreateInfo, *pDevice); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 860 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 861 | return result; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 862 | } |
| 863 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 864 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 865 | { |
| 866 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 867 | dispatch_key key = get_dispatch_key(device); |
| 868 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 869 | // Validate that a valid VkDevice was used: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 870 | SwpDevice *pDevice = &my_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 871 | if (!pDevice) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 872 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 873 | device, |
| 874 | "VkDevice"); |
| 875 | } |
| 876 | |
| 877 | if (VK_FALSE == skipCall) { |
| 878 | // Call down the call chain: |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 879 | my_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | // Regardless of skipCall value, do some internal cleanup: |
| 883 | if (pDevice) { |
| 884 | // Delete the SwpDevice associated with this device: |
| 885 | if (pDevice->pPhysicalDevice) { |
| 886 | pDevice->pPhysicalDevice->pDevice = NULL; |
| 887 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 888 | if (!pDevice->swapchains.empty()) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 889 | LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 890 | SWAPCHAIN_DEL_DEVICE_BEFORE_SWAPCHAINS, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 891 | "%s() called before all of its associated " |
| 892 | "VkSwapchainKHRs were destroyed.", |
| 893 | __FUNCTION__); |
| 894 | // Empty and then delete all SwpSwapchain's |
| 895 | for (auto it = pDevice->swapchains.begin() ; |
| 896 | it != pDevice->swapchains.end() ; it++) { |
| 897 | // Delete all SwpImage's |
| 898 | it->second->images.clear(); |
| 899 | } |
| 900 | pDevice->swapchains.clear(); |
| 901 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 902 | my_data->deviceMap.erase(device); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 903 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 904 | delete my_data->device_dispatch_table; |
| 905 | layer_data_map.erase(key); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 906 | } |
| 907 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 908 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( |
| 909 | VkPhysicalDevice physicalDevice, |
| 910 | uint32_t queueFamilyIndex, |
| 911 | VkSurfaceKHR surface, |
| 912 | VkBool32* pSupported) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 913 | { |
Ian Elliott | 320d0fc | 2015-12-30 12:04:43 -0700 | [diff] [blame^] | 914 | // TODOs: |
| 915 | // |
| 916 | // - Ensure that queueFamilyIndex is a valid queue family index for |
| 917 | // physicalDevice. How? Probably need to record data from another function |
| 918 | // call(s). |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 919 | VkResult result = VK_SUCCESS; |
| 920 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 921 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 922 | |
| 923 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
| 924 | // extension was enabled: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 925 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 926 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 927 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 928 | physicalDevice, |
| 929 | "VkPhysicalDevice"); |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 930 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 931 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 932 | pPhysicalDevice->pInstance, |
| 933 | "VkInstance", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 934 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 935 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 936 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 937 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 938 | skipCall |= validateSurface(my_data, surface, (char *) __FUNCTION__); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 939 | |
| 940 | if (VK_FALSE == skipCall) { |
| 941 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 942 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceSupportKHR( |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 943 | physicalDevice, queueFamilyIndex, surface, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 944 | pSupported); |
| 945 | |
| 946 | if ((result == VK_SUCCESS) && pSupported && pPhysicalDevice) { |
| 947 | // Record the result of this query: |
| 948 | pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = |
| 949 | *pSupported; |
| 950 | // TODO: We need to compare this with the actual queue used for |
| 951 | // presentation, to ensure it was advertised to the application as |
| 952 | // supported for presentation. |
| 953 | } |
| 954 | |
| 955 | return result; |
| 956 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 957 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 958 | } |
| 959 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 960 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 961 | VkPhysicalDevice physicalDevice, |
| 962 | VkSurfaceKHR surface, |
| 963 | VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 964 | { |
| 965 | VkResult result = VK_SUCCESS; |
| 966 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 967 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 968 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 969 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 970 | // extension was enabled: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 971 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 972 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 973 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 974 | physicalDevice, |
| 975 | "VkPhysicalDevice"); |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 976 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 977 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 978 | pPhysicalDevice->pInstance, |
| 979 | "VkInstance", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 980 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 981 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 982 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 983 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 984 | skipCall |= validateSurface(my_data, surface, (char *) __FUNCTION__); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 985 | |
| 986 | if (VK_FALSE == skipCall) { |
| 987 | // Call down the call chain: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 988 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 989 | physicalDevice, surface, pSurfaceCapabilities); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 990 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 991 | if ((result == VK_SUCCESS) && pPhysicalDevice) { |
| 992 | pPhysicalDevice->gotSurfaceCapabilities = true; |
| 993 | // FIXME: NEED TO COPY THIS DATA, BECAUSE pSurfaceCapabilities POINTS TO APP-ALLOCATED DATA |
| 994 | pPhysicalDevice->surfaceCapabilities = *pSurfaceCapabilities; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | return result; |
| 998 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 999 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1000 | } |
| 1001 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1002 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( |
| 1003 | VkPhysicalDevice physicalDevice, |
| 1004 | VkSurfaceKHR surface, |
| 1005 | uint32_t* pCount, |
| 1006 | VkSurfaceFormatKHR* pSurfaceFormats) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1007 | { |
| 1008 | VkResult result = VK_SUCCESS; |
| 1009 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1010 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1011 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1012 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1013 | // extension was enabled: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1014 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 1015 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1016 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1017 | physicalDevice, |
| 1018 | "VkPhysicalDevice"); |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 1019 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1020 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1021 | pPhysicalDevice->pInstance, |
| 1022 | "VkInstance", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1023 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1024 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 1025 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1026 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1027 | skipCall |= validateSurface(my_data, surface, (char *) __FUNCTION__); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1028 | |
| 1029 | if (VK_FALSE == skipCall) { |
| 1030 | // Call down the call chain: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1031 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceFormatsKHR( |
| 1032 | physicalDevice, surface, pCount, pSurfaceFormats); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1033 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1034 | if ((result == VK_SUCCESS) && pPhysicalDevice && pSurfaceFormats && pCount && |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1035 | (*pCount > 0)) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1036 | pPhysicalDevice->surfaceFormatCount = *pCount; |
| 1037 | pPhysicalDevice->pSurfaceFormats = (VkSurfaceFormatKHR *) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1038 | malloc(*pCount * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1039 | if (pPhysicalDevice->pSurfaceFormats) { |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 1040 | for (uint32_t i = 0 ; i < *pCount ; i++) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1041 | pPhysicalDevice->pSurfaceFormats[i] = pSurfaceFormats[i]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1042 | } |
| 1043 | } else { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1044 | pPhysicalDevice->surfaceFormatCount = 0; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | return result; |
| 1049 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 1050 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1051 | } |
| 1052 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1053 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1054 | VkPhysicalDevice physicalDevice, |
| 1055 | VkSurfaceKHR surface, |
| 1056 | uint32_t* pCount, |
| 1057 | VkPresentModeKHR* pPresentModes) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1058 | { |
| 1059 | VkResult result = VK_SUCCESS; |
| 1060 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1061 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1062 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1063 | // Validate that a valid VkPhysicalDevice was used, and that the instance |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1064 | // extension was enabled: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1065 | SwpPhysicalDevice *pPhysicalDevice = &my_data->physicalDeviceMap[physicalDevice]; |
| 1066 | if (!pPhysicalDevice || !pPhysicalDevice->pInstance) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1067 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1068 | physicalDevice, |
| 1069 | "VkPhysicalDevice"); |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 1070 | } else if (!pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1071 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1072 | pPhysicalDevice->pInstance, |
| 1073 | "VkInstance", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1074 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1075 | "%s() called even though the %s extension was not enabled for this VkInstance.", |
| 1076 | __FUNCTION__, VK_KHR_SURFACE_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1077 | } |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1078 | skipCall |= validateSurface(my_data, surface, (char *) __FUNCTION__); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1079 | |
| 1080 | if (VK_FALSE == skipCall) { |
| 1081 | // Call down the call chain: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1082 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfacePresentModesKHR( |
| 1083 | physicalDevice, surface, pCount, pPresentModes); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1084 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1085 | if ((result == VK_SUCCESS) && pPhysicalDevice && pPresentModes && pCount && |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1086 | (*pCount > 0)) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1087 | pPhysicalDevice->presentModeCount = *pCount; |
| 1088 | pPhysicalDevice->pPresentModes = (VkPresentModeKHR *) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1089 | malloc(*pCount * sizeof(VkPresentModeKHR)); |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1090 | if (pPhysicalDevice->pSurfaceFormats) { |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 1091 | for (uint32_t i = 0 ; i < *pCount ; i++) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1092 | pPhysicalDevice->pPresentModes[i] = pPresentModes[i]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1093 | } |
| 1094 | } else { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1095 | pPhysicalDevice->presentModeCount = 0; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | return result; |
| 1100 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 1101 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1102 | } |
| 1103 | |
| 1104 | // This function does the up-front validation work for vkCreateSwapchainKHR(), |
| 1105 | // and returns VK_TRUE if a logging callback indicates that the call down the |
| 1106 | // chain should be skipped: |
| 1107 | static VkBool32 validateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, VkSwapchainKHR* pSwapchain) |
| 1108 | { |
| 1109 | // TODO: Validate cases of re-creating a swapchain (the current code |
| 1110 | // assumes a new swapchain is being created). |
| 1111 | VkResult result = VK_SUCCESS; |
| 1112 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1113 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1114 | char fn[] = "vkCreateSwapchainKHR"; |
| 1115 | |
| 1116 | // Validate that a valid VkDevice was used, and that the device |
| 1117 | // extension was enabled: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1118 | SwpDevice *pDevice = &my_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1119 | if (!pDevice) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1120 | return LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1121 | SWAPCHAIN_INVALID_HANDLE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1122 | "%s() called with a non-valid %s.", |
| 1123 | fn, "VkDevice"); |
| 1124 | |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 1125 | } else if (!pDevice->swapchainExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1126 | return LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1127 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 1128 | "%s() called even though the %s extension was not enabled for this VkDevice.", |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1129 | fn, VK_KHR_SWAPCHAIN_EXTENSION_NAME ); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | // Validate pCreateInfo with the results for previous queries: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1133 | if (!pDevice->pPhysicalDevice && !pDevice->pPhysicalDevice->gotSurfaceCapabilities) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1134 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1135 | SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1136 | "%s() called before calling " |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1137 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR().", |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1138 | fn); |
| 1139 | } else { |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1140 | // Validate pCreateInfo->surface, to ensure it is valid (Note: in order |
| 1141 | // to validate, we must lookup layer_data based on the VkInstance |
| 1142 | // associated with this VkDevice): |
| 1143 | SwpPhysicalDevice *pPhysicalDevice = pDevice->pPhysicalDevice; |
| 1144 | SwpInstance *pInstance = pPhysicalDevice->pInstance; |
| 1145 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(pInstance->instance), layer_data_map); |
| 1146 | skipCall |= validateSurface(my_instance_data, |
| 1147 | pCreateInfo->surface, |
| 1148 | (char *) "vkCreateSwapchainKHR"); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1149 | // Validate pCreateInfo->minImageCount against |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1150 | // VkSurfaceCapabilitiesKHR::{min|max}ImageCount: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1151 | VkSurfaceCapabilitiesKHR *pCapabilities = &pDevice->pPhysicalDevice->surfaceCapabilities; |
| 1152 | if ((pCreateInfo->minImageCount < pCapabilities->minImageCount) || |
| 1153 | ((pCapabilities->maxImageCount > 0) && |
| 1154 | (pCreateInfo->minImageCount > pCapabilities->maxImageCount))) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1155 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1156 | SWAPCHAIN_CREATE_SWAP_BAD_MIN_IMG_COUNT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1157 | "%s() called with pCreateInfo->minImageCount " |
| 1158 | "= %d, which is outside the bounds returned " |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1159 | "by vkGetPhysicalDeviceSurfaceCapabilitiesKHR() (i.e. " |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1160 | "minImageCount = %d, maxImageCount = %d).", |
| 1161 | fn, |
| 1162 | pCreateInfo->minImageCount, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1163 | pCapabilities->minImageCount, |
| 1164 | pCapabilities->maxImageCount); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1165 | } |
| 1166 | // Validate pCreateInfo->imageExtent against |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1167 | // VkSurfaceCapabilitiesKHR::{current|min|max}ImageExtent: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1168 | if ((pCapabilities->currentExtent.width == -1) && |
| 1169 | ((pCreateInfo->imageExtent.width < pCapabilities->minImageExtent.width) || |
| 1170 | (pCreateInfo->imageExtent.width > pCapabilities->maxImageExtent.width) || |
| 1171 | (pCreateInfo->imageExtent.height < pCapabilities->minImageExtent.height) || |
| 1172 | (pCreateInfo->imageExtent.height > pCapabilities->maxImageExtent.height))) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1173 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1174 | SWAPCHAIN_CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1175 | "%s() called with pCreateInfo->imageExtent = " |
| 1176 | "(%d,%d), which is outside the bounds " |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1177 | "returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): " |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1178 | "currentExtent = (%d,%d), minImageExtent = " |
| 1179 | "(%d,%d), maxImageExtent = (%d,%d).", |
| 1180 | fn, |
| 1181 | pCreateInfo->imageExtent.width, |
| 1182 | pCreateInfo->imageExtent.height, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1183 | pCapabilities->currentExtent.width, |
| 1184 | pCapabilities->currentExtent.height, |
| 1185 | pCapabilities->minImageExtent.width, |
| 1186 | pCapabilities->minImageExtent.height, |
| 1187 | pCapabilities->maxImageExtent.width, |
| 1188 | pCapabilities->maxImageExtent.height); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1189 | } |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1190 | if ((pCapabilities->currentExtent.width != -1) && |
| 1191 | ((pCreateInfo->imageExtent.width != pCapabilities->currentExtent.width) || |
| 1192 | (pCreateInfo->imageExtent.height != pCapabilities->currentExtent.height))) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1193 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1194 | SWAPCHAIN_CREATE_SWAP_EXTENTS_NO_MATCH_WIN, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1195 | "%s() called with pCreateInfo->imageExtent = " |
| 1196 | "(%d,%d), which is not equal to the " |
| 1197 | "currentExtent = (%d,%d) returned by " |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1198 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR().", |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1199 | fn, |
| 1200 | pCreateInfo->imageExtent.width, |
| 1201 | pCreateInfo->imageExtent.height, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1202 | pCapabilities->currentExtent.width, |
| 1203 | pCapabilities->currentExtent.height); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1204 | } |
| 1205 | // Validate pCreateInfo->preTransform against |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1206 | // VkSurfaceCapabilitiesKHR::supportedTransforms: |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 1207 | if (!((pCreateInfo->preTransform) & pCapabilities->supportedTransforms)) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1208 | // This is an error situation; one for which we'd like to give |
| 1209 | // the developer a helpful, multi-line error message. Build it |
| 1210 | // up a little at a time, and then log it: |
| 1211 | std::string errorString = ""; |
| 1212 | char str[1024]; |
| 1213 | // Here's the first part of the message: |
| 1214 | sprintf(str, "%s() called with a non-supported " |
| 1215 | "pCreateInfo->preTransform (i.e. %s). " |
| 1216 | "Supported values are:\n", |
| 1217 | fn, |
| 1218 | surfaceTransformStr(pCreateInfo->preTransform)); |
| 1219 | errorString += str; |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 1220 | for (int i = 0; i < 32; i++) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1221 | // Build up the rest of the message: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1222 | if ((1 << i) & pCapabilities->supportedTransforms) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1223 | const char *newStr = |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1224 | surfaceTransformStr((VkSurfaceTransformFlagBitsKHR) (1 << i)); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1225 | sprintf(str, " %s\n", newStr); |
| 1226 | errorString += str; |
| 1227 | } |
| 1228 | } |
| 1229 | // Log the message that we've built up: |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1230 | skipCall |= debug_report_log_msg(my_data->report_data, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1231 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1232 | VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | 80e774f | 2016-01-04 15:54:59 -0700 | [diff] [blame] | 1233 | (uint64_t) device, __LINE__, |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1234 | SWAPCHAIN_CREATE_SWAP_BAD_PRE_TRANSFORM, |
| 1235 | LAYER_NAME, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1236 | errorString.c_str()); |
| 1237 | } |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1238 | // Validate pCreateInfo->compositeAlpha against |
| 1239 | // VkSurfaceCapabilitiesKHR::supportedCompositeAlpha: |
| 1240 | if (!((pCreateInfo->compositeAlpha) & pCapabilities->supportedCompositeAlpha)) { |
| 1241 | // This is an error situation; one for which we'd like to give |
| 1242 | // the developer a helpful, multi-line error message. Build it |
| 1243 | // up a little at a time, and then log it: |
| 1244 | std::string errorString = ""; |
| 1245 | char str[1024]; |
| 1246 | // Here's the first part of the message: |
| 1247 | sprintf(str, "%s() called with a non-supported " |
| 1248 | "pCreateInfo->compositeAlpha (i.e. %s). " |
| 1249 | "Supported values are:\n", |
| 1250 | fn, |
| 1251 | surfaceCompositeAlphaStr(pCreateInfo->compositeAlpha)); |
| 1252 | errorString += str; |
| 1253 | for (int i = 0; i < 32; i++) { |
| 1254 | // Build up the rest of the message: |
| 1255 | if ((1 << i) & pCapabilities->supportedCompositeAlpha) { |
| 1256 | const char *newStr = |
| 1257 | surfaceCompositeAlphaStr((VkCompositeAlphaFlagBitsKHR) (1 << i)); |
| 1258 | sprintf(str, " %s\n", newStr); |
| 1259 | errorString += str; |
| 1260 | } |
| 1261 | } |
| 1262 | // Log the message that we've built up: |
| 1263 | skipCall |= debug_report_log_msg(my_data->report_data, |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 1264 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1265 | VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1266 | (uint64_t) device, 0, |
| 1267 | SWAPCHAIN_CREATE_SWAP_BAD_COMPOSITE_ALPHA, |
| 1268 | LAYER_NAME, |
| 1269 | errorString.c_str()); |
| 1270 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1271 | // Validate pCreateInfo->imageArraySize against |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1272 | // VkSurfaceCapabilitiesKHR::maxImageArraySize: |
Mark Lobodzinski | a3b4452 | 2015-12-11 11:05:33 -0700 | [diff] [blame] | 1273 | if (pCreateInfo->imageArrayLayers > pCapabilities->maxImageArrayLayers) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1274 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1275 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_ARRAY_SIZE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1276 | "%s() called with a non-supported " |
| 1277 | "pCreateInfo->imageArraySize (i.e. %d). " |
| 1278 | "Maximum value is %d.", |
| 1279 | fn, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1280 | pCreateInfo->imageArrayLayers, |
| 1281 | pCapabilities->maxImageArrayLayers); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1282 | } |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1283 | // Validate pCreateInfo->imageUsage against |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1284 | // VkSurfaceCapabilitiesKHR::supportedUsageFlags: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1285 | if (pCreateInfo->imageUsage && |
| 1286 | (pCreateInfo->imageUsage != |
| 1287 | (pCreateInfo->imageUsage & pCapabilities->supportedUsageFlags))) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1288 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1289 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_USAGE_FLAGS, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1290 | "%s() called with a non-supported " |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1291 | "pCreateInfo->imageUsage (i.e. 0x%08x)." |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1292 | " Supported flag bits are 0x%08x.", |
| 1293 | fn, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1294 | pCreateInfo->imageUsage, |
| 1295 | pCapabilities->supportedUsageFlags); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1296 | } |
| 1297 | } |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1298 | if (!pDevice->pPhysicalDevice && !pDevice->pPhysicalDevice->surfaceFormatCount) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1299 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1300 | SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1301 | "%s() called before calling " |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1302 | "vkGetPhysicalDeviceSurfaceFormatsKHR().", |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1303 | fn); |
| 1304 | } else { |
| 1305 | // Validate pCreateInfo->imageFormat against |
| 1306 | // VkSurfaceFormatKHR::format: |
| 1307 | bool foundFormat = false; |
| 1308 | bool foundColorSpace = false; |
| 1309 | bool foundMatch = false; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1310 | for (uint32_t i = 0 ; i < pDevice->pPhysicalDevice->surfaceFormatCount ; i++) { |
| 1311 | if (pCreateInfo->imageFormat == pDevice->pPhysicalDevice->pSurfaceFormats[i].format) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1312 | // Validate pCreateInfo->imageColorSpace against |
| 1313 | // VkSurfaceFormatKHR::colorSpace: |
| 1314 | foundFormat = true; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1315 | if (pCreateInfo->imageColorSpace == pDevice->pPhysicalDevice->pSurfaceFormats[i].colorSpace) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1316 | foundMatch = true; |
| 1317 | break; |
| 1318 | } |
| 1319 | } else { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1320 | if (pCreateInfo->imageColorSpace == pDevice->pPhysicalDevice->pSurfaceFormats[i].colorSpace) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1321 | foundColorSpace = true; |
| 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | if (!foundMatch) { |
| 1326 | if (!foundFormat) { |
| 1327 | if (!foundColorSpace) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1328 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1329 | "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1330 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_FMT_CLR_SP, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1331 | "%s() called with neither a " |
| 1332 | "supported pCreateInfo->imageFormat " |
| 1333 | "(i.e. %d) nor a supported " |
| 1334 | "pCreateInfo->imageColorSpace " |
| 1335 | "(i.e. %d).", |
| 1336 | fn, |
| 1337 | pCreateInfo->imageFormat, |
| 1338 | pCreateInfo->imageColorSpace); |
| 1339 | } else { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1340 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1341 | "VkDevice", |
| 1342 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_FORMAT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1343 | "%s() called with a non-supported " |
| 1344 | "pCreateInfo->imageFormat (i.e. %d).", |
| 1345 | fn, pCreateInfo->imageFormat); |
| 1346 | } |
| 1347 | } else if (!foundColorSpace) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1348 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1349 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_COLOR_SPACE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1350 | "%s() called with a non-supported " |
| 1351 | "pCreateInfo->imageColorSpace (i.e. %d).", |
| 1352 | fn, pCreateInfo->imageColorSpace); |
| 1353 | } |
| 1354 | } |
| 1355 | } |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1356 | if (!pDevice->pPhysicalDevice && !pDevice->pPhysicalDevice->presentModeCount) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1357 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1358 | SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1359 | "%s() called before calling " |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1360 | "vkGetPhysicalDeviceSurfacePresentModesKHR().", |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1361 | fn); |
| 1362 | } else { |
| 1363 | // Validate pCreateInfo->presentMode against |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1364 | // vkGetPhysicalDeviceSurfacePresentModesKHR(): |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1365 | bool foundMatch = false; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1366 | for (uint32_t i = 0 ; i < pDevice->pPhysicalDevice->presentModeCount ; i++) { |
| 1367 | if (pDevice->pPhysicalDevice->pPresentModes[i] == pCreateInfo->presentMode) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1368 | foundMatch = true; |
| 1369 | break; |
| 1370 | } |
| 1371 | } |
| 1372 | if (!foundMatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1373 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1374 | SWAPCHAIN_CREATE_SWAP_BAD_PRESENT_MODE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1375 | "%s() called with a non-supported " |
| 1376 | "pCreateInfo->presentMode (i.e. %s).", |
| 1377 | fn, |
| 1378 | presentModeStr(pCreateInfo->presentMode)); |
| 1379 | } |
| 1380 | } |
| 1381 | |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1382 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 1383 | if ((pCreateInfo->queueFamilyIndexCount <= 1) || |
| 1384 | !pCreateInfo->pQueueFamilyIndices) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 1385 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1386 | SWAPCHAIN_CREATE_SWAP_BAD_SHARING_VALUES, |
| 1387 | "%s() called with a supported " |
| 1388 | "pCreateInfo->sharingMode of (i.e. %s)," |
| 1389 | "but with a bad value(s) for " |
| 1390 | "pCreateInfo->queueFamilyIndexCount or " |
| 1391 | "pCreateInfo->pQueueFamilyIndices).", |
| 1392 | fn, |
| 1393 | sharingModeStr(pCreateInfo->imageSharingMode)); |
| 1394 | } |
| 1395 | } else if (pCreateInfo->imageSharingMode != VK_SHARING_MODE_EXCLUSIVE) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 1396 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1397 | SWAPCHAIN_CREATE_SWAP_BAD_SHARING_MODE, |
| 1398 | "%s() called with a non-supported " |
| 1399 | "pCreateInfo->imageSharingMode (i.e. %s).", |
| 1400 | fn, |
| 1401 | sharingModeStr(pCreateInfo->imageSharingMode)); |
| 1402 | } |
| 1403 | |
| 1404 | if ((pCreateInfo->clipped != VK_FALSE) && |
| 1405 | (pCreateInfo->clipped != VK_TRUE)) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 1406 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1407 | SWAPCHAIN_BAD_BOOL, |
| 1408 | "%s() called with a VkBool32 value that is neither " |
| 1409 | "VK_TRUE nor VK_FALSE, but has the numeric value of %d.", |
| 1410 | fn, |
| 1411 | pCreateInfo->clipped); |
| 1412 | } |
| 1413 | |
| 1414 | if (pCreateInfo->oldSwapchain) { |
| 1415 | SwpSwapchain *pSwapchain = &my_data->swapchainMap[pCreateInfo->oldSwapchain]; |
| 1416 | if (pSwapchain) { |
| 1417 | if (device != pSwapchain->pDevice->device) { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 1418 | LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1419 | SWAPCHAIN_DESTROY_SWAP_DIFF_DEVICE, |
| 1420 | "%s() called with a different VkDevice than the " |
| 1421 | "VkSwapchainKHR was created with.", |
| 1422 | __FUNCTION__); |
| 1423 | } |
| 1424 | } else { |
Ian Elliott | 1bf155f | 2015-12-29 17:35:46 -0700 | [diff] [blame] | 1425 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1426 | pCreateInfo->oldSwapchain, |
| 1427 | "VkSwapchainKHR"); |
| 1428 | } |
| 1429 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1430 | |
| 1431 | return skipCall; |
| 1432 | } |
| 1433 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1434 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( |
| 1435 | VkDevice device, |
| 1436 | const VkSwapchainCreateInfoKHR* pCreateInfo, |
| 1437 | const VkAllocationCallbacks* pAllocator, |
| 1438 | VkSwapchainKHR* pSwapchain) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1439 | { |
| 1440 | VkResult result = VK_SUCCESS; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1441 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1442 | VkBool32 skipCall = validateCreateSwapchainKHR(device, pCreateInfo, |
| 1443 | pSwapchain); |
| 1444 | |
| 1445 | if (VK_FALSE == skipCall) { |
| 1446 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1447 | result = my_data->device_dispatch_table->CreateSwapchainKHR( |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1448 | device, pCreateInfo, pAllocator, pSwapchain); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1449 | |
| 1450 | if (result == VK_SUCCESS) { |
| 1451 | // Remember the swapchain's handle, and link it to the device: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1452 | SwpDevice *pDevice = &my_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1453 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1454 | my_data->swapchainMap[*pSwapchain].swapchain = *pSwapchain; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1455 | pDevice->swapchains[*pSwapchain] = |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1456 | &my_data->swapchainMap[*pSwapchain]; |
| 1457 | my_data->swapchainMap[*pSwapchain].pDevice = pDevice; |
| 1458 | my_data->swapchainMap[*pSwapchain].imageCount = 0; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1459 | } |
| 1460 | |
| 1461 | return result; |
| 1462 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 1463 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1464 | } |
| 1465 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1466 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( |
| 1467 | VkDevice device, |
| 1468 | VkSwapchainKHR swapchain, |
| 1469 | const VkAllocationCallbacks* pAllocator) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1470 | { |
| 1471 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1472 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1473 | |
| 1474 | // Validate that a valid VkDevice was used, and that the device |
| 1475 | // extension was enabled: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1476 | SwpDevice *pDevice = &my_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1477 | if (!pDevice) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1478 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1479 | device, |
| 1480 | "VkDevice"); |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 1481 | } else if (!pDevice->swapchainExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1482 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1483 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 1484 | "%s() called even though the %s extension was not enabled for this VkDevice.", |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1485 | __FUNCTION__, VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1486 | } |
| 1487 | |
| 1488 | // Regardless of skipCall value, do some internal cleanup: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1489 | SwpSwapchain *pSwapchain = &my_data->swapchainMap[swapchain]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1490 | if (pSwapchain) { |
| 1491 | // Delete the SwpSwapchain associated with this swapchain: |
| 1492 | if (pSwapchain->pDevice) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1493 | pSwapchain->pDevice->swapchains.erase(swapchain); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1494 | if (device != pSwapchain->pDevice->device) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1495 | LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1496 | SWAPCHAIN_DESTROY_SWAP_DIFF_DEVICE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1497 | "%s() called with a different VkDevice than the " |
| 1498 | "VkSwapchainKHR was created with.", |
| 1499 | __FUNCTION__); |
| 1500 | } |
| 1501 | } |
| 1502 | if (pSwapchain->imageCount) { |
| 1503 | pSwapchain->images.clear(); |
| 1504 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1505 | my_data->swapchainMap.erase(swapchain); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1506 | } else { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1507 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1508 | swapchain, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1509 | "VkSwapchainKHR"); |
| 1510 | } |
| 1511 | |
| 1512 | if (VK_FALSE == skipCall) { |
| 1513 | // Call down the call chain: |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1514 | my_data->device_dispatch_table->DestroySwapchainKHR(device, swapchain, pAllocator); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1515 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1516 | } |
| 1517 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1518 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pCount, VkImage* pSwapchainImages) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1519 | { |
| 1520 | VkResult result = VK_SUCCESS; |
| 1521 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1522 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1523 | |
| 1524 | // Validate that a valid VkDevice was used, and that the device |
| 1525 | // extension was enabled: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1526 | SwpDevice *pDevice = &my_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1527 | if (!pDevice) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1528 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1529 | device, |
| 1530 | "VkDevice"); |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 1531 | } else if (!pDevice->swapchainExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1532 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1533 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 1534 | "%s() called even though the %s extension was not enabled for this VkDevice.", |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1535 | __FUNCTION__, VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1536 | } |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1537 | SwpSwapchain *pSwapchain = &my_data->swapchainMap[swapchain]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1538 | if (!pSwapchain) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1539 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1540 | swapchain.handle, |
| 1541 | "VkSwapchainKHR"); |
| 1542 | } |
| 1543 | |
| 1544 | if (VK_FALSE == skipCall) { |
| 1545 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1546 | result = my_data->device_dispatch_table->GetSwapchainImagesKHR( |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1547 | device, swapchain, pCount, pSwapchainImages); |
| 1548 | |
Ian Elliott | 6646385 | 2015-09-28 11:24:53 -0600 | [diff] [blame] | 1549 | // TBD: Should we validate that this function was called once with |
| 1550 | // pSwapchainImages set to NULL (and record pCount at that time), and then |
| 1551 | // called again with a non-NULL pSwapchainImages? |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1552 | if ((result == VK_SUCCESS) && pSwapchain &&pSwapchainImages && |
| 1553 | pCount && (*pCount > 0)) { |
| 1554 | // Record the images and their state: |
| 1555 | if (pSwapchain) { |
| 1556 | pSwapchain->imageCount = *pCount; |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 1557 | for (uint32_t i = 0 ; i < *pCount ; i++) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1558 | pSwapchain->images[i].image = pSwapchainImages[i]; |
| 1559 | pSwapchain->images[i].pSwapchain = pSwapchain; |
| 1560 | pSwapchain->images[i].ownedByApp = false; |
| 1561 | } |
| 1562 | } |
| 1563 | } |
| 1564 | |
| 1565 | return result; |
| 1566 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 1567 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1568 | } |
| 1569 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1570 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( |
| 1571 | VkDevice device, |
| 1572 | VkSwapchainKHR swapchain, |
| 1573 | uint64_t timeout, |
| 1574 | VkSemaphore semaphore, |
| 1575 | VkFence fence, |
| 1576 | uint32_t* pImageIndex) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1577 | { |
| 1578 | // TODO: Record/update the state of the swapchain, in case an error occurs |
| 1579 | // (e.g. VK_ERROR_OUT_OF_DATE_KHR). |
| 1580 | VkResult result = VK_SUCCESS; |
| 1581 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1582 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1583 | |
| 1584 | // Validate that a valid VkDevice was used, and that the device |
| 1585 | // extension was enabled: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1586 | SwpDevice *pDevice = &my_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1587 | if (!pDevice) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1588 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1589 | device, |
| 1590 | "VkDevice"); |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 1591 | } else if (!pDevice->swapchainExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1592 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1593 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 1594 | "%s() called even though the %s extension was not enabled for this VkDevice.", |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1595 | __FUNCTION__, VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1596 | } |
| 1597 | // Validate that a valid VkSwapchainKHR was used: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1598 | SwpSwapchain *pSwapchain = &my_data->swapchainMap[swapchain]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1599 | if (!pSwapchain) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1600 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1601 | swapchain, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1602 | "VkSwapchainKHR"); |
| 1603 | } else { |
| 1604 | // Look to see if the application is trying to own too many images at |
| 1605 | // the same time (i.e. not leave any to display): |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 1606 | uint32_t imagesOwnedByApp = 0; |
| 1607 | for (uint32_t i = 0 ; i < pSwapchain->imageCount ; i++) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1608 | if (pSwapchain->images[i].ownedByApp) { |
| 1609 | imagesOwnedByApp++; |
| 1610 | } |
| 1611 | } |
| 1612 | if (imagesOwnedByApp >= (pSwapchain->imageCount - 1)) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1613 | skipCall |= LOG_PERF_WARNING(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Ian Elliott | 4a99445 | 2015-09-24 18:33:16 -0600 | [diff] [blame] | 1614 | swapchain, |
| 1615 | "VkSwapchainKHR", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1616 | SWAPCHAIN_APP_OWNS_TOO_MANY_IMAGES, |
Ian Elliott | 4a99445 | 2015-09-24 18:33:16 -0600 | [diff] [blame] | 1617 | "%s() called when the application " |
| 1618 | "already owns all presentable images " |
| 1619 | "in this swapchain except for the " |
| 1620 | "image currently being displayed. " |
| 1621 | "This call to %s() cannot succeed " |
| 1622 | "unless another thread calls the " |
| 1623 | "vkQueuePresentKHR() function in " |
| 1624 | "order to release ownership of one of " |
| 1625 | "the presentable images of this " |
| 1626 | "swapchain.", |
| 1627 | __FUNCTION__, __FUNCTION__); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1628 | } |
| 1629 | } |
| 1630 | |
| 1631 | if (VK_FALSE == skipCall) { |
| 1632 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1633 | result = my_data->device_dispatch_table->AcquireNextImageKHR( |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1634 | device, swapchain, timeout, semaphore, fence, pImageIndex); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1635 | |
| 1636 | if (((result == VK_SUCCESS) || (result == VK_SUBOPTIMAL_KHR)) && |
| 1637 | pSwapchain) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1638 | // Change the state of the image (now owned by the application): |
| 1639 | pSwapchain->images[*pImageIndex].ownedByApp = true; |
| 1640 | } |
| 1641 | |
| 1642 | return result; |
| 1643 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 1644 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1645 | } |
| 1646 | |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1647 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( |
| 1648 | VkQueue queue, |
| 1649 | const VkPresentInfoKHR* pPresentInfo) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1650 | { |
| 1651 | // TODOs: |
| 1652 | // |
| 1653 | // - Ensure that the queue is active, and is one of the queueFamilyIndex's |
| 1654 | // that was returned by a previuos query. |
| 1655 | // - Record/update the state of the swapchain, in case an error occurs |
| 1656 | // (e.g. VK_ERROR_OUT_OF_DATE_KHR). |
| 1657 | VkResult result = VK_SUCCESS; |
| 1658 | VkBool32 skipCall = VK_FALSE; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1659 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1660 | |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 1661 | for (uint32_t i = 0; i < pPresentInfo->swapchainCount ; i++) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1662 | uint32_t index = pPresentInfo->pImageIndices[i]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1663 | SwpSwapchain *pSwapchain = |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1664 | &my_data->swapchainMap[pPresentInfo->pSwapchains[i]]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1665 | if (pSwapchain) { |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 1666 | if (!pSwapchain->pDevice->swapchainExtensionEnabled) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1667 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1668 | pSwapchain->pDevice, "VkDevice", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1669 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 1670 | "%s() called even though the %s extension was not enabled for this VkDevice.", |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 1671 | __FUNCTION__, VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1672 | } |
| 1673 | if (index >= pSwapchain->imageCount) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1674 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1675 | pPresentInfo->pSwapchains[i], |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1676 | "VkSwapchainKHR", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1677 | SWAPCHAIN_INDEX_TOO_LARGE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1678 | "%s() called for an index that is too " |
| 1679 | "large (i.e. %d). There are only %d " |
| 1680 | "images in this VkSwapchainKHR.\n", |
| 1681 | __FUNCTION__, index, |
| 1682 | pSwapchain->imageCount); |
| 1683 | } else { |
| 1684 | if (!pSwapchain->images[index].ownedByApp) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1685 | skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1686 | pPresentInfo->pSwapchains[i], |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1687 | "VkSwapchainKHR", |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 1688 | SWAPCHAIN_INDEX_NOT_IN_USE, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1689 | "%s() returned an index (i.e. %d) " |
| 1690 | "for an image that is not owned by " |
| 1691 | "the application.", |
| 1692 | __FUNCTION__, index); |
| 1693 | } |
| 1694 | } |
| 1695 | } else { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1696 | skipCall |= LOG_ERROR_NON_VALID_OBJ(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1697 | pPresentInfo->pSwapchains[i], |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1698 | "VkSwapchainKHR"); |
| 1699 | } |
| 1700 | } |
| 1701 | |
| 1702 | if (VK_FALSE == skipCall) { |
| 1703 | // Call down the call chain: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1704 | result = my_data->device_dispatch_table->QueuePresentKHR(queue, |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1705 | pPresentInfo); |
| 1706 | |
| 1707 | if ((result == VK_SUCCESS) || (result == VK_SUBOPTIMAL_KHR)) { |
Courtney Goeltzenleuchter | dad30df | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 1708 | for (uint32_t i = 0; i < pPresentInfo->swapchainCount ; i++) { |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1709 | int index = pPresentInfo->pImageIndices[i]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1710 | SwpSwapchain *pSwapchain = |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1711 | &my_data->swapchainMap[pPresentInfo->pSwapchains[i]]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1712 | if (pSwapchain) { |
| 1713 | // Change the state of the image (no longer owned by the |
| 1714 | // application): |
| 1715 | pSwapchain->images[index].ownedByApp = false; |
| 1716 | } |
| 1717 | } |
| 1718 | } |
| 1719 | |
| 1720 | return result; |
| 1721 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 1722 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1723 | } |
| 1724 | |
| 1725 | static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) |
| 1726 | { |
| 1727 | if (!name || name[0] != 'v' || name[1] != 'k') |
| 1728 | return NULL; |
| 1729 | |
| 1730 | name += 2; |
| 1731 | if (!strcmp(name, "CreateInstance")) |
| 1732 | return (PFN_vkVoidFunction) vkCreateInstance; |
| 1733 | if (!strcmp(name, "DestroyInstance")) |
| 1734 | return (PFN_vkVoidFunction) vkDestroyInstance; |
| 1735 | if (!strcmp(name, "EnumeratePhysicalDevices")) |
| 1736 | return (PFN_vkVoidFunction) vkEnumeratePhysicalDevices; |
| 1737 | if (!strcmp(name, "CreateDevice")) |
| 1738 | return (PFN_vkVoidFunction) vkCreateDevice; |
| 1739 | if (!strcmp(name, "DestroyDevice")) |
| 1740 | return (PFN_vkVoidFunction) vkDestroyDevice; |
| 1741 | |
| 1742 | return NULL; |
| 1743 | } |
| 1744 | static inline PFN_vkVoidFunction layer_intercept_instance_proc(const char *name) |
| 1745 | { |
| 1746 | if (!name || name[0] != 'v' || name[1] != 'k') |
| 1747 | return NULL; |
| 1748 | |
| 1749 | name += 2; |
| 1750 | if (!strcmp(name, "CreateInstance")) |
| 1751 | return (PFN_vkVoidFunction) vkCreateInstance; |
| 1752 | if (!strcmp(name, "DestroyInstance")) |
| 1753 | return (PFN_vkVoidFunction) vkDestroyInstance; |
| 1754 | if (!strcmp(name, "EnumeratePhysicalDevices")) |
| 1755 | return (PFN_vkVoidFunction) vkEnumeratePhysicalDevices; |
| 1756 | |
| 1757 | return NULL; |
| 1758 | } |
| 1759 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1760 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( |
| 1761 | VkInstance instance, |
| 1762 | const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, |
| 1763 | const VkAllocationCallbacks* pAllocator, |
| 1764 | VkDebugReportCallbackEXT* pMsgCallback) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1765 | { |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1766 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1767 | VkResult result = my_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1768 | if (VK_SUCCESS == result) { |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 1769 | result = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1770 | } |
| 1771 | return result; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1772 | } |
| 1773 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1774 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, const VkAllocationCallbacks *pAllocator) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1775 | { |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1776 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1777 | my_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 1778 | layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1779 | } |
| 1780 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1781 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 1782 | VkInstance instance, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1783 | VkDebugReportFlagsEXT flags, |
| 1784 | VkDebugReportObjectTypeEXT objType, |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 1785 | uint64_t object, |
| 1786 | size_t location, |
| 1787 | int32_t msgCode, |
| 1788 | const char* pLayerPrefix, |
| 1789 | const char* pMsg) |
| 1790 | { |
| 1791 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1792 | my_data->instance_dispatch_table->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 1793 | } |
| 1794 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1795 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* funcName) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1796 | { |
| 1797 | PFN_vkVoidFunction addr; |
| 1798 | if (device == VK_NULL_HANDLE) { |
| 1799 | return NULL; |
| 1800 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1801 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1802 | layer_data *my_data; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1803 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 1804 | if (!strcmp("vkGetDeviceProcAddr", funcName)) { |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1805 | VkBaseLayerObject* wrapped_dev = (VkBaseLayerObject*) device; |
| 1806 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_dev->baseObject), layer_data_map); |
| 1807 | my_data->device_dispatch_table = new VkLayerDispatchTable; |
| 1808 | layer_initialize_dispatch_table(my_data->device_dispatch_table, wrapped_dev); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1809 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
| 1810 | } |
| 1811 | |
| 1812 | addr = layer_intercept_proc(funcName); |
| 1813 | if (addr) |
| 1814 | return addr; |
| 1815 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1816 | my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1817 | VkLayerDispatchTable *pDisp = my_data->device_dispatch_table; |
| 1818 | if (my_data->deviceMap.size() != 0 && |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 1819 | my_data->deviceMap[device].swapchainExtensionEnabled) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1820 | { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1821 | if (!strcmp("vkCreateSwapchainKHR", funcName)) |
| 1822 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateSwapchainKHR); |
| 1823 | if (!strcmp("vkDestroySwapchainKHR", funcName)) |
| 1824 | return reinterpret_cast<PFN_vkVoidFunction>(vkDestroySwapchainKHR); |
| 1825 | if (!strcmp("vkGetSwapchainImagesKHR", funcName)) |
| 1826 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetSwapchainImagesKHR); |
| 1827 | if (!strcmp("vkAcquireNextImageKHR", funcName)) |
| 1828 | return reinterpret_cast<PFN_vkVoidFunction>(vkAcquireNextImageKHR); |
| 1829 | if (!strcmp("vkQueuePresentKHR", funcName)) |
| 1830 | return reinterpret_cast<PFN_vkVoidFunction>(vkQueuePresentKHR); |
| 1831 | } |
| 1832 | { |
| 1833 | if (pDisp->GetDeviceProcAddr == NULL) |
| 1834 | return NULL; |
| 1835 | return pDisp->GetDeviceProcAddr(device, funcName); |
| 1836 | } |
| 1837 | } |
| 1838 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1839 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1840 | { |
| 1841 | PFN_vkVoidFunction addr; |
| 1842 | if (instance == VK_NULL_HANDLE) { |
| 1843 | return NULL; |
| 1844 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1845 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1846 | layer_data *my_data; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1847 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 1848 | if (!strcmp("vkGetInstanceProcAddr", funcName)) { |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1849 | VkBaseLayerObject* wrapped_inst = (VkBaseLayerObject*) instance; |
| 1850 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_inst->baseObject), layer_data_map); |
| 1851 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
| 1852 | layer_init_instance_dispatch_table(my_data->instance_dispatch_table, wrapped_inst); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1853 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
| 1854 | } |
| 1855 | |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 1856 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
| 1857 | return (PFN_vkVoidFunction) vkEnumerateInstanceLayerProperties; |
| 1858 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
| 1859 | return (PFN_vkVoidFunction) vkEnumerateInstanceExtensionProperties; |
| 1860 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1861 | addr = layer_intercept_instance_proc(funcName); |
| 1862 | if (addr) |
| 1863 | return addr; |
| 1864 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1865 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 1866 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 1867 | addr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
| 1868 | if (addr) { |
| 1869 | return addr; |
| 1870 | } |
| 1871 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 1872 | if (my_data->instanceMap.size() != 0 && |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 1873 | my_data->instanceMap[instance].surfaceExtensionEnabled) |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1874 | { |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1875 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 1876 | if (!strcmp("vkCreateAndroidSurfaceKHR", funcName)) |
| 1877 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateAndroidSurfaceKHR); |
| 1878 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1879 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 1880 | if (!strcmp("vkCreateMirSurfaceKHR", funcName)) |
| 1881 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateMirSurfaceKHR); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 1882 | if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", funcName)) |
| 1883 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceMirPresentationSupportKHR); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1884 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1885 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 1886 | if (!strcmp("vkCreateWaylandSurfaceKHR", funcName)) |
| 1887 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateWaylandSurfaceKHR); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 1888 | if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", funcName)) |
| 1889 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceWaylandPresentationSupportKHR); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1890 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 1891 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 1892 | if (!strcmp("vkCreateWin32SurfaceKHR", funcName)) |
| 1893 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateWin32SurfaceKHR); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 1894 | if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", funcName)) |
| 1895 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceWin32PresentationSupportKHR); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1896 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 1897 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 1898 | if (!strcmp("vkCreateXcbSurfaceKHR", funcName)) |
| 1899 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateXcbSurfaceKHR); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 1900 | if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", funcName)) |
| 1901 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceXcbPresentationSupportKHR); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1902 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1903 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 1904 | if (!strcmp("vkCreateXlibSurfaceKHR", funcName)) |
| 1905 | return reinterpret_cast<PFN_vkVoidFunction>(vkCreateXlibSurfaceKHR); |
Ian Elliott | 55ff796 | 2015-12-30 10:18:47 -0700 | [diff] [blame] | 1906 | if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", funcName)) |
| 1907 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceXlibPresentationSupportKHR); |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 1908 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1909 | if (!strcmp("vkDestroySurfaceKHR", funcName)) |
| 1910 | return reinterpret_cast<PFN_vkVoidFunction>(vkDestroySurfaceKHR); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1911 | if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", funcName)) |
| 1912 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceSurfaceSupportKHR); |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 1913 | if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", funcName)) |
| 1914 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); |
| 1915 | if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", funcName)) |
| 1916 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceSurfaceFormatsKHR); |
| 1917 | if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", funcName)) |
| 1918 | return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceSurfacePresentModesKHR); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1919 | } |
| 1920 | |
| 1921 | if (pTable->GetInstanceProcAddr == NULL) |
| 1922 | return NULL; |
| 1923 | return pTable->GetInstanceProcAddr(instance, funcName); |
| 1924 | } |
| 1925 | |