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. |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [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 |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 9 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [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. |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 17 | * |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | */ |
| 20 | |
Jamie Madill | df5d573 | 2016-04-04 11:54:43 -0400 | [diff] [blame] | 21 | #include "vk_loader_platform.h" |
| 22 | #include "vulkan/vulkan.h" |
| 23 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
Karl Schultz | d7f3754 | 2016-05-10 11:36:08 -0600 | [diff] [blame] | 27 | #include <cinttypes> |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 28 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 29 | #include <unordered_map> |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 30 | #include <vector> |
| 31 | #include <mutex> |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 32 | |
| 33 | #include "vulkan/vk_layer.h" |
| 34 | #include "vk_layer_config.h" |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 35 | #include "vk_layer_table.h" |
| 36 | #include "vk_layer_data.h" |
| 37 | #include "vk_layer_logging.h" |
| 38 | #include "vk_layer_extension_utils.h" |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 39 | #include "vk_safe_struct.h" |
Jon Ashburn | dc9111c | 2016-03-22 12:57:13 -0600 | [diff] [blame] | 40 | #include "vk_layer_utils.h" |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 41 | |
Chia-I Wu | cdb7096 | 2016-05-13 14:07:36 +0800 | [diff] [blame] | 42 | namespace unique_objects { |
| 43 | |
Mark Lobodzinski | fdf8f47 | 2016-04-28 16:36:58 -0600 | [diff] [blame] | 44 | // All increments must be guarded by global_lock |
| 45 | static uint64_t global_unique_id = 1; |
| 46 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 47 | struct layer_data { |
Chia-I Wu | 1657047 | 2016-05-17 07:57:15 +0800 | [diff] [blame^] | 48 | VkInstance instance; |
| 49 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 50 | bool wsi_enabled; |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 51 | std::unordered_map<uint64_t, uint64_t> unique_id_mapping; // Map uniqueID to actual object handle |
| 52 | VkPhysicalDevice gpu; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 53 | |
Mark Lobodzinski | fdf8f47 | 2016-04-28 16:36:58 -0600 | [diff] [blame] | 54 | layer_data() : wsi_enabled(false), gpu(VK_NULL_HANDLE){}; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | struct instExts { |
| 58 | bool wsi_enabled; |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 59 | bool xlib_enabled; |
| 60 | bool xcb_enabled; |
| 61 | bool wayland_enabled; |
| 62 | bool mir_enabled; |
| 63 | bool android_enabled; |
| 64 | bool win32_enabled; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 67 | static std::unordered_map<void *, struct instExts> instanceExtMap; |
| 68 | static std::unordered_map<void *, layer_data *> layer_data_map; |
| 69 | static device_table_map unique_objects_device_table_map; |
| 70 | static instance_table_map unique_objects_instance_table_map; |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 71 | static std::mutex global_lock; // Protect map accesses and unique_id increments |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 72 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 73 | // Handle CreateInstance |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 74 | static void createInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 75 | uint32_t i; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 76 | VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(unique_objects_instance_table_map, instance); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 77 | PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; |
Michael Lentine | 56512bb | 2016-03-02 17:28:55 -0600 | [diff] [blame] | 78 | |
| 79 | pDisp->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)gpa(instance, "vkDestroySurfaceKHR"); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 80 | pDisp->GetPhysicalDeviceSurfaceSupportKHR = |
| 81 | (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
| 82 | pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = |
| 83 | (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); |
| 84 | pDisp->GetPhysicalDeviceSurfaceFormatsKHR = |
| 85 | (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"); |
| 86 | pDisp->GetPhysicalDeviceSurfacePresentModesKHR = |
| 87 | (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"); |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 88 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 89 | pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)gpa(instance, "vkCreateWin32SurfaceKHR"); |
| 90 | pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = |
| 91 | (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 92 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 93 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 94 | pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)gpa(instance, "vkCreateXcbSurfaceKHR"); |
| 95 | pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = |
| 96 | (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 97 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 98 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 99 | pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)gpa(instance, "vkCreateXlibSurfaceKHR"); |
| 100 | pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = |
| 101 | (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 102 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 103 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 104 | pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)gpa(instance, "vkCreateMirSurfaceKHR"); |
| 105 | pDisp->GetPhysicalDeviceMirPresentationSupportKHR = |
| 106 | (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 107 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 108 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 109 | pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)gpa(instance, "vkCreateWaylandSurfaceKHR"); |
| 110 | pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = |
| 111 | (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 112 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 113 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 114 | pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)gpa(instance, "vkCreateAndroidSurfaceKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 115 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 116 | |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 117 | instanceExtMap[pDisp] = {}; |
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) |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 120 | instanceExtMap[pDisp].wsi_enabled = true; |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 121 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 122 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 123 | instanceExtMap[pDisp].xlib_enabled = true; |
| 124 | #endif |
| 125 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 126 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 127 | instanceExtMap[pDisp].xcb_enabled = true; |
| 128 | #endif |
| 129 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 130 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 131 | instanceExtMap[pDisp].wayland_enabled = true; |
| 132 | #endif |
| 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) |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 135 | instanceExtMap[pDisp].mir_enabled = true; |
| 136 | #endif |
| 137 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 138 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 139 | instanceExtMap[pDisp].android_enabled = true; |
| 140 | #endif |
| 141 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 142 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 143 | instanceExtMap[pDisp].win32_enabled = true; |
| 144 | #endif |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 148 | VkResult explicit_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 149 | VkInstance *pInstance) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 150 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 151 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 152 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 153 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 154 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 155 | if (fpCreateInstance == NULL) { |
| 156 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 157 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 158 | |
| 159 | // Advance the link info for the next element on the chain |
| 160 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 161 | |
| 162 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 163 | if (result != VK_SUCCESS) { |
| 164 | return result; |
| 165 | } |
| 166 | |
Chia-I Wu | 1657047 | 2016-05-17 07:57:15 +0800 | [diff] [blame^] | 167 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 168 | my_data->instance = *pInstance; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 169 | initInstanceTable(*pInstance, fpGetInstanceProcAddr, unique_objects_instance_table_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 170 | |
| 171 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
| 172 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 173 | return result; |
| 174 | } |
| 175 | |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 176 | void explicit_DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Dustin Graves | 7b098da | 2016-04-29 11:55:43 -0600 | [diff] [blame] | 177 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 178 | get_dispatch_table(unique_objects_instance_table_map, instance)->DestroyInstance(instance, pAllocator); |
Dustin Graves | 7b098da | 2016-04-29 11:55:43 -0600 | [diff] [blame] | 179 | layer_data_map.erase(key); |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 180 | } |
| 181 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 182 | // Handle CreateDevice |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 183 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 184 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 185 | VkLayerDispatchTable *pDisp = get_dispatch_table(unique_objects_device_table_map, device); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 186 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 187 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)gpa(device, "vkCreateSwapchainKHR"); |
| 188 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)gpa(device, "vkDestroySwapchainKHR"); |
| 189 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)gpa(device, "vkGetSwapchainImagesKHR"); |
| 190 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)gpa(device, "vkAcquireNextImageKHR"); |
| 191 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(device, "vkQueuePresentKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 192 | my_device_data->wsi_enabled = false; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 193 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 194 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 195 | my_device_data->wsi_enabled = true; |
| 196 | } |
| 197 | } |
| 198 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 199 | VkResult explicit_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 200 | VkDevice *pDevice) { |
Chia-I Wu | 1657047 | 2016-05-17 07:57:15 +0800 | [diff] [blame^] | 201 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 202 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 203 | |
| 204 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 205 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 206 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
Chia-I Wu | 1657047 | 2016-05-17 07:57:15 +0800 | [diff] [blame^] | 207 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 208 | if (fpCreateDevice == NULL) { |
| 209 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 210 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 211 | |
| 212 | // Advance the link info for the next element on the chain |
| 213 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 214 | |
| 215 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 216 | if (result != VK_SUCCESS) { |
| 217 | return result; |
| 218 | } |
| 219 | |
| 220 | // Setup layer's device dispatch table |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 221 | initDeviceTable(*pDevice, fpGetDeviceProcAddr, unique_objects_device_table_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 222 | |
| 223 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 224 | // Set gpu for this device in order to get at any objects mapped at instance level |
| 225 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 226 | my_device_data->gpu = gpu; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 227 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 228 | return result; |
| 229 | } |
| 230 | |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 231 | void explicit_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Dustin Graves | 7b098da | 2016-04-29 11:55:43 -0600 | [diff] [blame] | 232 | dispatch_key key = get_dispatch_key(device); |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 233 | get_dispatch_table(unique_objects_device_table_map, device)->DestroyDevice(device, pAllocator); |
Dustin Graves | 7b098da | 2016-04-29 11:55:43 -0600 | [diff] [blame] | 234 | layer_data_map.erase(key); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 237 | VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 238 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 239 | VkPipeline *pPipelines) { |
| 240 | // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'stage': {'module': 'VkShaderModule'}, |
| 241 | // 'layout': 'VkPipelineLayout', 'basePipelineHandle': 'VkPipeline'}} |
| 242 | // LOCAL DECLS:{'pCreateInfos': 'VkComputePipelineCreateInfo*'} |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 243 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 244 | safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 245 | if (pCreateInfos) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 246 | std::lock_guard<std::mutex> lock(global_lock); |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 247 | local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount]; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 248 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 249 | local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]); |
| 250 | if (pCreateInfos[idx0].basePipelineHandle) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 251 | local_pCreateInfos[idx0].basePipelineHandle = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 252 | (VkPipeline)my_device_data |
| 253 | ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].basePipelineHandle)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 254 | } |
| 255 | if (pCreateInfos[idx0].layout) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 256 | local_pCreateInfos[idx0].layout = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 257 | (VkPipelineLayout) |
| 258 | my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].layout)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 259 | } |
| 260 | if (pCreateInfos[idx0].stage.module) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 261 | local_pCreateInfos[idx0].stage.module = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 262 | (VkShaderModule) |
| 263 | my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].stage.module)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 264 | } |
| 265 | } |
| 266 | } |
| 267 | if (pipelineCache) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 268 | std::lock_guard<std::mutex> lock(global_lock); |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 269 | pipelineCache = (VkPipelineCache)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(pipelineCache)]; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 270 | } |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 271 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 272 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device) |
| 273 | ->CreateComputePipelines(device, pipelineCache, createInfoCount, |
| 274 | (const VkComputePipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines); |
Eric Engestrom | 53b513f | 2016-02-21 19:58:09 +0000 | [diff] [blame] | 275 | delete[] local_pCreateInfos; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 276 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 277 | uint64_t unique_id = 0; |
| 278 | std::lock_guard<std::mutex> lock(global_lock); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 279 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Mark Lobodzinski | fdf8f47 | 2016-04-28 16:36:58 -0600 | [diff] [blame] | 280 | unique_id = global_unique_id++; |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 281 | my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]); |
| 282 | pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | return result; |
| 286 | } |
| 287 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 288 | VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 289 | const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 290 | VkPipeline *pPipelines) { |
| 291 | // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'layout': 'VkPipelineLayout', |
| 292 | // 'pStages[stageCount]': {'module': 'VkShaderModule'}, 'renderPass': 'VkRenderPass', 'basePipelineHandle': 'VkPipeline'}} |
| 293 | // LOCAL DECLS:{'pCreateInfos': 'VkGraphicsPipelineCreateInfo*'} |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 294 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 295 | safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = NULL; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 296 | if (pCreateInfos) { |
| 297 | local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount]; |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 298 | std::lock_guard<std::mutex> lock(global_lock); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 299 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 300 | local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]); |
| 301 | if (pCreateInfos[idx0].basePipelineHandle) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 302 | local_pCreateInfos[idx0].basePipelineHandle = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 303 | (VkPipeline)my_device_data |
| 304 | ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].basePipelineHandle)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 305 | } |
| 306 | if (pCreateInfos[idx0].layout) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 307 | local_pCreateInfos[idx0].layout = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 308 | (VkPipelineLayout) |
| 309 | my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].layout)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 310 | } |
| 311 | if (pCreateInfos[idx0].pStages) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 312 | for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) { |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 313 | if (pCreateInfos[idx0].pStages[idx1].module) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 314 | local_pCreateInfos[idx0].pStages[idx1].module = |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 315 | (VkShaderModule)my_device_data |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 316 | ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].pStages[idx1].module)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | } |
| 320 | if (pCreateInfos[idx0].renderPass) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 321 | local_pCreateInfos[idx0].renderPass = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 322 | (VkRenderPass) |
| 323 | my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].renderPass)]; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 324 | } |
| 325 | } |
| 326 | } |
| 327 | if (pipelineCache) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 328 | std::lock_guard<std::mutex> lock(global_lock); |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 329 | pipelineCache = (VkPipelineCache)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(pipelineCache)]; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 330 | } |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 331 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 332 | VkResult result = |
| 333 | get_dispatch_table(unique_objects_device_table_map, device) |
| 334 | ->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, |
| 335 | (const VkGraphicsPipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines); |
Eric Engestrom | 53b513f | 2016-02-21 19:58:09 +0000 | [diff] [blame] | 336 | delete[] local_pCreateInfos; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 337 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 338 | uint64_t unique_id = 0; |
| 339 | std::lock_guard<std::mutex> lock(global_lock); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 340 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Mark Lobodzinski | fdf8f47 | 2016-04-28 16:36:58 -0600 | [diff] [blame] | 341 | unique_id = global_unique_id++; |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 342 | my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]); |
| 343 | pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | return result; |
| 347 | } |
| 348 | |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 349 | VkResult explicit_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 350 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { |
| 351 | layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 352 | |
| 353 | safe_VkSwapchainCreateInfoKHR *local_pCreateInfo = NULL; |
| 354 | if (pCreateInfo) { |
| 355 | std::lock_guard<std::mutex> lock(global_lock); |
| 356 | local_pCreateInfo = new safe_VkSwapchainCreateInfoKHR(pCreateInfo); |
| 357 | local_pCreateInfo->oldSwapchain = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 358 | (VkSwapchainKHR)my_map_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfo->oldSwapchain)]; |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 359 | // Need to pull surface mapping from the instance-level map |
| 360 | layer_data *instance_data = get_my_data_ptr(get_dispatch_key(my_map_data->gpu), layer_data_map); |
| 361 | local_pCreateInfo->surface = |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 362 | (VkSurfaceKHR)instance_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfo->surface)]; |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device) |
| 366 | ->CreateSwapchainKHR(device, (const VkSwapchainCreateInfoKHR *)local_pCreateInfo, pAllocator, pSwapchain); |
| 367 | if (local_pCreateInfo) |
| 368 | delete local_pCreateInfo; |
| 369 | if (VK_SUCCESS == result) { |
| 370 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | fdf8f47 | 2016-04-28 16:36:58 -0600 | [diff] [blame] | 371 | uint64_t unique_id =global_unique_id++; |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 372 | my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*pSwapchain); |
| 373 | *pSwapchain = reinterpret_cast<VkSwapchainKHR &>(unique_id); |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 374 | } |
| 375 | return result; |
| 376 | } |
| 377 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 378 | VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 379 | VkImage *pSwapchainImages) { |
| 380 | // UNWRAP USES: |
| 381 | // 0 : swapchain,VkSwapchainKHR, pSwapchainImages,VkImage |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 382 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 383 | if (VK_NULL_HANDLE != swapchain) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 384 | std::lock_guard<std::mutex> lock(global_lock); |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 385 | swapchain = (VkSwapchainKHR)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(swapchain)]; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 386 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 387 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device) |
| 388 | ->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 389 | // TODO : Need to add corresponding code to delete these images |
| 390 | if (VK_SUCCESS == result) { |
| 391 | if ((*pSwapchainImageCount > 0) && pSwapchainImages) { |
Tobin Ehlis | 10ba1de | 2016-04-13 12:59:43 -0600 | [diff] [blame] | 392 | uint64_t unique_id = 0; |
| 393 | std::lock_guard<std::mutex> lock(global_lock); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 394 | for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) { |
Mark Lobodzinski | fdf8f47 | 2016-04-28 16:36:58 -0600 | [diff] [blame] | 395 | unique_id = global_unique_id++; |
Dustin Graves | a7622d8 | 2016-04-14 17:29:20 -0600 | [diff] [blame] | 396 | my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pSwapchainImages[i]); |
| 397 | pSwapchainImages[i] = reinterpret_cast<VkImage &>(unique_id); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | } |
| 401 | return result; |
| 402 | } |
Chia-I Wu | cdb7096 | 2016-05-13 14:07:36 +0800 | [diff] [blame] | 403 | |
| 404 | } // namespace unique_objects |