Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2016 Google Inc. |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 5 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 9 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 11 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 17 | * |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 18 | * Author: Ian Elliott <ian@lunarg.com> |
Ian Elliott | 578e7e2 | 2016-01-05 14:03:16 -0700 | [diff] [blame] | 19 | * Author: Ian Elliott <ianelliott@google.com> |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 20 | */ |
| 21 | |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 22 | #include <mutex> |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 23 | #include <stdio.h> |
| 24 | #include <string.h> |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 25 | #include <vk_loader_platform.h> |
Cody Northrop | d08141b | 2016-02-01 09:52:07 -0700 | [diff] [blame] | 26 | #include <vulkan/vk_icd.h> |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 27 | #include "swapchain.h" |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 28 | #include "vk_layer_extension_utils.h" |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 29 | #include "vk_enum_string_helper.h" |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 30 | #include "vk_layer_utils.h" |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 31 | |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 32 | namespace swapchain { |
| 33 | |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 34 | static std::mutex global_lock; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 35 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 36 | // The following is for logging error messages: |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 37 | static std::unordered_map<void *, layer_data *> layer_data_map; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 38 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 39 | static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}}; |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 40 | |
Chia-I Wu | 40e25e7 | 2016-04-28 14:12:27 +0800 | [diff] [blame] | 41 | static const VkLayerProperties swapchain_layer = { |
Jon Ashburn | dc9111c | 2016-03-22 12:57:13 -0600 | [diff] [blame] | 42 | "VK_LAYER_LUNARG_swapchain", VK_LAYER_API_VERSION, 1, "LunarG Validation Layer", |
Chia-I Wu | 40e25e7 | 2016-04-28 14:12:27 +0800 | [diff] [blame] | 43 | }; |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 44 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 45 | static void checkDeviceRegisterExtensions(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, VkDevice device) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 46 | uint32_t i; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 47 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 48 | 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] | 49 | |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 50 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 51 | { |
| 52 | auto it = my_instance_data->physicalDeviceMap.find(physicalDevice); |
| 53 | pPhysicalDevice = (it == my_instance_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 54 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 55 | if (pPhysicalDevice) { |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 56 | my_device_data->deviceMap[device].pPhysicalDevice = pPhysicalDevice; |
| 57 | pPhysicalDevice->pDevice = &my_device_data->deviceMap[device]; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 58 | } else { |
Ian Elliott | 07adb11 | 2016-01-05 12:51:03 -0700 | [diff] [blame] | 59 | // TBD: Should we leave error in (since Swapchain really needs this |
| 60 | // link)? |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 61 | log_msg(my_instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 62 | reinterpret_cast<uint64_t>(physicalDevice), __LINE__, SWAPCHAIN_INVALID_HANDLE, "Swapchain", |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 63 | "vkCreateDevice() called with a non-valid VkPhysicalDevice."); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 64 | } |
Mark Lobodzinski | 55cd49b | 2015-11-27 15:23:23 -0700 | [diff] [blame] | 65 | my_device_data->deviceMap[device].device = device; |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 66 | my_device_data->deviceMap[device].swapchainExtensionEnabled = false; |
Mark Young | 1a86744 | 2016-07-01 15:18:27 -0600 | [diff] [blame^] | 67 | my_device_data->deviceMap[device].displaySwapchainExtensionEnabled = false; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 68 | |
| 69 | // Record whether the WSI device extension was enabled for this VkDevice. |
| 70 | // No need to check if the extension was advertised by |
| 71 | // vkEnumerateDeviceExtensionProperties(), since the loader handles that. |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 72 | for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 73 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) { |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 74 | my_device_data->deviceMap[device].swapchainExtensionEnabled = true; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 75 | } |
Mark Young | 1a86744 | 2016-07-01 15:18:27 -0600 | [diff] [blame^] | 76 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) == 0) { |
| 77 | my_device_data->deviceMap[device].displaySwapchainExtensionEnabled = true; |
| 78 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 82 | static void checkInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 83 | uint32_t i; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 84 | 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] | 85 | |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 86 | // Remember this instance, and whether the VK_KHR_surface extension |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 87 | // was enabled for it: |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 88 | my_data->instanceMap[instance].instance = instance; |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 89 | my_data->instanceMap[instance].surfaceExtensionEnabled = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 90 | my_data->instanceMap[instance].displayExtensionEnabled = false; |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 91 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 92 | my_data->instanceMap[instance].androidSurfaceExtensionEnabled = false; |
| 93 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 94 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 95 | my_data->instanceMap[instance].mirSurfaceExtensionEnabled = false; |
| 96 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 97 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 98 | my_data->instanceMap[instance].waylandSurfaceExtensionEnabled = false; |
| 99 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 100 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 101 | my_data->instanceMap[instance].win32SurfaceExtensionEnabled = false; |
| 102 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 103 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 104 | my_data->instanceMap[instance].xcbSurfaceExtensionEnabled = false; |
| 105 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 106 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 107 | my_data->instanceMap[instance].xlibSurfaceExtensionEnabled = false; |
| 108 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 109 | |
Ian Elliott | ed6b5ac | 2016-04-28 09:08:13 -0600 | [diff] [blame] | 110 | // Look for one or more debug report create info structures, and copy the |
| 111 | // callback(s) for each one found (for use by vkDestroyInstance) |
| 112 | layer_copy_tmp_callbacks(pCreateInfo->pNext, &my_data->num_tmp_callbacks, &my_data->tmp_dbg_create_infos, |
| 113 | &my_data->tmp_callbacks); |
| 114 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 115 | // Record whether the WSI instance extension was enabled for this |
| 116 | // VkInstance. No need to check if the extension was advertised by |
| 117 | // vkEnumerateInstanceExtensionProperties(), since the loader handles that. |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 118 | for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 119 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 120 | |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 121 | my_data->instanceMap[instance].surfaceExtensionEnabled = true; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 122 | } |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 123 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { |
| 124 | |
| 125 | my_data->instanceMap[instance].displayExtensionEnabled = true; |
| 126 | } |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 127 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 128 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 129 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 130 | my_data->instanceMap[instance].androidSurfaceExtensionEnabled = true; |
Jason Ekstrand | a5ebe8a | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 131 | } |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 132 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 133 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 134 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 135 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 136 | my_data->instanceMap[instance].mirSurfaceExtensionEnabled = true; |
Jason Ekstrand | a5ebe8a | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 137 | } |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 138 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 139 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 140 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 141 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 142 | my_data->instanceMap[instance].waylandSurfaceExtensionEnabled = true; |
Jason Ekstrand | a5ebe8a | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 143 | } |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 144 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 145 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 146 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 147 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 148 | my_data->instanceMap[instance].win32SurfaceExtensionEnabled = true; |
Jason Ekstrand | a5ebe8a | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 149 | } |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 150 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 151 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 152 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 153 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 154 | my_data->instanceMap[instance].xcbSurfaceExtensionEnabled = true; |
Jason Ekstrand | a5ebe8a | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 155 | } |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 156 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 157 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 158 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 8dffaf3 | 2016-01-04 14:10:30 -0700 | [diff] [blame] | 159 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 160 | my_data->instanceMap[instance].xlibSurfaceExtensionEnabled = true; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 161 | } |
Jason Ekstrand | a5ebe8a | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 162 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 166 | #include "vk_dispatch_table_helper.h" |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 167 | static void init_swapchain(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 168 | |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 169 | layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_swapchain"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 170 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 171 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 172 | static const char *surfaceTransformStr(VkSurfaceTransformFlagBitsKHR value) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 173 | // Return a string corresponding to the value: |
| 174 | return string_VkSurfaceTransformFlagBitsKHR(value); |
| 175 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 176 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 177 | static const char *surfaceCompositeAlphaStr(VkCompositeAlphaFlagBitsKHR value) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 178 | // Return a string corresponding to the value: |
| 179 | return string_VkCompositeAlphaFlagBitsKHR(value); |
| 180 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 181 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 182 | static const char *presentModeStr(VkPresentModeKHR value) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 183 | // Return a string corresponding to the value: |
| 184 | return string_VkPresentModeKHR(value); |
| 185 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 186 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 187 | static const char *sharingModeStr(VkSharingMode value) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 188 | // Return a string corresponding to the value: |
| 189 | return string_VkSharingMode(value); |
| 190 | } |
Ian Elliott | 07adb11 | 2016-01-05 12:51:03 -0700 | [diff] [blame] | 191 | |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 192 | static bool ValidateQueueFamilyIndex(layer_data *my_data, uint32_t queue_family_index, uint32_t queue_family_count, |
| 193 | VkPhysicalDevice physical_device, const char *function) { |
| 194 | bool skip_call = false; |
| 195 | if (queue_family_index >= queue_family_count) { |
| 196 | skip_call = log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 197 | reinterpret_cast<uint64_t>(physical_device), __LINE__, SWAPCHAIN_QUEUE_FAMILY_INDEX_TOO_LARGE, |
| 198 | swapchain_layer_name, |
| 199 | "%s() called with a queueFamilyIndex that is too large (i.e. %d). The maximum value (returned by " |
| 200 | "vkGetPhysicalDeviceQueueFamilyProperties) is only %d.", |
| 201 | function, queue_family_index, queue_family_count); |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 202 | } |
| 203 | return skip_call; |
| 204 | } |
| 205 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 206 | VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 207 | VkInstance *pInstance) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 208 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 209 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 210 | assert(chain_info->u.pLayerInfo); |
| 211 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 212 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 213 | if (fpCreateInstance == NULL) { |
| 214 | return VK_ERROR_INITIALIZATION_FAILED; |
| 215 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 216 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 217 | // Advance the link info for the next element on the chain |
| 218 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 219 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 220 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 221 | if (result != VK_SUCCESS) { |
| 222 | return result; |
| 223 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 224 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 225 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
Chia-I Wu | a673753 | 2016-04-28 16:04:15 +0800 | [diff] [blame] | 226 | my_data->instance = *pInstance; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 227 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
| 228 | layer_init_instance_dispatch_table(*pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 229 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 230 | my_data->report_data = debug_report_create_instance(my_data->instance_dispatch_table, *pInstance, |
| 231 | pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 232 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 233 | // Call the following function after my_data is initialized: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 234 | checkInstanceRegisterExtensions(pCreateInfo, *pInstance); |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 235 | init_swapchain(my_data, pAllocator); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 236 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 237 | return result; |
| 238 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 239 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 240 | VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 241 | dispatch_key key = get_dispatch_key(instance); |
| 242 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 243 | SwpInstance *pInstance = NULL; |
| 244 | { |
| 245 | auto it = my_data->instanceMap.find(instance); |
| 246 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 247 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 248 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 249 | // Call down the call chain: |
| 250 | my_data->instance_dispatch_table->DestroyInstance(instance, pAllocator); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 251 | |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 252 | std::lock_guard<std::mutex> lock(global_lock); |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 253 | |
Ian Elliott | ed6b5ac | 2016-04-28 09:08:13 -0600 | [diff] [blame] | 254 | // Enable the temporary callback(s) here to catch cleanup issues: |
| 255 | bool callback_setup = false; |
| 256 | if (my_data->num_tmp_callbacks > 0) { |
| 257 | if (!layer_enable_tmp_callbacks(my_data->report_data, my_data->num_tmp_callbacks, my_data->tmp_dbg_create_infos, |
| 258 | my_data->tmp_callbacks)) { |
| 259 | callback_setup = true; |
| 260 | } |
| 261 | } |
| 262 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 263 | // Do additional internal cleanup: |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 264 | if (pInstance) { |
| 265 | // Delete all of the SwpPhysicalDevice's, SwpSurface's, and the |
| 266 | // SwpInstance associated with this instance: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 267 | for (auto it = pInstance->physicalDevices.begin(); it != pInstance->physicalDevices.end(); it++) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 268 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 269 | // Free memory that was allocated for/by this SwpPhysicalDevice: |
| 270 | SwpPhysicalDevice *pPhysicalDevice = it->second; |
| 271 | if (pPhysicalDevice) { |
Ian Elliott | 458696a | 2016-02-04 06:11:17 -0700 | [diff] [blame] | 272 | if (pPhysicalDevice->pDevice) { |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 273 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 274 | reinterpret_cast<uint64_t>(pPhysicalDevice->pDevice->device), __LINE__, |
| 275 | SWAPCHAIN_DEL_OBJECT_BEFORE_CHILDREN, swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 276 | "VkDestroyInstance() called before all of its associated VkDevices were destroyed."); |
Ian Elliott | 458696a | 2016-02-04 06:11:17 -0700 | [diff] [blame] | 277 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 278 | free(pPhysicalDevice->pSurfaceFormats); |
| 279 | free(pPhysicalDevice->pPresentModes); |
| 280 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 281 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 282 | // Erase the SwpPhysicalDevice's from the my_data->physicalDeviceMap (which |
| 283 | // are simply pointed to by the SwpInstance): |
| 284 | my_data->physicalDeviceMap.erase(it->second->physicalDevice); |
| 285 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 286 | for (auto it = pInstance->surfaces.begin(); it != pInstance->surfaces.end(); it++) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 287 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 288 | // Free memory that was allocated for/by this SwpPhysicalDevice: |
| 289 | SwpSurface *pSurface = it->second; |
| 290 | if (pSurface) { |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 291 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 292 | reinterpret_cast<uint64_t>(pInstance->instance), __LINE__, SWAPCHAIN_DEL_OBJECT_BEFORE_CHILDREN, |
| 293 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 294 | "VkDestroyInstance() called before all of its associated VkSurfaceKHRs were destroyed."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | my_data->instanceMap.erase(instance); |
| 298 | } |
Mark Lobodzinski | 3c99d55 | 2016-02-04 13:50:23 -0700 | [diff] [blame] | 299 | |
Ian Elliott | ed6b5ac | 2016-04-28 09:08:13 -0600 | [diff] [blame] | 300 | // Disable and cleanup the temporary callback(s): |
| 301 | if (callback_setup) { |
| 302 | layer_disable_tmp_callbacks(my_data->report_data, my_data->num_tmp_callbacks, my_data->tmp_callbacks); |
| 303 | } |
| 304 | if (my_data->num_tmp_callbacks > 0) { |
| 305 | layer_free_tmp_callbacks(my_data->tmp_dbg_create_infos, my_data->tmp_callbacks); |
| 306 | my_data->num_tmp_callbacks = 0; |
| 307 | } |
| 308 | |
Mark Lobodzinski | 3c99d55 | 2016-02-04 13:50:23 -0700 | [diff] [blame] | 309 | // Clean up logging callback, if any |
| 310 | while (my_data->logging_callback.size() > 0) { |
| 311 | VkDebugReportCallbackEXT callback = my_data->logging_callback.back(); |
| 312 | layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); |
| 313 | my_data->logging_callback.pop_back(); |
| 314 | } |
| 315 | layer_debug_report_destroy_instance(my_data->report_data); |
| 316 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 317 | delete my_data->instance_dispatch_table; |
| 318 | layer_data_map.erase(key); |
| 319 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 320 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 321 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 322 | uint32_t *pQueueFamilyPropertyCount, |
| 323 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 324 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 325 | |
| 326 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 327 | my_data->instance_dispatch_table->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, |
| 328 | pQueueFamilyProperties); |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 329 | |
| 330 | // Record the result of this query: |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 331 | std::lock_guard<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 332 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 333 | { |
| 334 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 335 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 336 | } |
Ian Elliott | a2bb0e0 | 2016-08-24 11:30:45 -0600 | [diff] [blame] | 337 | // Note: for poorly-written applications (e.g. that don't call this command |
| 338 | // twice, the first time with pQueueFamilyProperties set to NULL, and the |
| 339 | // second time with a non-NULL pQueueFamilyProperties and with the same |
| 340 | // count as returned the first time), record the count when |
| 341 | // pQueueFamilyProperties is non-NULL: |
| 342 | if (pPhysicalDevice && pQueueFamilyPropertyCount && pQueueFamilyProperties) { |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 343 | pPhysicalDevice->gotQueueFamilyPropertyCount = true; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 344 | pPhysicalDevice->numOfQueueFamilies = *pQueueFamilyPropertyCount; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 345 | } |
| 346 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 347 | |
| 348 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 349 | VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, |
| 350 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 351 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 352 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 353 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 354 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 355 | SwpInstance *pInstance = NULL; |
| 356 | { |
| 357 | auto it = my_data->instanceMap.find(instance); |
| 358 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 359 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 360 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 361 | // Validate that the platform extension was enabled: |
Cody Northrop | d08141b | 2016-02-01 09:52:07 -0700 | [diff] [blame] | 362 | if (pInstance && !pInstance->androidSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 363 | skip_call |= |
| 364 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 365 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 366 | "vkCreateAndroidSurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 367 | VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 368 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 369 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 370 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 371 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 372 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 373 | result = my_data->instance_dispatch_table->CreateAndroidSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 374 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 375 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 376 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 377 | { |
| 378 | auto it = my_data->instanceMap.find(instance); |
| 379 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 380 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 381 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 382 | // Record the VkSurfaceKHR returned by the ICD: |
| 383 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 384 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 385 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 386 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 387 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 388 | // Point to the associated SwpInstance: |
| 389 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 390 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 391 | lock.unlock(); |
| 392 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 393 | return result; |
| 394 | } |
| 395 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 396 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 397 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 398 | |
| 399 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 400 | VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, |
| 401 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 402 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 403 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 404 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 405 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 406 | SwpInstance *pInstance = NULL; |
| 407 | { |
| 408 | auto it = my_data->instanceMap.find(instance); |
| 409 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 410 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 411 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 412 | // Validate that the platform extension was enabled: |
| 413 | if (pInstance && !pInstance->mirSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 414 | skip_call |= |
| 415 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 416 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 417 | "vkCreateMirSurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 418 | VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 419 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 420 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 421 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 422 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 423 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 424 | result = my_data->instance_dispatch_table->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 425 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 426 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 427 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 428 | { |
| 429 | auto it = my_data->instanceMap.find(instance); |
| 430 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 431 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 432 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 433 | // Record the VkSurfaceKHR returned by the ICD: |
| 434 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 435 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 436 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 437 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 438 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 439 | // Point to the associated SwpInstance: |
| 440 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 441 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 442 | lock.unlock(); |
| 443 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 444 | return result; |
| 445 | } |
| 446 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 447 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 448 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 449 | VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 450 | uint32_t queueFamilyIndex, MirConnection *connection) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 451 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 452 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 453 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 454 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 455 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 456 | { |
| 457 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 458 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 459 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 460 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 461 | // Validate that the platform extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 462 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->mirSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 463 | skip_call |= |
| 464 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 465 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 466 | swapchain_layer_name, "vkGetPhysicalDeviceMirPresentationSupportKHR() called even though the %s " |
| 467 | "extension was not enabled for this VkInstance.", |
| 468 | VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 469 | } |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 470 | if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 471 | skip_call |= ValidateQueueFamilyIndex(my_data, queueFamilyIndex, pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 472 | pPhysicalDevice->physicalDevice, "vkGetPhysicalDeviceMirPresentationSupportKHR"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 473 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 474 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 475 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 476 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 477 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 478 | result = my_data->instance_dispatch_table->GetPhysicalDeviceMirPresentationSupportKHR(physicalDevice, queueFamilyIndex, |
| 479 | connection); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 480 | } |
| 481 | return result; |
| 482 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 483 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 484 | |
| 485 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 486 | VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, |
| 487 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 488 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 489 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 490 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 491 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 492 | SwpInstance *pInstance = NULL; |
| 493 | { |
| 494 | auto it = my_data->instanceMap.find(instance); |
| 495 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 496 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 497 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 498 | // Validate that the platform extension was enabled: |
| 499 | if (pInstance && !pInstance->waylandSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 500 | skip_call |= |
| 501 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 502 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 503 | "vkCreateWaylandSurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 504 | VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 505 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 506 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 507 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 508 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 509 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 510 | result = my_data->instance_dispatch_table->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 511 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 512 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 513 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 514 | { |
| 515 | auto it = my_data->instanceMap.find(instance); |
| 516 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 517 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 518 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 519 | // Record the VkSurfaceKHR returned by the ICD: |
| 520 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 521 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 522 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 523 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 524 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 525 | // Point to the associated SwpInstance: |
| 526 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 527 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 528 | lock.unlock(); |
| 529 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 530 | return result; |
| 531 | } |
| 532 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 533 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 534 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 535 | VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 536 | uint32_t queueFamilyIndex, |
| 537 | struct wl_display *display) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 538 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 539 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 540 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 541 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 542 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 543 | { |
| 544 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 545 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 546 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 547 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 548 | // Validate that the platform extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 549 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->waylandSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 550 | skip_call |= |
| 551 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 552 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 553 | swapchain_layer_name, "vkGetPhysicalDeviceWaylandPresentationSupportKHR() called even though the %s " |
| 554 | "extension was not enabled for this VkInstance.", |
| 555 | VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 556 | } |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 557 | if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 558 | skip_call |= ValidateQueueFamilyIndex(my_data, queueFamilyIndex, pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 559 | pPhysicalDevice->physicalDevice, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 560 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 561 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 562 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 563 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 564 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 565 | result = my_data->instance_dispatch_table->GetPhysicalDeviceWaylandPresentationSupportKHR(physicalDevice, queueFamilyIndex, |
| 566 | display); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 567 | } |
| 568 | return result; |
| 569 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 570 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 571 | |
| 572 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 573 | VKAPI_ATTR VkResult VKAPI_CALL CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 574 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 575 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 576 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 577 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 578 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 579 | SwpInstance *pInstance = NULL; |
| 580 | { |
| 581 | auto it = my_data->instanceMap.find(instance); |
| 582 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 583 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 584 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 585 | // Validate that the platform extension was enabled: |
| 586 | if (pInstance && !pInstance->win32SurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 587 | skip_call |= |
| 588 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 589 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 590 | "vkCreateWin32SurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 591 | VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 592 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 593 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 594 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 595 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 596 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 597 | result = my_data->instance_dispatch_table->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 598 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 599 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 600 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 601 | { |
| 602 | auto it = my_data->instanceMap.find(instance); |
| 603 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 604 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 605 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 606 | // Record the VkSurfaceKHR returned by the ICD: |
| 607 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 608 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 609 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 610 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 611 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 612 | // Point to the associated SwpInstance: |
| 613 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 614 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 615 | lock.unlock(); |
| 616 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 617 | return result; |
| 618 | } |
| 619 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 620 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 621 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 622 | VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 623 | uint32_t queueFamilyIndex) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 624 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 625 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 626 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 627 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 628 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 629 | { |
| 630 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 631 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 632 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 633 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 634 | // Validate that the platform extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 635 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->win32SurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 636 | skip_call |= |
| 637 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 638 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 639 | swapchain_layer_name, "vkGetPhysicalDeviceWin32PresentationSupportKHR() called even though the %s extension " |
| 640 | "was not enabled for this VkInstance.", |
| 641 | VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 642 | } |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 643 | if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 644 | skip_call |= ValidateQueueFamilyIndex(my_data, queueFamilyIndex, pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 645 | pPhysicalDevice->physicalDevice, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 646 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 647 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 648 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 649 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 650 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 651 | result = my_data->instance_dispatch_table->GetPhysicalDeviceWin32PresentationSupportKHR(physicalDevice, queueFamilyIndex); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 652 | } |
| 653 | return result; |
| 654 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 655 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 656 | |
| 657 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 658 | VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, |
| 659 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 660 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 661 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 662 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 663 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 664 | SwpInstance *pInstance = NULL; |
| 665 | { |
| 666 | auto it = my_data->instanceMap.find(instance); |
| 667 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 668 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 669 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 670 | // Validate that the platform extension was enabled: |
| 671 | if (pInstance && !pInstance->xcbSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 672 | skip_call |= |
| 673 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 674 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 675 | "vkCreateXcbSurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 676 | VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 677 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 678 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 679 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 680 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 681 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 682 | result = my_data->instance_dispatch_table->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 683 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 684 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 685 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 686 | { |
| 687 | auto it = my_data->instanceMap.find(instance); |
| 688 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 689 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 690 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 691 | // Record the VkSurfaceKHR returned by the ICD: |
| 692 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 693 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 694 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 695 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 696 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 697 | // Point to the associated SwpInstance: |
| 698 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 699 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 700 | lock.unlock(); |
| 701 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 702 | return result; |
| 703 | } |
| 704 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 705 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 706 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 707 | VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 708 | uint32_t queueFamilyIndex, xcb_connection_t *connection, |
| 709 | xcb_visualid_t visual_id) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 710 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 711 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 712 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 713 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 714 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 715 | { |
| 716 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 717 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 718 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 719 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 720 | // Validate that the platform extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 721 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->xcbSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 722 | skip_call |= |
| 723 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 724 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 725 | swapchain_layer_name, "vkGetPhysicalDeviceXcbPresentationSupportKHR() called even though the %s " |
| 726 | "extension was not enabled for this VkInstance.", |
| 727 | VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 728 | } |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 729 | if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 730 | skip_call |= ValidateQueueFamilyIndex(my_data, queueFamilyIndex, pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 731 | pPhysicalDevice->physicalDevice, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 732 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 733 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 734 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 735 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 736 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 737 | result = my_data->instance_dispatch_table->GetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice, queueFamilyIndex, |
| 738 | connection, visual_id); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 739 | } |
| 740 | return result; |
| 741 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 742 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 743 | |
| 744 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 745 | VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, |
| 746 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 747 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 748 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 749 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 750 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 751 | SwpInstance *pInstance = NULL; |
| 752 | { |
| 753 | auto it = my_data->instanceMap.find(instance); |
| 754 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 755 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 756 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 757 | // Validate that the platform extension was enabled: |
| 758 | if (pInstance && !pInstance->xlibSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 759 | skip_call |= |
| 760 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 761 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 762 | "vkCreateXlibSurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 763 | VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 764 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 765 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 766 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 767 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 768 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 769 | result = my_data->instance_dispatch_table->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 770 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 771 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 772 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 773 | { |
| 774 | auto it = my_data->instanceMap.find(instance); |
| 775 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 776 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 777 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 778 | // Record the VkSurfaceKHR returned by the ICD: |
| 779 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 780 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 781 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 782 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 783 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 784 | // Point to the associated SwpInstance: |
| 785 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 786 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 787 | lock.unlock(); |
| 788 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 789 | return result; |
| 790 | } |
| 791 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 792 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 793 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 794 | VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 795 | uint32_t queueFamilyIndex, Display *dpy, |
| 796 | VisualID visualID) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 797 | VkBool32 result = VK_FALSE; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 798 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 799 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 800 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 801 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 802 | { |
| 803 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 804 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 805 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 806 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 807 | // Validate that the platform extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 808 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->xlibSurfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 809 | skip_call |= |
| 810 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 811 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 812 | swapchain_layer_name, "vkGetPhysicalDeviceXlibPresentationSupportKHR() called even though the %s " |
| 813 | "extension was not enabled for this VkInstance.", |
| 814 | VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 815 | } |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 816 | if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 817 | skip_call |= ValidateQueueFamilyIndex(my_data, queueFamilyIndex, pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 818 | pPhysicalDevice->physicalDevice, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 819 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 820 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 821 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 822 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 823 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 824 | result = my_data->instance_dispatch_table->GetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, queueFamilyIndex, |
| 825 | dpy, visualID); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 826 | } |
| 827 | return result; |
| 828 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 829 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 830 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 831 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 832 | VkDisplayPropertiesKHR *pProperties) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 833 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 834 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 835 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 836 | std::unique_lock<std::mutex> lock(global_lock); |
| 837 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 838 | { |
| 839 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 840 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 841 | } |
| 842 | |
| 843 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 844 | skip_call |= |
| 845 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 846 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 847 | swapchain_layer_name, "vkGetPhysicalDeviceDisplayPropertiesKHR() called even though the %s " |
| 848 | "extension was not enabled for this VkInstance.", |
| 849 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 850 | } |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 851 | lock.unlock(); |
| 852 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 853 | if (!skip_call) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 854 | result = |
| 855 | my_data->instance_dispatch_table->GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 856 | return result; |
| 857 | } |
| 858 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 859 | } |
| 860 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 861 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 862 | VkDisplayPlanePropertiesKHR *pProperties) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 863 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 864 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 865 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 866 | std::unique_lock<std::mutex> lock(global_lock); |
| 867 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 868 | { |
| 869 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 870 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 871 | } |
| 872 | |
| 873 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 874 | skip_call |= |
| 875 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 876 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 877 | swapchain_layer_name, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR() called even though the %s " |
| 878 | "extension was not enabled for this VkInstance.", |
| 879 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 880 | } |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 881 | lock.unlock(); |
| 882 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 883 | if (!skip_call) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 884 | result = my_data->instance_dispatch_table->GetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, pPropertyCount, |
| 885 | pProperties); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 886 | |
| 887 | lock.lock(); |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 888 | if (!pPhysicalDevice->gotDisplayPlanePropertyCount) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 889 | pPhysicalDevice->displayPlanePropertyCount = *pPropertyCount; |
| 890 | pPhysicalDevice->gotDisplayPlanePropertyCount = true; |
| 891 | } |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 892 | // TODO store the properties for later checks |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 893 | lock.unlock(); |
| 894 | |
| 895 | return result; |
| 896 | } |
| 897 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 898 | } |
| 899 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 900 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 901 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 902 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 903 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 904 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 905 | std::unique_lock<std::mutex> lock(global_lock); |
| 906 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 907 | { |
| 908 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 909 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 910 | } |
| 911 | |
| 912 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 913 | skip_call |= |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 914 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 915 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 916 | swapchain_layer_name, "vkGetDisplayPlaneSupportedDisplaysKHR() called even though the %s " |
| 917 | "extension was not enabled for this VkInstance.", |
| 918 | VK_KHR_DISPLAY_EXTENSION_NAME); |
| 919 | } |
| 920 | |
| 921 | if (!pPhysicalDevice->gotDisplayPlanePropertyCount) { |
| 922 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 923 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, |
| 924 | SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, swapchain_layer_name, |
| 925 | "Potential problem with calling vkGetDisplayPlaneSupportedDisplaysKHR() without first " |
| 926 | "querying vkGetPhysicalDeviceDisplayPlanePropertiesKHR."); |
| 927 | } |
| 928 | |
| 929 | if (pPhysicalDevice->gotDisplayPlanePropertyCount && planeIndex >= pPhysicalDevice->displayPlanePropertyCount) { |
| 930 | skip_call |= |
| 931 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 932 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_PLANE_INDEX_TOO_LARGE, |
| 933 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 934 | "vkGetDisplayPlaneSupportedDisplaysKHR(): planeIndex must be in the range [0, %d] that was returned by " |
| 935 | "vkGetPhysicalDeviceDisplayPlanePropertiesKHR. Do you have the plane index hardcoded?", |
| 936 | pPhysicalDevice->displayPlanePropertyCount - 1); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 937 | } |
| 938 | lock.unlock(); |
| 939 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 940 | if (!skip_call) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 941 | result = my_data->instance_dispatch_table->GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, pDisplayCount, |
| 942 | pDisplays); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 943 | |
| 944 | return result; |
| 945 | } |
Jon Ashburn | e699f44 | 2016-06-30 09:01:27 -0600 | [diff] [blame] | 946 | // TODO validate the returned display objects |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 947 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 948 | } |
| 949 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 950 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 951 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 952 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 953 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 954 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 955 | std::unique_lock<std::mutex> lock(global_lock); |
| 956 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 957 | { |
| 958 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 959 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 960 | } |
| 961 | |
| 962 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 963 | skip_call |= |
| 964 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 965 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 966 | swapchain_layer_name, |
| 967 | "vkGetDisplayModePropertiesKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 968 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 969 | } |
| 970 | |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 971 | lock.unlock(); |
| 972 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 973 | if (!skip_call) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 974 | result = |
| 975 | my_data->instance_dispatch_table->GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 976 | return result; |
| 977 | } |
Jon Ashburn | e699f44 | 2016-06-30 09:01:27 -0600 | [diff] [blame] | 978 | // TODO store the displayMode for later checking |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 979 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 980 | } |
| 981 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 982 | VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 983 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 984 | const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 985 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 986 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 987 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 988 | std::unique_lock<std::mutex> lock(global_lock); |
| 989 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 990 | { |
| 991 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 992 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 993 | } |
| 994 | |
| 995 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 996 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 997 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, |
| 998 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 999 | "vkCreateDisplayModeKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1000 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1001 | } |
| 1002 | |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1003 | lock.unlock(); |
| 1004 | |
Jon Ashburn | e699f44 | 2016-06-30 09:01:27 -0600 | [diff] [blame] | 1005 | // TODO more validation checks needed |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1006 | if (!skip_call) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1007 | result = my_data->instance_dispatch_table->CreateDisplayModeKHR(physicalDevice, display, pCreateInfo, pAllocator, pMode); |
| 1008 | return result; |
| 1009 | } |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1010 | |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1011 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1012 | } |
| 1013 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1014 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, |
| 1015 | uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1016 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1017 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1018 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1019 | std::unique_lock<std::mutex> lock(global_lock); |
| 1020 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 1021 | { |
| 1022 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1023 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1024 | } |
| 1025 | |
| 1026 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1027 | skip_call |= |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1028 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1029 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 1030 | swapchain_layer_name, |
| 1031 | "vkGetDisplayPlaneCapabilitiesKHR) called even though the %s extension was not enabled for this VkInstance.", |
| 1032 | VK_KHR_DISPLAY_EXTENSION_NAME); |
| 1033 | } |
| 1034 | |
| 1035 | if (!pPhysicalDevice->gotDisplayPlanePropertyCount) { |
| 1036 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 1037 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, |
| 1038 | SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, swapchain_layer_name, |
| 1039 | "Potential problem with calling vkGetDisplayPlaneCapabilitiesKHR() without first " |
| 1040 | "querying vkGetPhysicalDeviceDisplayPlanePropertiesKHR."); |
| 1041 | } |
| 1042 | |
| 1043 | if (pPhysicalDevice->gotDisplayPlanePropertyCount && planeIndex >= pPhysicalDevice->displayPlanePropertyCount) { |
| 1044 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 1045 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, |
| 1046 | SWAPCHAIN_PLANE_INDEX_TOO_LARGE, swapchain_layer_name, |
| 1047 | "vkGetDisplayPlaneCapabilitiesKHR(): planeIndex must be in the range [0, %d] that was returned by " |
| 1048 | "vkGetPhysicalDeviceDisplayPlanePropertiesKHR. Do you have the plane index hardcoded?", |
| 1049 | pPhysicalDevice->displayPlanePropertyCount - 1); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1050 | } |
| 1051 | |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1052 | lock.unlock(); |
| 1053 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1054 | if (!skip_call) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1055 | result = my_data->instance_dispatch_table->GetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, pCapabilities); |
| 1056 | return result; |
| 1057 | } |
| 1058 | |
| 1059 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1060 | } |
| 1061 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1062 | VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayPlaneSurfaceKHR(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, |
| 1063 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1064 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1065 | bool skip_call = false; |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1066 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 1067 | std::unique_lock<std::mutex> lock(global_lock); |
| 1068 | SwpInstance *pInstance = &(my_data->instanceMap[instance]); |
| 1069 | |
| 1070 | // Validate that the platform extension was enabled: |
| 1071 | if (pInstance && !pInstance->displayExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1072 | skip_call |= |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1073 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1074 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1075 | "vkCreateDisplayPlaneSurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1076 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1077 | } |
| 1078 | |
Jon Ashburn | e699f44 | 2016-06-30 09:01:27 -0600 | [diff] [blame] | 1079 | // TODO more validation checks |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1080 | if (!skip_call) { |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 1081 | // Call down the call chain: |
| 1082 | lock.unlock(); |
| 1083 | result = my_data->instance_dispatch_table->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
| 1084 | lock.lock(); |
| 1085 | |
| 1086 | // Obtain this pointer again after locking: |
| 1087 | pInstance = &(my_data->instanceMap[instance]); |
| 1088 | if ((result == VK_SUCCESS) && pInstance && pSurface) { |
| 1089 | // Record the VkSurfaceKHR returned by the ICD: |
| 1090 | my_data->surfaceMap[*pSurface].surface = *pSurface; |
| 1091 | my_data->surfaceMap[*pSurface].pInstance = pInstance; |
| 1092 | my_data->surfaceMap[*pSurface].usedAllocatorToCreate = (pAllocator != NULL); |
| 1093 | my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0; |
| 1094 | my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL; |
| 1095 | // Point to the associated SwpInstance: |
| 1096 | pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface]; |
| 1097 | } |
| 1098 | lock.unlock(); |
| 1099 | return result; |
| 1100 | } |
| 1101 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1102 | } |
| 1103 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1104 | VKAPI_ATTR void VKAPI_CALL DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1105 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1106 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1107 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1108 | SwpSurface *pSurface = NULL; |
| 1109 | { |
| 1110 | auto it = my_data->surfaceMap.find(surface); |
| 1111 | pSurface = (it == my_data->surfaceMap.end()) ? NULL : &it->second; |
| 1112 | } |
| 1113 | SwpInstance *pInstance = NULL; |
| 1114 | { |
| 1115 | auto it = my_data->instanceMap.find(instance); |
| 1116 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 1117 | } |
Ian Elliott | f6b8c78 | 2016-04-29 13:03:17 -0600 | [diff] [blame] | 1118 | |
| 1119 | // Validate that the platform extension was enabled: |
| 1120 | if (pInstance && !pInstance->surfaceExtensionEnabled) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1121 | skip_call |= |
| 1122 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 1123 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 1124 | "vkDestroySurfaceKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1125 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Ian Elliott | f6b8c78 | 2016-04-29 13:03:17 -0600 | [diff] [blame] | 1126 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1127 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1128 | // Regardless of skip_call value, do some internal cleanup: |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1129 | if (pSurface) { |
| 1130 | // Delete the SwpSurface associated with this surface: |
| 1131 | if (pSurface->pInstance) { |
| 1132 | pSurface->pInstance->surfaces.erase(surface); |
| 1133 | } |
| 1134 | if (!pSurface->swapchains.empty()) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1135 | skip_call |= |
| 1136 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 1137 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_DEL_OBJECT_BEFORE_CHILDREN, swapchain_layer_name, |
| 1138 | "vkDestroySurfaceKHR() called before all of its associated VkSwapchainKHRs were destroyed."); |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1139 | |
| 1140 | // Empty and then delete all SwpSwapchains |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1141 | for (auto it = pSurface->swapchains.begin(); it != pSurface->swapchains.end(); it++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1142 | // Delete all SwpImage's |
| 1143 | it->second->images.clear(); |
| 1144 | // In case the swapchain's device hasn't been destroyed yet |
| 1145 | // (which isn't likely, but is possible), delete its |
| 1146 | // association with this swapchain (i.e. so we can't point to |
| 1147 | // this swpchain from that device, later on): |
| 1148 | if (it->second->pDevice) { |
| 1149 | it->second->pDevice->swapchains.clear(); |
| 1150 | } |
| 1151 | } |
| 1152 | pSurface->swapchains.clear(); |
| 1153 | } |
| 1154 | if ((pAllocator != NULL) != pSurface->usedAllocatorToCreate) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1155 | skip_call |= |
| 1156 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
| 1157 | reinterpret_cast<uint64_t>(instance), __LINE__, SWAPCHAIN_INCOMPATIBLE_ALLOCATOR, swapchain_layer_name, |
| 1158 | "vkDestroySurfaceKHR() called with incompatible pAllocator from when the object was created."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1159 | } |
| 1160 | my_data->surfaceMap.erase(surface); |
| 1161 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1162 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1163 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1164 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1165 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1166 | my_data->instance_dispatch_table->DestroySurfaceKHR(instance, surface, pAllocator); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1167 | } |
| 1168 | } |
| 1169 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1170 | VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 1171 | VkPhysicalDevice *pPhysicalDevices) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1172 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1173 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1174 | |
| 1175 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1176 | result = my_data->instance_dispatch_table->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1177 | |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1178 | std::lock_guard<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1179 | SwpInstance *pInstance = NULL; |
| 1180 | { |
| 1181 | auto it = my_data->instanceMap.find(instance); |
| 1182 | pInstance = (it == my_data->instanceMap.end()) ? NULL : &it->second; |
| 1183 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1184 | if ((result == VK_SUCCESS) && pInstance && pPhysicalDevices && (*pPhysicalDeviceCount > 0)) { |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1185 | // Record the VkPhysicalDevices returned by the ICD: |
| 1186 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1187 | my_data->physicalDeviceMap[pPhysicalDevices[i]].physicalDevice = pPhysicalDevices[i]; |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1188 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pInstance = pInstance; |
| 1189 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pDevice = NULL; |
| 1190 | my_data->physicalDeviceMap[pPhysicalDevices[i]].gotQueueFamilyPropertyCount = false; |
| 1191 | my_data->physicalDeviceMap[pPhysicalDevices[i]].gotSurfaceCapabilities = false; |
| 1192 | my_data->physicalDeviceMap[pPhysicalDevices[i]].surfaceFormatCount = 0; |
| 1193 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pSurfaceFormats = NULL; |
| 1194 | my_data->physicalDeviceMap[pPhysicalDevices[i]].presentModeCount = 0; |
| 1195 | my_data->physicalDeviceMap[pPhysicalDevices[i]].pPresentModes = NULL; |
| 1196 | // Point to the associated SwpInstance: |
| 1197 | if (pInstance) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1198 | pInstance->physicalDevices[pPhysicalDevices[i]] = &my_data->physicalDeviceMap[pPhysicalDevices[i]]; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1199 | } |
| 1200 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1201 | } |
Ian Elliott | a3c69bc | 2016-02-04 15:34:59 -0700 | [diff] [blame] | 1202 | return result; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1205 | VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 1206 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
Chia-I Wu | a673753 | 2016-04-28 16:04:15 +0800 | [diff] [blame] | 1207 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1208 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1209 | |
| 1210 | assert(chain_info->u.pLayerInfo); |
| 1211 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1212 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
Chia-I Wu | a673753 | 2016-04-28 16:04:15 +0800 | [diff] [blame] | 1213 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1214 | if (fpCreateDevice == NULL) { |
| 1215 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1216 | } |
| 1217 | |
| 1218 | // Advance the link info for the next element on the chain |
| 1219 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1220 | |
| 1221 | VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 1222 | if (result != VK_SUCCESS) { |
| 1223 | return result; |
| 1224 | } |
| 1225 | |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1226 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1227 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 1228 | |
| 1229 | // Setup device dispatch table |
| 1230 | my_device_data->device_dispatch_table = new VkLayerDispatchTable; |
| 1231 | layer_init_device_dispatch_table(*pDevice, my_device_data->device_dispatch_table, fpGetDeviceProcAddr); |
| 1232 | |
| 1233 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 1234 | checkDeviceRegisterExtensions(physicalDevice, pCreateInfo, *pDevice); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1235 | |
| 1236 | return result; |
| 1237 | } |
| 1238 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 1239 | VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1240 | dispatch_key key = get_dispatch_key(device); |
| 1241 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1242 | |
| 1243 | // Call down the call chain: |
| 1244 | my_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
| 1245 | |
| 1246 | // Do some internal cleanup: |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1247 | std::lock_guard<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1248 | SwpDevice *pDevice = NULL; |
| 1249 | { |
| 1250 | auto it = my_data->deviceMap.find(device); |
| 1251 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 1252 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1253 | if (pDevice) { |
| 1254 | // Delete the SwpDevice associated with this device: |
| 1255 | if (pDevice->pPhysicalDevice) { |
| 1256 | pDevice->pPhysicalDevice->pDevice = NULL; |
| 1257 | } |
| 1258 | if (!pDevice->swapchains.empty()) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1259 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1260 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_DEL_OBJECT_BEFORE_CHILDREN, swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1261 | "vkDestroyDevice() called before all of its associated VkSwapchainKHRs were destroyed."); |
| 1262 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1263 | // Empty and then delete all SwpSwapchain's |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1264 | for (auto it = pDevice->swapchains.begin(); it != pDevice->swapchains.end(); it++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1265 | // Delete all SwpImage's |
| 1266 | it->second->images.clear(); |
| 1267 | // In case the swapchain's surface hasn't been destroyed yet |
| 1268 | // (which is likely) delete its association with this swapchain |
| 1269 | // (i.e. so we can't point to this swpchain from that surface, |
| 1270 | // later on): |
| 1271 | if (it->second->pSurface) { |
| 1272 | it->second->pSurface->swapchains.clear(); |
| 1273 | } |
| 1274 | } |
| 1275 | pDevice->swapchains.clear(); |
| 1276 | } |
| 1277 | my_data->deviceMap.erase(device); |
| 1278 | } |
| 1279 | delete my_data->device_dispatch_table; |
| 1280 | layer_data_map.erase(key); |
| 1281 | } |
| 1282 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1283 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, |
| 1284 | VkSurfaceKHR surface, VkBool32 *pSupported) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1285 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1286 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1287 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1288 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1289 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 1290 | { |
| 1291 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1292 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1293 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1294 | |
| 1295 | // Validate that the surface extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1296 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1297 | skip_call |= log_msg( |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1298 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1299 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 1300 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1301 | "vkGetPhysicalDeviceSurfaceSupportKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1302 | VK_KHR_SURFACE_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1303 | } |
| 1304 | if (!pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1305 | skip_call |= log_msg( |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1306 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1307 | reinterpret_cast<uint64_t>(pPhysicalDevice->physicalDevice), __LINE__, SWAPCHAIN_DID_NOT_QUERY_QUEUE_FAMILIES, |
| 1308 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1309 | "vkGetPhysicalDeviceSurfaceSupportKHR() called before calling the vkGetPhysicalDeviceQueueFamilyProperties function."); |
Mark Lobodzinski | c3b7c46 | 2016-08-08 11:09:27 -0600 | [diff] [blame] | 1310 | } else if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1311 | skip_call |= ValidateQueueFamilyIndex(my_data, queueFamilyIndex, pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1312 | pPhysicalDevice->physicalDevice, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1313 | } |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 1314 | |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1315 | lock.unlock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1316 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1317 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1318 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1319 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, |
| 1320 | pSupported); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1321 | lock.lock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1322 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1323 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1324 | { |
| 1325 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1326 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1327 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1328 | if ((result == VK_SUCCESS) && pSupported && pPhysicalDevice) { |
| 1329 | // Record the result of this query: |
| 1330 | SwpInstance *pInstance = pPhysicalDevice->pInstance; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1331 | SwpSurface *pSurface = (pInstance) ? pInstance->surfaces[surface] : NULL; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1332 | if (pSurface) { |
| 1333 | pPhysicalDevice->supportedSurfaces[surface] = pSurface; |
| 1334 | if (!pSurface->numQueueFamilyIndexSupport) { |
| 1335 | if (pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1336 | pSurface->pQueueFamilyIndexSupport = |
| 1337 | (VkBool32 *)malloc(pPhysicalDevice->numOfQueueFamilies * sizeof(VkBool32)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1338 | if (pSurface->pQueueFamilyIndexSupport != NULL) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1339 | pSurface->numQueueFamilyIndexSupport = pPhysicalDevice->numOfQueueFamilies; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1340 | } |
| 1341 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1342 | } |
| 1343 | if (pSurface->numQueueFamilyIndexSupport) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1344 | pSurface->pQueueFamilyIndexSupport[queueFamilyIndex] = *pSupported; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1345 | } |
| 1346 | } |
| 1347 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1348 | lock.unlock(); |
| 1349 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1350 | return result; |
| 1351 | } |
| 1352 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1353 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1354 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1355 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 1356 | VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1357 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1358 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1359 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1360 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1361 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 1362 | { |
| 1363 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1364 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1365 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1366 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1367 | // Validate that the surface extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1368 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1369 | skip_call |= log_msg( |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1370 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1371 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 1372 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1373 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1374 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1375 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1376 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1377 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1378 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1379 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1380 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, |
| 1381 | pSurfaceCapabilities); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1382 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1383 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1384 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1385 | { |
| 1386 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1387 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1388 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1389 | if ((result == VK_SUCCESS) && pPhysicalDevice) { |
| 1390 | // Record the result of this query: |
| 1391 | pPhysicalDevice->gotSurfaceCapabilities = true; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1392 | // FIXME: NEED TO COPY THIS DATA, BECAUSE pSurfaceCapabilities POINTS TO APP-ALLOCATED DATA |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1393 | pPhysicalDevice->surfaceCapabilities = *pSurfaceCapabilities; |
| 1394 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1395 | lock.unlock(); |
| 1396 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1397 | return result; |
| 1398 | } |
| 1399 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1400 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1401 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1402 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 1403 | uint32_t *pSurfaceFormatCount, |
| 1404 | VkSurfaceFormatKHR *pSurfaceFormats) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1405 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1406 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1407 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1408 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1409 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 1410 | { |
| 1411 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1412 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1413 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1414 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1415 | // Validate that the surface extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1416 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1417 | skip_call |= log_msg( |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1418 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1419 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 1420 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1421 | "vkGetPhysicalDeviceSurfaceFormatsKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1422 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1423 | } |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 1424 | if (pPhysicalDevice && pSurfaceFormats) { |
| 1425 | // Compare the preliminary value of *pSurfaceFormatCount with the value this time: |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1426 | if (pPhysicalDevice->surfaceFormatCount == 0) { |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 1427 | // Since we haven't recorded a preliminary value of *pSurfaceFormatCount, that likely means that the application didn't |
| 1428 | // previously call this function with a NULL value of pSurfaceFormats: |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1429 | skip_call |= log_msg( |
Mark Lobodzinski | 6a7e933 | 2016-08-16 09:06:15 -0600 | [diff] [blame] | 1430 | my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1431 | reinterpret_cast<uint64_t>(pPhysicalDevice->physicalDevice), __LINE__, SWAPCHAIN_PRIOR_COUNT, swapchain_layer_name, |
| 1432 | "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount; but no prior positive " |
| 1433 | "value has been seen for pSurfaceFormats."); |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1434 | } else if (*pSurfaceFormatCount > pPhysicalDevice->surfaceFormatCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1435 | skip_call |= log_msg( |
Mark Lobodzinski | 2511de1 | 2016-08-08 10:18:49 -0600 | [diff] [blame] | 1436 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1437 | reinterpret_cast<uint64_t>(pPhysicalDevice->physicalDevice), __LINE__, SWAPCHAIN_INVALID_COUNT, |
| 1438 | swapchain_layer_name, |
Mark Lobodzinski | 2511de1 | 2016-08-08 10:18:49 -0600 | [diff] [blame] | 1439 | "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount, and with pSurfaceFormats set to " |
| 1440 | "a value (%d) that is greater than the value (%d) that was returned when pSurfaceFormatCount was NULL.", |
| 1441 | *pSurfaceFormatCount, pPhysicalDevice->surfaceFormatCount); |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1442 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1443 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1444 | lock.unlock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1445 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1446 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1447 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1448 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount, |
| 1449 | pSurfaceFormats); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1450 | lock.lock(); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1451 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1452 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1453 | { |
| 1454 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1455 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1456 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1457 | if ((result == VK_SUCCESS) && pPhysicalDevice && !pSurfaceFormats && pSurfaceFormatCount) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1458 | // Record the result of this preliminary query: |
| 1459 | pPhysicalDevice->surfaceFormatCount = *pSurfaceFormatCount; |
Ian Elliott | a2bb0e0 | 2016-08-24 11:30:45 -0600 | [diff] [blame] | 1460 | } else if (((result == VK_SUCCESS) || (result == VK_INCOMPLETE)) && pPhysicalDevice && pSurfaceFormats && |
| 1461 | pSurfaceFormatCount && (*pSurfaceFormatCount > 0)) { |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1462 | // Record the result of this query: |
Ian Elliott | a2bb0e0 | 2016-08-24 11:30:45 -0600 | [diff] [blame] | 1463 | |
| 1464 | // Note: for poorly-written applications (e.g. that don't call this command |
| 1465 | // twice, the first time with pSurfaceFormats set to NULL, and the second time |
| 1466 | // with a non-NULL pSurfaceFormats and with the same count as returned the |
| 1467 | // first time), record again the count when pSurfaceFormats is non-NULL: |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1468 | pPhysicalDevice->surfaceFormatCount = *pSurfaceFormatCount; |
| 1469 | pPhysicalDevice->pSurfaceFormats = (VkSurfaceFormatKHR *)malloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR)); |
| 1470 | if (pPhysicalDevice->pSurfaceFormats) { |
| 1471 | for (uint32_t i = 0; i < *pSurfaceFormatCount; i++) { |
| 1472 | pPhysicalDevice->pSurfaceFormats[i] = pSurfaceFormats[i]; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1473 | } |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1474 | } else { |
| 1475 | pPhysicalDevice->surfaceFormatCount = 0; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1476 | } |
| 1477 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1478 | lock.unlock(); |
| 1479 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1480 | return result; |
| 1481 | } |
| 1482 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1483 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1484 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1485 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 1486 | uint32_t *pPresentModeCount, |
| 1487 | VkPresentModeKHR *pPresentModes) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1488 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1489 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1490 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1491 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1492 | SwpPhysicalDevice *pPhysicalDevice = NULL; |
| 1493 | { |
| 1494 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1495 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1496 | } |
Ian Elliott | 07adb11 | 2016-01-05 12:51:03 -0700 | [diff] [blame] | 1497 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1498 | // Validate that the surface extension was enabled: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1499 | if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1500 | skip_call |= log_msg( |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1501 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1502 | reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, |
| 1503 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1504 | "vkGetPhysicalDeviceSurfacePresentModesKHR() called even though the %s extension was not enabled for this VkInstance.", |
| 1505 | VK_KHR_DISPLAY_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1506 | } |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 1507 | if (pPhysicalDevice && pPresentModes) { |
| 1508 | // Compare the preliminary value of *pPresentModeCount with the value this time: |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1509 | if (pPhysicalDevice->presentModeCount == 0) { |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 1510 | // Since we haven't recorded a preliminary value of *pPresentModeCount, that likely means that the application didn't |
| 1511 | // previously call this function with a NULL value of pPresentModes: |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1512 | skip_call |= log_msg( |
Mark Lobodzinski | 6a7e933 | 2016-08-16 09:06:15 -0600 | [diff] [blame] | 1513 | my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1514 | reinterpret_cast<uint64_t>(pPhysicalDevice->physicalDevice), __LINE__, SWAPCHAIN_PRIOR_COUNT, swapchain_layer_name, |
| 1515 | "vkGetPhysicalDeviceSurfacePresentModesKHR() called with non-NULL pPresentModeCount; but no prior positive " |
| 1516 | "value has been seen for pPresentModes."); |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1517 | } else if (*pPresentModeCount > pPhysicalDevice->presentModeCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1518 | skip_call |= log_msg( |
Mark Lobodzinski | 2511de1 | 2016-08-08 10:18:49 -0600 | [diff] [blame] | 1519 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1520 | reinterpret_cast<uint64_t>(pPhysicalDevice->physicalDevice), __LINE__, SWAPCHAIN_INVALID_COUNT, |
| 1521 | swapchain_layer_name, |
Mark Lobodzinski | 2511de1 | 2016-08-08 10:18:49 -0600 | [diff] [blame] | 1522 | "vkGetPhysicalDeviceSurfacePresentModesKHR() called with non-NULL pPresentModeCount, and with pPresentModes set to " |
| 1523 | "a value (%d) that is greater than the value (%d) that was returned when pPresentModeCount was NULL.", |
| 1524 | *pPresentModeCount, pPhysicalDevice->presentModeCount); |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1525 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1526 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1527 | lock.unlock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1528 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1529 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1530 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1531 | result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, |
| 1532 | pPresentModeCount, pPresentModes); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1533 | lock.lock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1534 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 1535 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1536 | { |
| 1537 | auto it = my_data->physicalDeviceMap.find(physicalDevice); |
| 1538 | pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; |
| 1539 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1540 | if ((result == VK_SUCCESS) && pPhysicalDevice && !pPresentModes && pPresentModeCount) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1541 | // Record the result of this preliminary query: |
| 1542 | pPhysicalDevice->presentModeCount = *pPresentModeCount; |
Ian Elliott | a2bb0e0 | 2016-08-24 11:30:45 -0600 | [diff] [blame] | 1543 | } else if (((result == VK_SUCCESS) || (result == VK_INCOMPLETE)) && pPhysicalDevice && |
| 1544 | pPresentModes && pPresentModeCount && (*pPresentModeCount > 0)) { |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1545 | // Record the result of this query: |
Ian Elliott | a2bb0e0 | 2016-08-24 11:30:45 -0600 | [diff] [blame] | 1546 | |
| 1547 | // Note: for poorly-written applications (e.g. that don't call this command |
| 1548 | // twice, the first time with pPresentModes set to NULL, and the second time |
| 1549 | // with a non-NULL pPresentModes and with the same count as returned the |
| 1550 | // first time), record again the count when pPresentModes is non-NULL: |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1551 | pPhysicalDevice->presentModeCount = *pPresentModeCount; |
| 1552 | pPhysicalDevice->pPresentModes = (VkPresentModeKHR *)malloc(*pPresentModeCount * sizeof(VkPresentModeKHR)); |
| 1553 | if (pPhysicalDevice->pPresentModes) { |
| 1554 | for (uint32_t i = 0; i < *pPresentModeCount; i++) { |
| 1555 | pPhysicalDevice->pPresentModes[i] = pPresentModes[i]; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1556 | } |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 1557 | } else { |
| 1558 | pPhysicalDevice->presentModeCount = 0; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1559 | } |
| 1560 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1561 | lock.unlock(); |
| 1562 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1563 | return result; |
| 1564 | } |
| 1565 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1566 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1567 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1568 | // This function does the up-front validation work for vkCreateSwapchainKHR(), |
Dustin Graves | 080069b | 2016-04-05 13:48:15 -0600 | [diff] [blame] | 1569 | // and returns true if a logging callback indicates that the call down the |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1570 | // chain should be skipped: |
Dustin Graves | 080069b | 2016-04-05 13:48:15 -0600 | [diff] [blame] | 1571 | static bool validateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, VkSwapchainKHR *pSwapchain) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1572 | // TODO: Validate cases of re-creating a swapchain (the current code |
| 1573 | // assumes a new swapchain is being created). |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1574 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1575 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1576 | char fn[] = "vkCreateSwapchainKHR"; |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1577 | SwpDevice *pDevice = NULL; |
| 1578 | { |
| 1579 | auto it = my_data->deviceMap.find(device); |
| 1580 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 1581 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1582 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1583 | // Validate that the swapchain extension was enabled: |
| 1584 | if (pDevice && !pDevice->swapchainExtensionEnabled) { |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1585 | return log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1586 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1587 | "vkCreateSwapchainKHR() called even though the %s extension was not enabled for this VkDevice.", |
| 1588 | VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1589 | } |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 1590 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1591 | // Keep around a useful pointer to pPhysicalDevice: |
| 1592 | SwpPhysicalDevice *pPhysicalDevice = pDevice->pPhysicalDevice; |
Ian Elliott | f7f8ff0 | 2015-12-30 14:55:41 -0700 | [diff] [blame] | 1593 | |
Mark Lobodzinski | d40b2db | 2016-02-25 13:56:57 -0700 | [diff] [blame] | 1594 | // Validate pCreateInfo values with result of |
| 1595 | // vkGetPhysicalDeviceQueueFamilyProperties |
| 1596 | if (pPhysicalDevice && pPhysicalDevice->gotQueueFamilyPropertyCount) { |
Michael Mc Donnell | 75ecdb7 | 2016-04-03 14:47:51 -0700 | [diff] [blame] | 1597 | for (uint32_t i = 0; i < pCreateInfo->queueFamilyIndexCount; i++) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1598 | skip_call |= ValidateQueueFamilyIndex(my_data, pCreateInfo->pQueueFamilyIndices[i], pPhysicalDevice->numOfQueueFamilies, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1599 | pPhysicalDevice->physicalDevice, "vkCreateSwapchainKHR"); |
Mark Lobodzinski | d40b2db | 2016-02-25 13:56:57 -0700 | [diff] [blame] | 1600 | } |
| 1601 | } |
| 1602 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1603 | // Validate pCreateInfo values with the results of |
| 1604 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1605 | if (!pPhysicalDevice || !pPhysicalDevice->gotSurfaceCapabilities) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1606 | skip_call |= |
| 1607 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1608 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, swapchain_layer_name, |
| 1609 | "vkCreateSwapchainKHR() called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1610 | } else if (pCreateInfo) { |
| 1611 | // Validate pCreateInfo->surface to make sure that |
| 1612 | // vkGetPhysicalDeviceSurfaceSupportKHR() reported this as a supported |
| 1613 | // surface: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1614 | SwpSurface *pSurface = ((pPhysicalDevice) ? pPhysicalDevice->supportedSurfaces[pCreateInfo->surface] : NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1615 | if (!pSurface) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1616 | skip_call |= |
| 1617 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1618 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_UNSUPPORTED_SURFACE, swapchain_layer_name, |
| 1619 | "The surface in pCreateInfo->surface, that was given to vkCreateSwapchainKHR(), must be a surface " |
| 1620 | "that is supported by the device as determined by vkGetPhysicalDeviceSurfaceSupportKHR(). " |
| 1621 | "However, vkGetPhysicalDeviceSurfaceSupportKHR() was never called with this surface."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1622 | } |
Ian Elliott | 4f147fc | 2016-01-20 08:52:08 -0700 | [diff] [blame] | 1623 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1624 | // Validate pCreateInfo->minImageCount against |
| 1625 | // VkSurfaceCapabilitiesKHR::{min|max}ImageCount: |
| 1626 | VkSurfaceCapabilitiesKHR *pCapabilities = &pPhysicalDevice->surfaceCapabilities; |
| 1627 | if ((pCreateInfo->minImageCount < pCapabilities->minImageCount) || |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1628 | ((pCapabilities->maxImageCount > 0) && (pCreateInfo->minImageCount > pCapabilities->maxImageCount))) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1629 | skip_call |= |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1630 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1631 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_MIN_IMG_COUNT, swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1632 | "vkCreateSwapchainKHR() called with pCreateInfo->minImageCount = %d, which is outside the bounds returned " |
| 1633 | "by vkGetPhysicalDeviceSurfaceCapabilitiesKHR() (i.e. minImageCount = %d, maxImageCount = %d).", |
| 1634 | pCreateInfo->minImageCount, pCapabilities->minImageCount, pCapabilities->maxImageCount); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1635 | } |
| 1636 | // Validate pCreateInfo->imageExtent against |
| 1637 | // VkSurfaceCapabilitiesKHR::{current|min|max}ImageExtent: |
| 1638 | if ((pCapabilities->currentExtent.width == -1) && |
| 1639 | ((pCreateInfo->imageExtent.width < pCapabilities->minImageExtent.width) || |
| 1640 | (pCreateInfo->imageExtent.width > pCapabilities->maxImageExtent.width) || |
| 1641 | (pCreateInfo->imageExtent.height < pCapabilities->minImageExtent.height) || |
| 1642 | (pCreateInfo->imageExtent.height > pCapabilities->maxImageExtent.height))) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1643 | skip_call |= log_msg( |
| 1644 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1645 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS, swapchain_layer_name, |
| 1646 | "vkCreateSwapchainKHR() called with pCreateInfo->imageExtent = (%d,%d), which is outside the " |
| 1647 | "bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (%d,%d), " |
| 1648 | "minImageExtent = (%d,%d), maxImageExtent = (%d,%d).", |
| 1649 | pCreateInfo->imageExtent.width, pCreateInfo->imageExtent.height, pCapabilities->currentExtent.width, |
| 1650 | pCapabilities->currentExtent.height, pCapabilities->minImageExtent.width, pCapabilities->minImageExtent.height, |
| 1651 | pCapabilities->maxImageExtent.width, pCapabilities->maxImageExtent.height); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1652 | } |
| 1653 | if ((pCapabilities->currentExtent.width != -1) && |
| 1654 | ((pCreateInfo->imageExtent.width != pCapabilities->currentExtent.width) || |
| 1655 | (pCreateInfo->imageExtent.height != pCapabilities->currentExtent.height))) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1656 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1657 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_EXTENTS_NO_MATCH_WIN, |
| 1658 | swapchain_layer_name, |
| 1659 | "vkCreateSwapchainKHR() called with pCreateInfo->imageExtent = (%d,%d), which is not equal to the " |
| 1660 | "currentExtent = (%d,%d) returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR().", |
| 1661 | pCreateInfo->imageExtent.width, pCreateInfo->imageExtent.height, |
| 1662 | pCapabilities->currentExtent.width, pCapabilities->currentExtent.height); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1663 | } |
| 1664 | // Validate pCreateInfo->preTransform has one bit set (1st two |
| 1665 | // lines of if-statement), which bit is also set in |
| 1666 | // VkSurfaceCapabilitiesKHR::supportedTransforms (3rd line of if-statement): |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1667 | if (!pCreateInfo->preTransform || (pCreateInfo->preTransform & (pCreateInfo->preTransform - 1)) || |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1668 | !(pCreateInfo->preTransform & pCapabilities->supportedTransforms)) { |
| 1669 | // This is an error situation; one for which we'd like to give |
| 1670 | // the developer a helpful, multi-line error message. Build it |
| 1671 | // up a little at a time, and then log it: |
| 1672 | std::string errorString = ""; |
| 1673 | char str[1024]; |
| 1674 | // Here's the first part of the message: |
| 1675 | sprintf(str, "%s() called with a non-supported " |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1676 | "pCreateInfo->preTransform (i.e. %s). " |
| 1677 | "Supported values are:\n", |
| 1678 | fn, surfaceTransformStr(pCreateInfo->preTransform)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1679 | errorString += str; |
| 1680 | for (int i = 0; i < 32; i++) { |
| 1681 | // Build up the rest of the message: |
| 1682 | if ((1 << i) & pCapabilities->supportedTransforms) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1683 | const char *newStr = surfaceTransformStr((VkSurfaceTransformFlagBitsKHR)(1 << i)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1684 | sprintf(str, " %s\n", newStr); |
| 1685 | errorString += str; |
| 1686 | } |
| 1687 | } |
| 1688 | // Log the message that we've built up: |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1689 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1690 | reinterpret_cast<uint64_t &>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_PRE_TRANSFORM, |
| 1691 | LAYER_NAME, "%s", errorString.c_str()); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1692 | } |
| 1693 | // Validate pCreateInfo->compositeAlpha has one bit set (1st two |
| 1694 | // lines of if-statement), which bit is also set in |
| 1695 | // VkSurfaceCapabilitiesKHR::supportedCompositeAlpha (3rd line of if-statement): |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1696 | if (!pCreateInfo->compositeAlpha || (pCreateInfo->compositeAlpha & (pCreateInfo->compositeAlpha - 1)) || |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1697 | !((pCreateInfo->compositeAlpha) & pCapabilities->supportedCompositeAlpha)) { |
| 1698 | // This is an error situation; one for which we'd like to give |
| 1699 | // the developer a helpful, multi-line error message. Build it |
| 1700 | // up a little at a time, and then log it: |
| 1701 | std::string errorString = ""; |
| 1702 | char str[1024]; |
| 1703 | // Here's the first part of the message: |
| 1704 | sprintf(str, "%s() called with a non-supported " |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1705 | "pCreateInfo->compositeAlpha (i.e. %s). " |
| 1706 | "Supported values are:\n", |
| 1707 | fn, surfaceCompositeAlphaStr(pCreateInfo->compositeAlpha)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1708 | errorString += str; |
| 1709 | for (int i = 0; i < 32; i++) { |
| 1710 | // Build up the rest of the message: |
| 1711 | if ((1 << i) & pCapabilities->supportedCompositeAlpha) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1712 | const char *newStr = surfaceCompositeAlphaStr((VkCompositeAlphaFlagBitsKHR)(1 << i)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1713 | sprintf(str, " %s\n", newStr); |
| 1714 | errorString += str; |
| 1715 | } |
| 1716 | } |
| 1717 | // Log the message that we've built up: |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1718 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1719 | reinterpret_cast<uint64_t &>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_COMPOSITE_ALPHA, |
| 1720 | LAYER_NAME, "%s", errorString.c_str()); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1721 | } |
David McFarland | e22cfb0 | 2016-05-20 18:26:28 -0300 | [diff] [blame] | 1722 | // Validate pCreateInfo->imageArrayLayers against |
| 1723 | // VkSurfaceCapabilitiesKHR::maxImageArrayLayers: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1724 | if ((pCreateInfo->imageArrayLayers < 1) || (pCreateInfo->imageArrayLayers > pCapabilities->maxImageArrayLayers)) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1725 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1726 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_IMG_ARRAY_LAYERS, |
| 1727 | swapchain_layer_name, |
| 1728 | "vkCreateSwapchainKHR() called with a non-supported pCreateInfo->imageArrayLayers (i.e. %d). " |
| 1729 | "Minimum value is 1, maximum value is %d.", |
| 1730 | pCreateInfo->imageArrayLayers, pCapabilities->maxImageArrayLayers); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1731 | } |
| 1732 | // Validate pCreateInfo->imageUsage against |
| 1733 | // VkSurfaceCapabilitiesKHR::supportedUsageFlags: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1734 | if (pCreateInfo->imageUsage != (pCreateInfo->imageUsage & pCapabilities->supportedUsageFlags)) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1735 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1736 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_IMG_USAGE_FLAGS, |
| 1737 | swapchain_layer_name, |
| 1738 | "vkCreateSwapchainKHR() called with a non-supported pCreateInfo->imageUsage (i.e. 0x%08x). " |
| 1739 | "Supported flag bits are 0x%08x.", |
| 1740 | pCreateInfo->imageUsage, pCapabilities->supportedUsageFlags); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1741 | } |
| 1742 | } |
Ian Elliott | f7f8ff0 | 2015-12-30 14:55:41 -0700 | [diff] [blame] | 1743 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1744 | // Validate pCreateInfo values with the results of |
| 1745 | // vkGetPhysicalDeviceSurfaceFormatsKHR(): |
| 1746 | if (!pPhysicalDevice || !pPhysicalDevice->surfaceFormatCount) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1747 | skip_call |= |
| 1748 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1749 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, swapchain_layer_name, |
| 1750 | "vkCreateSwapchainKHR() called before calling vkGetPhysicalDeviceSurfaceFormatsKHR()."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1751 | } else if (pCreateInfo) { |
| 1752 | // Validate pCreateInfo->imageFormat against |
| 1753 | // VkSurfaceFormatKHR::format: |
| 1754 | bool foundFormat = false; |
| 1755 | bool foundColorSpace = false; |
| 1756 | bool foundMatch = false; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1757 | for (uint32_t i = 0; i < pPhysicalDevice->surfaceFormatCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1758 | if (pCreateInfo->imageFormat == pPhysicalDevice->pSurfaceFormats[i].format) { |
| 1759 | // Validate pCreateInfo->imageColorSpace against |
| 1760 | // VkSurfaceFormatKHR::colorSpace: |
| 1761 | foundFormat = true; |
| 1762 | if (pCreateInfo->imageColorSpace == pPhysicalDevice->pSurfaceFormats[i].colorSpace) { |
| 1763 | foundMatch = true; |
| 1764 | break; |
| 1765 | } |
| 1766 | } else { |
| 1767 | if (pCreateInfo->imageColorSpace == pPhysicalDevice->pSurfaceFormats[i].colorSpace) { |
| 1768 | foundColorSpace = true; |
| 1769 | } |
| 1770 | } |
| 1771 | } |
| 1772 | if (!foundMatch) { |
| 1773 | if (!foundFormat) { |
| 1774 | if (!foundColorSpace) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1775 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1776 | VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, reinterpret_cast<uint64_t>(device), __LINE__, |
| 1777 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_FMT_CLR_SP, swapchain_layer_name, |
| 1778 | "vkCreateSwapchainKHR() called with neither a supported pCreateInfo->imageFormat " |
| 1779 | "(i.e. %d) nor a supported " |
| 1780 | "pCreateInfo->imageColorSpace (i.e. %d).", |
| 1781 | pCreateInfo->imageFormat, pCreateInfo->imageColorSpace); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1782 | } else { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1783 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1784 | VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, reinterpret_cast<uint64_t>(device), __LINE__, |
| 1785 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_FORMAT, swapchain_layer_name, |
| 1786 | "vkCreateSwapchainKHR() called with a non-supported pCreateInfo->imageFormat (i.e. %d)", |
| 1787 | pCreateInfo->imageFormat); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1788 | } |
| 1789 | } else if (!foundColorSpace) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1790 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1791 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_IMG_COLOR_SPACE, |
| 1792 | swapchain_layer_name, |
| 1793 | "vkCreateSwapchainKHR() called with a non-supported pCreateInfo->imageColorSpace (i.e. %d).", |
| 1794 | pCreateInfo->imageColorSpace); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1795 | } |
| 1796 | } |
| 1797 | } |
Ian Elliott | f7f8ff0 | 2015-12-30 14:55:41 -0700 | [diff] [blame] | 1798 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1799 | // Validate pCreateInfo values with the results of |
| 1800 | // vkGetPhysicalDeviceSurfacePresentModesKHR(): |
| 1801 | if (!pPhysicalDevice || !pPhysicalDevice->presentModeCount) { |
szdarkhack | fb287d3 | 2016-03-12 18:41:19 +0200 | [diff] [blame] | 1802 | if (!pCreateInfo || (pCreateInfo->presentMode != VK_PRESENT_MODE_FIFO_KHR)) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1803 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1804 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, |
| 1805 | swapchain_layer_name, "vkCreateSwapchainKHR() called before calling " |
| 1806 | "vkGetPhysicalDeviceSurfacePresentModesKHR()."); |
szdarkhack | fb287d3 | 2016-03-12 18:41:19 +0200 | [diff] [blame] | 1807 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1808 | } else if (pCreateInfo) { |
| 1809 | // Validate pCreateInfo->presentMode against |
| 1810 | // vkGetPhysicalDeviceSurfacePresentModesKHR(): |
| 1811 | bool foundMatch = false; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1812 | for (uint32_t i = 0; i < pPhysicalDevice->presentModeCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1813 | if (pPhysicalDevice->pPresentModes[i] == pCreateInfo->presentMode) { |
| 1814 | foundMatch = true; |
| 1815 | break; |
| 1816 | } |
| 1817 | } |
| 1818 | if (!foundMatch) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1819 | skip_call |= |
| 1820 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1821 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_PRESENT_MODE, swapchain_layer_name, |
| 1822 | "vkCreateSwapchainKHR() called with a non-supported pCreateInfo->presentMode (i.e. %s).", |
| 1823 | presentModeStr(pCreateInfo->presentMode)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1824 | } |
| 1825 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1826 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1827 | // Validate pCreateInfo->imageSharingMode and related values: |
| 1828 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1829 | if ((pCreateInfo->queueFamilyIndexCount <= 1) || !pCreateInfo->pQueueFamilyIndices) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1830 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1831 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_SHARING_VALUES, |
| 1832 | swapchain_layer_name, |
| 1833 | "vkCreateSwapchainKHR() called with a supported pCreateInfo->sharingMode of (i.e. %s), but with a " |
| 1834 | "bad value(s) for pCreateInfo->queueFamilyIndexCount or pCreateInfo->pQueueFamilyIndices).", |
| 1835 | sharingModeStr(pCreateInfo->imageSharingMode)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1836 | } |
| 1837 | } else if (pCreateInfo->imageSharingMode != VK_SHARING_MODE_EXCLUSIVE) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1838 | skip_call |= |
| 1839 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1840 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_BAD_SHARING_MODE, swapchain_layer_name, |
| 1841 | "vkCreateSwapchainKHR() called with a non-supported pCreateInfo->imageSharingMode (i.e. %s).", |
| 1842 | sharingModeStr(pCreateInfo->imageSharingMode)); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1843 | } |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1844 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1845 | // Validate pCreateInfo->clipped: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1846 | if (pCreateInfo && (pCreateInfo->clipped != VK_FALSE) && (pCreateInfo->clipped != VK_TRUE)) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1847 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1848 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_BAD_BOOL, swapchain_layer_name, |
| 1849 | "vkCreateSwapchainKHR() called with a VkBool32 value that is neither VK_TRUE nor VK_FALSE, but " |
| 1850 | "has the numeric value of %d.", |
| 1851 | pCreateInfo->clipped); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1852 | } |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 1853 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1854 | // Validate pCreateInfo->oldSwapchain: |
| 1855 | if (pCreateInfo && pCreateInfo->oldSwapchain) { |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1856 | SwpSwapchain *pOldSwapchain = NULL; |
| 1857 | { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1858 | auto it = my_data->swapchainMap.find(pCreateInfo->oldSwapchain); |
| 1859 | pOldSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1860 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1861 | if (pOldSwapchain) { |
| 1862 | if (device != pOldSwapchain->pDevice->device) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1863 | skip_call |= |
| 1864 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1865 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_DESTROY_SWAP_DIFF_DEVICE, swapchain_layer_name, |
| 1866 | "vkCreateSwapchainKHR() called with a different VkDevice than the VkSwapchainKHR was created with."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1867 | } |
| 1868 | if (pCreateInfo->surface != pOldSwapchain->pSurface->surface) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1869 | skip_call |= |
| 1870 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1871 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_CREATE_SWAP_DIFF_SURFACE, swapchain_layer_name, |
| 1872 | "vkCreateSwapchainKHR() called with pCreateInfo->oldSwapchain pCreateInfo->surface."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1873 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1874 | } |
| 1875 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1876 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1877 | return skip_call; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1878 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1879 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 1880 | VKAPI_ATTR VkResult VKAPI_CALL CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1881 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1882 | VkResult result = VK_SUCCESS; |
| 1883 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1884 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1885 | bool skip_call = validateCreateSwapchainKHR(device, pCreateInfo, pSwapchain); |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1886 | lock.unlock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1887 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1888 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1889 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1890 | result = my_data->device_dispatch_table->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1891 | lock.lock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1892 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1893 | if (result == VK_SUCCESS) { |
| 1894 | // Remember the swapchain's handle, and link it to the device: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1895 | SwpDevice *pDevice = NULL; |
| 1896 | { |
| 1897 | auto it = my_data->deviceMap.find(device); |
| 1898 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 1899 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1900 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1901 | my_data->swapchainMap[*pSwapchain].swapchain = *pSwapchain; |
| 1902 | if (pDevice) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1903 | pDevice->swapchains[*pSwapchain] = &my_data->swapchainMap[*pSwapchain]; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1904 | } |
| 1905 | my_data->swapchainMap[*pSwapchain].pDevice = pDevice; |
| 1906 | my_data->swapchainMap[*pSwapchain].imageCount = 0; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1907 | my_data->swapchainMap[*pSwapchain].usedAllocatorToCreate = (pAllocator != NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1908 | // Store a pointer to the surface |
| 1909 | SwpPhysicalDevice *pPhysicalDevice = pDevice->pPhysicalDevice; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1910 | SwpInstance *pInstance = (pPhysicalDevice) ? pPhysicalDevice->pInstance : NULL; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1911 | layer_data *my_instance_data = |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1912 | ((pInstance) ? get_my_data_ptr(get_dispatch_key(pInstance->instance), layer_data_map) : NULL); |
| 1913 | SwpSurface *pSurface = ((my_data && pCreateInfo) ? &my_instance_data->surfaceMap[pCreateInfo->surface] : NULL); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1914 | my_data->swapchainMap[*pSwapchain].pSurface = pSurface; |
| 1915 | if (pSurface) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1916 | pSurface->swapchains[*pSwapchain] = &my_data->swapchainMap[*pSwapchain]; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1917 | } |
| 1918 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 1919 | lock.unlock(); |
| 1920 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1921 | return result; |
| 1922 | } |
| 1923 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1924 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1925 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1926 | VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1927 | // TODOs: |
| 1928 | // |
| 1929 | // - Implement a check for validity language that reads: All uses of |
Ian Elliott | a5d13a9 | 2016-04-07 09:05:45 -0600 | [diff] [blame] | 1930 | // presentable images acquired from pname:swapchain must: have completed |
| 1931 | // execution |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1932 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1933 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1934 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1935 | SwpDevice *pDevice = NULL; |
| 1936 | { |
| 1937 | auto it = my_data->deviceMap.find(device); |
| 1938 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 1939 | } |
Ian Elliott | 8b9e256 | 2016-01-05 13:00:50 -0700 | [diff] [blame] | 1940 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1941 | // Validate that the swapchain extension was enabled: |
| 1942 | if (pDevice && !pDevice->swapchainExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1943 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1944 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 1945 | "vkDestroySwapchainKHR() called even though the %s extension was not enabled for this VkDevice.", |
| 1946 | VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1947 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1948 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1949 | // Regardless of skip_call value, do some internal cleanup: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1950 | SwpSwapchain *pSwapchain = NULL; |
| 1951 | { |
| 1952 | auto it = my_data->swapchainMap.find(swapchain); |
| 1953 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 1954 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1955 | if (pSwapchain) { |
| 1956 | // Delete the SwpSwapchain associated with this swapchain: |
| 1957 | if (pSwapchain->pDevice) { |
| 1958 | pSwapchain->pDevice->swapchains.erase(swapchain); |
| 1959 | if (device != pSwapchain->pDevice->device) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1960 | skip_call |= |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1961 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1962 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_DESTROY_SWAP_DIFF_DEVICE, swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 1963 | "vkDestroySwapchainKHR() called with a different VkDevice than the VkSwapchainKHR was created with."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1964 | } |
| 1965 | } |
| 1966 | if (pSwapchain->pSurface) { |
| 1967 | pSwapchain->pSurface->swapchains.erase(swapchain); |
| 1968 | } |
| 1969 | if (pSwapchain->imageCount) { |
| 1970 | pSwapchain->images.clear(); |
| 1971 | } |
| 1972 | if ((pAllocator != NULL) != pSwapchain->usedAllocatorToCreate) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1973 | skip_call |= |
| 1974 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 1975 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INCOMPATIBLE_ALLOCATOR, swapchain_layer_name, |
| 1976 | "vkDestroySwapchainKHR() called with incompatible pAllocator from when the object was created."); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1977 | } |
| 1978 | my_data->swapchainMap.erase(swapchain); |
| 1979 | } |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1980 | lock.unlock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1981 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1982 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1983 | // Call down the call chain: |
| 1984 | my_data->device_dispatch_table->DestroySwapchainKHR(device, swapchain, pAllocator); |
| 1985 | } |
| 1986 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1987 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 1988 | VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 1989 | VkImage *pSwapchainImages) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1990 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 1991 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1992 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 1993 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 1994 | SwpDevice *pDevice = NULL; |
| 1995 | { |
| 1996 | auto it = my_data->deviceMap.find(device); |
| 1997 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 1998 | } |
Ian Elliott | 8b9e256 | 2016-01-05 13:00:50 -0700 | [diff] [blame] | 1999 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2000 | // Validate that the swapchain extension was enabled: |
| 2001 | if (pDevice && !pDevice->swapchainExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2002 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2003 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 2004 | "vkGetSwapchainImagesKHR() called even though the %s extension was not enabled for this VkDevice.", |
| 2005 | VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2006 | } |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2007 | SwpSwapchain *pSwapchain = NULL; |
| 2008 | { |
| 2009 | auto it = my_data->swapchainMap.find(swapchain); |
| 2010 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 2011 | } |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 2012 | if (pSwapchain && pSwapchainImages) { |
| 2013 | // Compare the preliminary value of *pSwapchainImageCount with the value this time: |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 2014 | if (pSwapchain->imageCount == 0) { |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 2015 | // Since we haven't recorded a preliminary value of *pSwapchainImageCount, that likely means that the application didn't |
| 2016 | // previously call this function with a NULL value of pSwapchainImages: |
Mark Lobodzinski | 6a7e933 | 2016-08-16 09:06:15 -0600 | [diff] [blame] | 2017 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2018 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_PRIOR_COUNT, swapchain_layer_name, |
| 2019 | "vkGetSwapchainImagesKHR() called with non-NULL pSwapchainImageCount; but no prior positive " |
| 2020 | "value has been seen for pSwapchainImages."); |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 2021 | } else if (*pSwapchainImageCount > pSwapchain->imageCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2022 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2023 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INVALID_COUNT, swapchain_layer_name, |
| 2024 | "vkGetSwapchainImagesKHR() called with non-NULL pSwapchainImageCount, and with " |
| 2025 | "pSwapchainImages set to a value (%d) that is greater than the value (%d) that was returned when " |
| 2026 | "pSwapchainImageCount was NULL.", |
| 2027 | *pSwapchainImageCount, pSwapchain->imageCount); |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 2028 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2029 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 2030 | lock.unlock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2031 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2032 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2033 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2034 | result = my_data->device_dispatch_table->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2035 | lock.lock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2036 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 2037 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2038 | { |
| 2039 | auto it = my_data->swapchainMap.find(swapchain); |
| 2040 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 2041 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2042 | if ((result == VK_SUCCESS) && pSwapchain && !pSwapchainImages && pSwapchainImageCount) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2043 | // Record the result of this preliminary query: |
| 2044 | pSwapchain->imageCount = *pSwapchainImageCount; |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2045 | } else if ((result == VK_SUCCESS) && pSwapchain && pSwapchainImages && pSwapchainImageCount && |
| 2046 | (*pSwapchainImageCount > 0)) { |
Ian Elliott | fdf3ffa | 2016-05-05 14:06:53 -0600 | [diff] [blame] | 2047 | // Record the images and their state: |
| 2048 | pSwapchain->imageCount = *pSwapchainImageCount; |
| 2049 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 2050 | pSwapchain->images[i].image = pSwapchainImages[i]; |
| 2051 | pSwapchain->images[i].pSwapchain = pSwapchain; |
| 2052 | pSwapchain->images[i].acquiredByApp = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2053 | } |
| 2054 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 2055 | lock.unlock(); |
| 2056 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2057 | return result; |
| 2058 | } |
| 2059 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 2060 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2061 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2062 | VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 2063 | VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2064 | // TODOs: |
| 2065 | // |
| 2066 | // - Address the timeout. Possibilities include looking at the state of the |
| 2067 | // swapchain's images, depending on the timeout value. |
| 2068 | // - Implement a check for validity language that reads: If pname:semaphore is |
| 2069 | // not sname:VK_NULL_HANDLE it must: be unsignalled |
| 2070 | // - Implement a check for validity language that reads: If pname:fence is not |
| 2071 | // sname:VK_NULL_HANDLE it must: be unsignalled and mustnot: be associated |
| 2072 | // with any other queue command that has not yet completed execution on that |
| 2073 | // queue |
| 2074 | // - Record/update the state of the swapchain, in case an error occurs |
| 2075 | // (e.g. VK_ERROR_OUT_OF_DATE_KHR). |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2076 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2077 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2078 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2079 | std::unique_lock<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2080 | SwpDevice *pDevice = NULL; |
| 2081 | { |
| 2082 | auto it = my_data->deviceMap.find(device); |
| 2083 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 2084 | } |
Ian Elliott | 8b9e256 | 2016-01-05 13:00:50 -0700 | [diff] [blame] | 2085 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2086 | // Validate that the swapchain extension was enabled: |
| 2087 | if (pDevice && !pDevice->swapchainExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2088 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2089 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 2090 | "vkAcquireNextImageKHR() called even though the %s extension was not enabled for this VkDevice.", |
| 2091 | VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2092 | } |
Ian Elliott | fa8f032 | 2016-03-23 08:28:54 -0600 | [diff] [blame] | 2093 | if ((semaphore == VK_NULL_HANDLE) && (fence == VK_NULL_HANDLE)) { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2094 | skip_call |= |
| 2095 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2096 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_NO_SYNC_FOR_ACQUIRE, swapchain_layer_name, |
| 2097 | "vkAcquireNextImageKHR() called with both the semaphore and fence parameters set to VK_NULL_HANDLE (at " |
| 2098 | "least one should be used)."); |
Ian Elliott | fa8f032 | 2016-03-23 08:28:54 -0600 | [diff] [blame] | 2099 | } |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2100 | SwpSwapchain *pSwapchain = NULL; |
| 2101 | { |
| 2102 | auto it = my_data->swapchainMap.find(swapchain); |
| 2103 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 2104 | } |
Ian Elliott | 5c68028 | 2016-04-06 14:29:56 -0600 | [diff] [blame] | 2105 | SwpPhysicalDevice *pPhysicalDevice = pDevice->pPhysicalDevice; |
| 2106 | if (pSwapchain && pPhysicalDevice && pPhysicalDevice->gotSurfaceCapabilities) { |
| 2107 | // Look to see if the application has already acquired the maximum |
| 2108 | // number of images, and this will push it past the spec-defined |
| 2109 | // limits: |
| 2110 | uint32_t minImageCount = pPhysicalDevice->surfaceCapabilities.minImageCount; |
| 2111 | uint32_t imagesAcquiredByApp = 0; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2112 | for (uint32_t i = 0; i < pSwapchain->imageCount; i++) { |
Ian Elliott | a5d13a9 | 2016-04-07 09:05:45 -0600 | [diff] [blame] | 2113 | if (pSwapchain->images[i].acquiredByApp) { |
Ian Elliott | 5c68028 | 2016-04-06 14:29:56 -0600 | [diff] [blame] | 2114 | imagesAcquiredByApp++; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2115 | } |
| 2116 | } |
Ian Elliott | 5c68028 | 2016-04-06 14:29:56 -0600 | [diff] [blame] | 2117 | if (imagesAcquiredByApp > (pSwapchain->imageCount - minImageCount)) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2118 | skip_call |= log_msg( |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2119 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2120 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_APP_ACQUIRES_TOO_MANY_IMAGES, swapchain_layer_name, |
| 2121 | "vkAcquireNextImageKHR() called when it cannot succeed. The application has acquired %d image(s) that have not " |
| 2122 | "yet " |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 2123 | "been presented. The maximum number of images that the application can simultaneously acquire from this swapchain " |
| 2124 | "(including this call to vkCreateSwapchainKHR()) is %d. That value is derived by subtracting " |
| 2125 | "VkSurfaceCapabilitiesKHR::minImageCount (%d) from the number of images in the swapchain (%d) and adding 1.", |
| 2126 | imagesAcquiredByApp, (pSwapchain->imageCount - minImageCount + 1), minImageCount, pSwapchain->imageCount); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2127 | } |
| 2128 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 2129 | lock.unlock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2130 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2131 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2132 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2133 | result = my_data->device_dispatch_table->AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2134 | lock.lock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2135 | |
Ian Elliott | 3231183 | 2016-02-04 08:17:18 -0700 | [diff] [blame] | 2136 | // Obtain this pointer again after locking: |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2137 | { |
| 2138 | auto it = my_data->swapchainMap.find(swapchain); |
| 2139 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 2140 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2141 | if (((result == VK_SUCCESS) || (result == VK_SUBOPTIMAL_KHR)) && pSwapchain) { |
Ian Elliott | a5d13a9 | 2016-04-07 09:05:45 -0600 | [diff] [blame] | 2142 | // Change the state of the image (now acquired by the application): |
| 2143 | pSwapchain->images[*pImageIndex].acquiredByApp = true; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2144 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 2145 | lock.unlock(); |
| 2146 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2147 | return result; |
| 2148 | } |
| 2149 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 2150 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2151 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2152 | VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2153 | // TODOs: |
| 2154 | // |
| 2155 | // - Implement a check for validity language that reads: Any given element of |
| 2156 | // sname:VkSemaphore in pname:pWaitSemaphores must: refer to a prior signal |
| 2157 | // of that sname:VkSemaphore that won't be consumed by any other wait on that |
| 2158 | // semaphore |
| 2159 | // - Record/update the state of the swapchain, in case an error occurs |
| 2160 | // (e.g. VK_ERROR_OUT_OF_DATE_KHR). |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2161 | VkResult result = VK_SUCCESS; |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2162 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2163 | 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] | 2164 | |
Mark Lobodzinski | 0f73c0b | 2016-08-08 09:57:09 -0600 | [diff] [blame] | 2165 | // Note: pPresentInfo->pResults is allowed to be NULL |
Ian Elliott | 046ed2c | 2015-12-30 17:07:17 -0700 | [diff] [blame] | 2166 | |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2167 | std::unique_lock<std::mutex> lock(global_lock); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2168 | for (uint32_t i = 0; pPresentInfo && (i < pPresentInfo->swapchainCount); i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2169 | uint32_t index = pPresentInfo->pImageIndices[i]; |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2170 | SwpSwapchain *pSwapchain = NULL; |
| 2171 | { |
| 2172 | auto it = my_data->swapchainMap.find(pPresentInfo->pSwapchains[i]); |
| 2173 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 2174 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2175 | if (pSwapchain) { |
| 2176 | if (!pSwapchain->pDevice->swapchainExtensionEnabled) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2177 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2178 | reinterpret_cast<uint64_t>(pSwapchain->pDevice->device), __LINE__, |
| 2179 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 2180 | "vkQueuePresentKHR() called even though the %s extension was not enabled for this VkDevice.", |
| 2181 | VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2182 | } |
| 2183 | if (index >= pSwapchain->imageCount) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2184 | skip_call |= |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 2185 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2186 | reinterpret_cast<const uint64_t &>(pPresentInfo->pSwapchains[i]), __LINE__, SWAPCHAIN_INDEX_TOO_LARGE, |
| 2187 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 2188 | "vkQueuePresentKHR() called for an index that is too large (i.e. %d). There are only %d images in " |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2189 | "this VkSwapchainKHR.", |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 2190 | index, pSwapchain->imageCount); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2191 | } else { |
Ian Elliott | a5d13a9 | 2016-04-07 09:05:45 -0600 | [diff] [blame] | 2192 | if (!pSwapchain->images[index].acquiredByApp) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2193 | skip_call |= log_msg( |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 2194 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2195 | reinterpret_cast<const uint64_t &>(pPresentInfo->pSwapchains[i]), __LINE__, SWAPCHAIN_INDEX_NOT_IN_USE, |
| 2196 | swapchain_layer_name, |
Mark Lobodzinski | 9b482fa | 2016-08-08 09:38:42 -0600 | [diff] [blame] | 2197 | "vkQueuePresentKHR() returned an index (i.e. %d) for an image that is not acquired by the application.", |
| 2198 | index); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2199 | } |
| 2200 | } |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2201 | SwpQueue *pQueue = NULL; |
| 2202 | { |
| 2203 | auto it = my_data->queueMap.find(queue); |
| 2204 | pQueue = (it == my_data->queueMap.end()) ? NULL : &it->second; |
| 2205 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2206 | SwpSurface *pSurface = pSwapchain->pSurface; |
| 2207 | if (pQueue && pSurface && pSurface->numQueueFamilyIndexSupport) { |
| 2208 | uint32_t queueFamilyIndex = pQueue->queueFamilyIndex; |
| 2209 | // Note: the 1st test is to ensure queueFamilyIndex is in range, |
| 2210 | // and the 2nd test is the validation check: |
| 2211 | if ((pSurface->numQueueFamilyIndexSupport > queueFamilyIndex) && |
| 2212 | (!pSurface->pQueueFamilyIndexSupport[queueFamilyIndex])) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2213 | skip_call |= |
| 2214 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, |
| 2215 | reinterpret_cast<const uint64_t &>(pPresentInfo->pSwapchains[i]), __LINE__, |
| 2216 | SWAPCHAIN_SURFACE_NOT_SUPPORTED_WITH_QUEUE, swapchain_layer_name, |
| 2217 | "vkQueuePresentKHR() called with a swapchain whose surface is not supported for presention " |
| 2218 | "on this device with the queueFamilyIndex (i.e. %d) of the given queue.", |
| 2219 | queueFamilyIndex); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2220 | } |
| 2221 | } |
| 2222 | } |
| 2223 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 2224 | lock.unlock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2225 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2226 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2227 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2228 | result = my_data->device_dispatch_table->QueuePresentKHR(queue, pPresentInfo); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2229 | lock.lock(); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2230 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2231 | if (pPresentInfo && ((result == VK_SUCCESS) || (result == VK_SUBOPTIMAL_KHR))) { |
| 2232 | for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2233 | int index = pPresentInfo->pImageIndices[i]; |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2234 | SwpSwapchain *pSwapchain = NULL; |
| 2235 | { |
| 2236 | auto it = my_data->swapchainMap.find(pPresentInfo->pSwapchains[i]); |
| 2237 | pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; |
| 2238 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2239 | if (pSwapchain) { |
Ian Elliott | a5d13a9 | 2016-04-07 09:05:45 -0600 | [diff] [blame] | 2240 | // Change the state of the image (no longer acquired by the |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2241 | // application): |
Ian Elliott | a5d13a9 | 2016-04-07 09:05:45 -0600 | [diff] [blame] | 2242 | pSwapchain->images[index].acquiredByApp = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2243 | } |
| 2244 | } |
| 2245 | } |
Ian Elliott | 970a2bd | 2016-06-21 11:08:43 -0600 | [diff] [blame] | 2246 | lock.unlock(); |
| 2247 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2248 | return result; |
| 2249 | } |
| 2250 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 2251 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2252 | |
Mark Young | 1a86744 | 2016-07-01 15:18:27 -0600 | [diff] [blame^] | 2253 | VKAPI_ATTR VkResult VKAPI_CALL CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 2254 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 2255 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) { |
| 2256 | VkResult result = VK_SUCCESS; |
| 2257 | bool skip_call = false; |
| 2258 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 2259 | std::unique_lock<std::mutex> lock(global_lock); |
| 2260 | SwpDevice *pDevice = nullptr; |
| 2261 | { |
| 2262 | auto it = my_data->deviceMap.find(device); |
| 2263 | pDevice = (it == my_data->deviceMap.end()) ? nullptr : &it->second; |
| 2264 | } |
| 2265 | |
| 2266 | // Validate that the swapchain extension was enabled: |
| 2267 | if (pDevice && !pDevice->displaySwapchainExtensionEnabled) { |
| 2268 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2269 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, |
| 2270 | "vkCreateSharedSwapchainsKHR() called even though the %s extension was not enabled for this VkDevice.", |
| 2271 | VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME); |
| 2272 | } |
| 2273 | if (!pCreateInfos || !pSwapchains) { |
| 2274 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2275 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_NULL_POINTER, swapchain_layer_name, |
| 2276 | "vkCreateSharedSwapchainsKHR() called with NULL pointer"); |
| 2277 | } |
| 2278 | if (swapchainCount == 0) { |
| 2279 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2280 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INVALID_COUNT, swapchain_layer_name, |
| 2281 | "vkCreateSharedSwapchainsKHR() called with invalid swapchain count of %d.", swapchainCount); |
| 2282 | } else { |
| 2283 | SwpSwapchain *pSwapchain = nullptr; |
| 2284 | for (uint32_t iii = 0; iii < swapchainCount; iii++) { |
| 2285 | if (pCreateInfos[iii].sType != VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR) { |
| 2286 | skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2287 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_WRONG_STYPE, swapchain_layer_name, |
| 2288 | "vkCreateSharedSwapchainsKHR() called with invalid stype in pCreateInfos[%d].", iii); |
| 2289 | } |
| 2290 | auto it = my_data->swapchainMap.find(pSwapchains[iii]); |
| 2291 | pSwapchain = (it == my_data->swapchainMap.end()) ? nullptr : &it->second; |
| 2292 | if (nullptr == pSwapchain) { |
| 2293 | skip_call |= |
| 2294 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 2295 | reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INVALID_HANDLE, swapchain_layer_name, |
| 2296 | "vkCreateSharedSwapchainsKHR() called with invalid Swapchain Handle in pCreateInfos[%d].", iii); |
| 2297 | } |
| 2298 | } |
| 2299 | } |
| 2300 | lock.unlock(); |
| 2301 | |
| 2302 | if (!skip_call) { |
| 2303 | // Call down the call chain: |
| 2304 | result = my_data->device_dispatch_table->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, |
| 2305 | pSwapchains); |
| 2306 | return result; |
| 2307 | } |
| 2308 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 2309 | } |
| 2310 | |
| 2311 | VKAPI_ATTR void VKAPI_CALL |
| 2312 | GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2313 | bool skip_call = false; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2314 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Ian Elliott | c4db695 | 2016-01-21 14:29:45 -0700 | [diff] [blame] | 2315 | |
Mark Lobodzinski | 38ece43 | 2016-08-08 14:36:58 -0600 | [diff] [blame] | 2316 | if (!skip_call) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2317 | // Call down the call chain: |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2318 | my_data->device_dispatch_table->GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
Ian Elliott | c4db695 | 2016-01-21 14:29:45 -0700 | [diff] [blame] | 2319 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2320 | // Remember the queue's handle, and link it to the device: |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2321 | std::lock_guard<std::mutex> lock(global_lock); |
Ian Elliott | 77f46ca | 2016-05-05 14:10:49 -0600 | [diff] [blame] | 2322 | SwpDevice *pDevice = NULL; |
| 2323 | { |
| 2324 | auto it = my_data->deviceMap.find(device); |
| 2325 | pDevice = (it == my_data->deviceMap.end()) ? NULL : &it->second; |
| 2326 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2327 | my_data->queueMap[&pQueue].queue = *pQueue; |
| 2328 | if (pDevice) { |
| 2329 | pDevice->queues[*pQueue] = &my_data->queueMap[*pQueue]; |
| 2330 | } |
| 2331 | my_data->queueMap[&pQueue].pDevice = pDevice; |
| 2332 | my_data->queueMap[&pQueue].queueFamilyIndex = queueFamilyIndex; |
| 2333 | } |
| 2334 | } |
Ian Elliott | c4db695 | 2016-01-21 14:29:45 -0700 | [diff] [blame] | 2335 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2336 | VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance, |
| 2337 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 2338 | const VkAllocationCallbacks *pAllocator, |
| 2339 | VkDebugReportCallbackEXT *pMsgCallback) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2340 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2341 | VkResult result = |
| 2342 | my_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2343 | if (VK_SUCCESS == result) { |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2344 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | 97c4d51 | 2016-05-19 15:27:18 -0600 | [diff] [blame] | 2345 | result = layer_create_msg_callback(my_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2346 | } |
| 2347 | return result; |
| 2348 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2349 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2350 | VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2351 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2352 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 2353 | my_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Jeremy Hayes | 9de0bd7 | 2016-04-13 11:57:20 -0600 | [diff] [blame] | 2354 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2355 | layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); |
| 2356 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2357 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2358 | VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, |
| 2359 | VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, |
| 2360 | int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2361 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2362 | my_data->instance_dispatch_table->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, |
| 2363 | pMsg); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2364 | } |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 2365 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2366 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2367 | return util_GetLayerProperties(1, &swapchain_layer, pCount, pProperties); |
| 2368 | } |
| 2369 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2370 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 2371 | VkLayerProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2372 | return util_GetLayerProperties(1, &swapchain_layer, pCount, pProperties); |
| 2373 | } |
| 2374 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2375 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 2376 | VkExtensionProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2377 | if (pLayerName && !strcmp(pLayerName, swapchain_layer.layerName)) |
| 2378 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 2379 | |
| 2380 | return VK_ERROR_LAYER_NOT_PRESENT; |
| 2381 | } |
| 2382 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2383 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 2384 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
Chia-I Wu | 2b48125 | 2016-04-28 14:21:13 +0800 | [diff] [blame] | 2385 | if (pLayerName && !strcmp(pLayerName, swapchain_layer.layerName)) |
Chia-I Wu | 045209e | 2016-04-28 11:21:49 +0800 | [diff] [blame] | 2386 | return util_GetExtensionProperties(0, nullptr, pCount, pProperties); |
Chia-I Wu | 2b48125 | 2016-04-28 14:21:13 +0800 | [diff] [blame] | 2387 | |
| 2388 | assert(physicalDevice); |
| 2389 | |
| 2390 | dispatch_key key = get_dispatch_key(physicalDevice); |
| 2391 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 2392 | return my_data->instance_dispatch_table->EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties); |
Chia-I Wu | 045209e | 2016-04-28 11:21:49 +0800 | [diff] [blame] | 2393 | } |
| 2394 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2395 | static PFN_vkVoidFunction intercept_core_instance_command(const char *name); |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2396 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2397 | static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInstance instance); |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2398 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2399 | static PFN_vkVoidFunction intercept_core_device_command(const char *name); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 2400 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2401 | static PFN_vkVoidFunction intercept_khr_swapchain_command(const char *name, VkDevice dev); |
Chia-I Wu | 8324595 | 2016-05-05 16:13:19 +0800 | [diff] [blame] | 2402 | |
Chia-I Wu | 9bc0b58 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2403 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { |
| 2404 | PFN_vkVoidFunction proc = intercept_core_device_command(funcName); |
| 2405 | if (proc) |
| 2406 | return proc; |
| 2407 | |
| 2408 | assert(device); |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2409 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2410 | layer_data *my_data; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2411 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2412 | my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2413 | VkLayerDispatchTable *pDisp = my_data->device_dispatch_table; |
Chia-I Wu | 8324595 | 2016-05-05 16:13:19 +0800 | [diff] [blame] | 2414 | |
| 2415 | proc = intercept_khr_swapchain_command(funcName, device); |
| 2416 | if (proc) |
| 2417 | return proc; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 2418 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2419 | if (pDisp->GetDeviceProcAddr == NULL) |
| 2420 | return NULL; |
| 2421 | return pDisp->GetDeviceProcAddr(device, funcName); |
| 2422 | } |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2423 | |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2424 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2425 | PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); |
Chia-I Wu | 5ae2f65 | 2016-04-28 15:16:59 +0800 | [diff] [blame] | 2426 | if (!proc) |
| 2427 | proc = intercept_core_device_command(funcName); |
| 2428 | if (!proc) |
| 2429 | proc = intercept_khr_swapchain_command(funcName, VK_NULL_HANDLE); |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2430 | if (proc) |
| 2431 | return proc; |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 2432 | |
Chia-I Wu | 5ae2f65 | 2016-04-28 15:16:59 +0800 | [diff] [blame] | 2433 | assert(instance); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2434 | |
| 2435 | layer_data *my_data; |
| 2436 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 2437 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 2438 | |
Chia-I Wu | 5ae2f65 | 2016-04-28 15:16:59 +0800 | [diff] [blame] | 2439 | proc = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
| 2440 | if (!proc) |
| 2441 | proc = intercept_khr_surface_command(funcName, instance); |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2442 | if (proc) |
| 2443 | return proc; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2444 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 2445 | if (pTable->GetInstanceProcAddr == NULL) |
| 2446 | return NULL; |
| 2447 | return pTable->GetInstanceProcAddr(instance, funcName); |
| 2448 | } |
Chia-I Wu | 045209e | 2016-04-28 11:21:49 +0800 | [diff] [blame] | 2449 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2450 | static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2451 | static const struct { |
| 2452 | const char *name; |
| 2453 | PFN_vkVoidFunction proc; |
| 2454 | } core_instance_commands[] = { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2455 | {"vkGetInstanceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr)}, |
| 2456 | {"vkCreateInstance", reinterpret_cast<PFN_vkVoidFunction>(CreateInstance)}, |
| 2457 | {"vkDestroyInstance", reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance)}, |
| 2458 | {"vkCreateDevice", reinterpret_cast<PFN_vkVoidFunction>(CreateDevice)}, |
| 2459 | {"vkEnumeratePhysicalDevices", reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices)}, |
| 2460 | {"vkEnumerateInstanceLayerProperties", reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceLayerProperties)}, |
| 2461 | {"vkEnumerateDeviceLayerProperties", reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceLayerProperties)}, |
| 2462 | {"vkEnumerateInstanceExtensionProperties", reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties)}, |
| 2463 | {"vkEnumerateDeviceExtensionProperties", reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties)}, |
| 2464 | {"vkGetPhysicalDeviceQueueFamilyProperties", reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceQueueFamilyProperties)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2465 | }; |
| 2466 | |
| 2467 | for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { |
| 2468 | if (!strcmp(core_instance_commands[i].name, name)) |
| 2469 | return core_instance_commands[i].proc; |
| 2470 | } |
| 2471 | |
| 2472 | return nullptr; |
| 2473 | } |
| 2474 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2475 | static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInstance instance) { |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2476 | static const struct { |
| 2477 | const char *name; |
| 2478 | PFN_vkVoidFunction proc; |
| 2479 | } khr_surface_commands[] = { |
| 2480 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2481 | {"vkCreateAndroidSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateAndroidSurfaceKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2482 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 2483 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2484 | {"vkCreateMirSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateMirSurfaceKHR)}, |
| 2485 | {"vkGetPhysicalDeviceMirPresentationSupportKHR", |
| 2486 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceMirPresentationSupportKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2487 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 2488 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2489 | {"vkCreateWaylandSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateWaylandSurfaceKHR)}, |
| 2490 | {"vkGetPhysicalDeviceWaylandPresentationSupportKHR", |
| 2491 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceWaylandPresentationSupportKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2492 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 2493 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2494 | {"vkCreateWin32SurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateWin32SurfaceKHR)}, |
| 2495 | {"vkGetPhysicalDeviceWin32PresentationSupportKHR", |
| 2496 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceWin32PresentationSupportKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2497 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 2498 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2499 | {"vkCreateXcbSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateXcbSurfaceKHR)}, |
| 2500 | {"vkGetPhysicalDeviceXcbPresentationSupportKHR", |
| 2501 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceXcbPresentationSupportKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2502 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2503 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2504 | {"vkCreateXlibSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateXlibSurfaceKHR)}, |
| 2505 | {"vkGetPhysicalDeviceXlibPresentationSupportKHR", |
| 2506 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceXlibPresentationSupportKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2507 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2508 | {"vkDestroySurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(DestroySurfaceKHR)}, |
| 2509 | {"vkGetPhysicalDeviceSurfaceSupportKHR", reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceSupportKHR)}, |
| 2510 | {"vkGetPhysicalDeviceSurfaceCapabilitiesKHR", |
| 2511 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceCapabilitiesKHR)}, |
| 2512 | {"vkGetPhysicalDeviceSurfaceFormatsKHR", reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceFormatsKHR)}, |
| 2513 | {"vkGetPhysicalDeviceSurfacePresentModesKHR", |
| 2514 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfacePresentModesKHR)}, |
| 2515 | {"vkGetPhysicalDeviceDisplayPropertiesKHR", reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceDisplayPropertiesKHR)}, |
| 2516 | {"vkGetPhysicalDeviceDisplayPlanePropertiesKHR", |
| 2517 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceDisplayPlanePropertiesKHR)}, |
| 2518 | {"vkGetDisplayPlaneSupportedDisplaysKHR", reinterpret_cast<PFN_vkVoidFunction>(GetDisplayPlaneSupportedDisplaysKHR)}, |
| 2519 | {"vkGetDisplayModePropertiesKHR", reinterpret_cast<PFN_vkVoidFunction>(GetDisplayModePropertiesKHR)}, |
| 2520 | {"vkCreateDisplayModeKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateDisplayModeKHR)}, |
| 2521 | {"vkGetDisplayPlaneCapabilitiesKHR", reinterpret_cast<PFN_vkVoidFunction>(GetDisplayPlaneCapabilitiesKHR)}, |
| 2522 | {"vkCreateDisplayPlaneSurfaceKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateDisplayPlaneSurfaceKHR)}, |
Chia-I Wu | 22813c7 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2523 | }; |
| 2524 | |
| 2525 | // do not check if VK_KHR_*_surface is enabled (why?) |
| 2526 | |
| 2527 | for (size_t i = 0; i < ARRAY_SIZE(khr_surface_commands); i++) { |
| 2528 | if (!strcmp(khr_surface_commands[i].name, name)) |
| 2529 | return khr_surface_commands[i].proc; |
| 2530 | } |
| 2531 | |
| 2532 | return nullptr; |
| 2533 | } |
| 2534 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2535 | static PFN_vkVoidFunction intercept_core_device_command(const char *name) { |
Chia-I Wu | 9bc0b58 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2536 | static const struct { |
| 2537 | const char *name; |
| 2538 | PFN_vkVoidFunction proc; |
| 2539 | } core_device_commands[] = { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2540 | {"vkGetDeviceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr)}, |
| 2541 | {"vkDestroyDevice", reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice)}, |
| 2542 | {"vkGetDeviceQueue", reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue)}, |
Chia-I Wu | 9bc0b58 | 2016-04-28 14:38:57 +0800 | [diff] [blame] | 2543 | }; |
| 2544 | |
| 2545 | for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { |
| 2546 | if (!strcmp(core_device_commands[i].name, name)) |
| 2547 | return core_device_commands[i].proc; |
| 2548 | } |
| 2549 | |
| 2550 | return nullptr; |
| 2551 | } |
| 2552 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2553 | static PFN_vkVoidFunction intercept_khr_swapchain_command(const char *name, VkDevice dev) { |
Chia-I Wu | 8324595 | 2016-05-05 16:13:19 +0800 | [diff] [blame] | 2554 | static const struct { |
| 2555 | const char *name; |
| 2556 | PFN_vkVoidFunction proc; |
| 2557 | } khr_swapchain_commands[] = { |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2558 | {"vkCreateSwapchainKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateSwapchainKHR)}, |
| 2559 | {"vkDestroySwapchainKHR", reinterpret_cast<PFN_vkVoidFunction>(DestroySwapchainKHR)}, |
| 2560 | {"vkGetSwapchainImagesKHR", reinterpret_cast<PFN_vkVoidFunction>(GetSwapchainImagesKHR)}, |
| 2561 | {"vkAcquireNextImageKHR", reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR)}, |
| 2562 | {"vkQueuePresentKHR", reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR)}, |
Chia-I Wu | 8324595 | 2016-05-05 16:13:19 +0800 | [diff] [blame] | 2563 | }; |
| 2564 | |
| 2565 | // do not check if VK_KHR_swapchain is enabled (why?) |
| 2566 | |
| 2567 | for (size_t i = 0; i < ARRAY_SIZE(khr_swapchain_commands); i++) { |
| 2568 | if (!strcmp(khr_swapchain_commands[i].name, name)) |
| 2569 | return khr_swapchain_commands[i].proc; |
| 2570 | } |
| 2571 | |
| 2572 | return nullptr; |
| 2573 | } |
| 2574 | |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2575 | } // namespace swapchain |
| 2576 | |
| 2577 | // vk_layer_logging.h expects these to be defined |
| 2578 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2579 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, |
| 2580 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 2581 | const VkAllocationCallbacks *pAllocator, |
| 2582 | VkDebugReportCallbackEXT *pMsgCallback) { |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2583 | return swapchain::CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2584 | } |
| 2585 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2586 | VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 2587 | const VkAllocationCallbacks *pAllocator) { |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2588 | swapchain::DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2589 | } |
| 2590 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2591 | VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, |
| 2592 | VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, |
| 2593 | int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2594 | swapchain::DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2595 | } |
| 2596 | |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2597 | // loader-layer interface v0, just wrappers since there is only a layer |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2598 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2599 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 2600 | VkExtensionProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2601 | return swapchain::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); |
Chia-I Wu | 045209e | 2016-04-28 11:21:49 +0800 | [diff] [blame] | 2602 | } |
| 2603 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2604 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 2605 | VkLayerProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2606 | return swapchain::EnumerateInstanceLayerProperties(pCount, pProperties); |
Chia-I Wu | 045209e | 2016-04-28 11:21:49 +0800 | [diff] [blame] | 2607 | } |
| 2608 | |
Mark Lobodzinski | d0ef521 | 2016-08-08 14:41:55 -0600 | [diff] [blame] | 2609 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 2610 | VkLayerProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2611 | // the layer command handles VK_NULL_HANDLE just fine internally |
| 2612 | assert(physicalDevice == VK_NULL_HANDLE); |
| 2613 | return swapchain::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2614 | } |
| 2615 | |
| 2616 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 2617 | const char *pLayerName, uint32_t *pCount, |
| 2618 | VkExtensionProperties *pProperties) { |
Chia-I Wu | b02600c | 2016-05-20 07:11:22 +0800 | [diff] [blame] | 2619 | // the layer command handles VK_NULL_HANDLE just fine internally |
| 2620 | assert(physicalDevice == VK_NULL_HANDLE); |
Chia-I Wu | 2b48125 | 2016-04-28 14:21:13 +0800 | [diff] [blame] | 2621 | return swapchain::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2622 | } |
| 2623 | |
| 2624 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2625 | return swapchain::GetDeviceProcAddr(dev, funcName); |
Chia-I Wu | 516b508 | 2016-04-28 11:27:46 +0800 | [diff] [blame] | 2626 | } |
| 2627 | |
| 2628 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
Chia-I Wu | fccbfe4 | 2016-04-28 14:01:30 +0800 | [diff] [blame] | 2629 | return swapchain::GetInstanceProcAddr(instance, funcName); |
Chia-I Wu | 045209e | 2016-04-28 11:21:49 +0800 | [diff] [blame] | 2630 | } |