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