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 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and/or associated documentation files (the "Materials"), to |
| 8 | * deal in the Materials without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Materials, and to permit persons to whom the Materials |
| 11 | * are furnished to do so, subject to the following conditions: |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 12 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 13 | * The above copyright notice(s) and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Materials. |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 15 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 16 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 19 | * |
| 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 21 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 23 | * USE OR OTHER DEALINGS IN THE MATERIALS |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 24 | * |
| 25 | * Author: Tobin Ehlis <tobine@google.com> |
| 26 | */ |
| 27 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 28 | #include <stdio.h> |
| 29 | #include <stdlib.h> |
| 30 | #include <string.h> |
| 31 | #include <inttypes.h> |
| 32 | |
| 33 | #include "vulkan/vulkan.h" |
| 34 | #include "vk_loader_platform.h" |
| 35 | |
| 36 | #include <vector> |
| 37 | #include <unordered_map> |
| 38 | |
| 39 | #include "vulkan/vk_layer.h" |
| 40 | #include "vk_layer_config.h" |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 41 | #include "vk_layer_table.h" |
| 42 | #include "vk_layer_data.h" |
| 43 | #include "vk_layer_logging.h" |
| 44 | #include "vk_layer_extension_utils.h" |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 45 | #include "vk_safe_struct.h" |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 46 | |
| 47 | struct layer_data { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 48 | bool wsi_enabled; |
| 49 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 50 | layer_data() : wsi_enabled(false){}; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | struct instExts { |
| 54 | bool wsi_enabled; |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 55 | bool xlib_enabled; |
| 56 | bool xcb_enabled; |
| 57 | bool wayland_enabled; |
| 58 | bool mir_enabled; |
| 59 | bool android_enabled; |
| 60 | bool win32_enabled; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 63 | static std::unordered_map<void *, struct instExts> instanceExtMap; |
| 64 | static std::unordered_map<void *, layer_data *> layer_data_map; |
| 65 | static device_table_map unique_objects_device_table_map; |
| 66 | static instance_table_map unique_objects_instance_table_map; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 67 | // Structure to wrap returned non-dispatchable objects to guarantee they have unique handles |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 68 | // address of struct will be used as the unique handle |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 69 | struct VkUniqueObject { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 70 | uint64_t actualObject; |
| 71 | }; |
| 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 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 167 | initInstanceTable(*pInstance, fpGetInstanceProcAddr, unique_objects_instance_table_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 168 | |
| 169 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
| 170 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 171 | return result; |
| 172 | } |
| 173 | |
| 174 | // Handle CreateDevice |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 175 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 176 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 177 | VkLayerDispatchTable *pDisp = get_dispatch_table(unique_objects_device_table_map, device); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 178 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 179 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)gpa(device, "vkCreateSwapchainKHR"); |
| 180 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)gpa(device, "vkDestroySwapchainKHR"); |
| 181 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)gpa(device, "vkGetSwapchainImagesKHR"); |
| 182 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)gpa(device, "vkAcquireNextImageKHR"); |
| 183 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(device, "vkQueuePresentKHR"); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 184 | my_device_data->wsi_enabled = false; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 185 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 186 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 187 | my_device_data->wsi_enabled = true; |
| 188 | } |
| 189 | } |
| 190 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 191 | VkResult explicit_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 192 | VkDevice *pDevice) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 193 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 194 | |
| 195 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 196 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 197 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 198 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(NULL, "vkCreateDevice"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 199 | if (fpCreateDevice == NULL) { |
| 200 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 201 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 202 | |
| 203 | // Advance the link info for the next element on the chain |
| 204 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 205 | |
| 206 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 207 | if (result != VK_SUCCESS) { |
| 208 | return result; |
| 209 | } |
| 210 | |
| 211 | // Setup layer's device dispatch table |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 212 | initDeviceTable(*pDevice, fpGetDeviceProcAddr, unique_objects_device_table_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 213 | |
| 214 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 215 | |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 216 | return result; |
| 217 | } |
| 218 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 219 | VkResult explicit_QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence) { |
| 220 | // UNWRAP USES: |
| 221 | // 0 : fence,VkFence |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 222 | if (VK_NULL_HANDLE != fence) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 223 | fence = (VkFence)((VkUniqueObject *)fence)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 224 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 225 | // waitSemaphoreCount : pSubmits[submitCount]->pWaitSemaphores,VkSemaphore |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 226 | std::vector<VkSemaphore> original_pWaitSemaphores = {}; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 227 | // signalSemaphoreCount : pSubmits[submitCount]->pSignalSemaphores,VkSemaphore |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 228 | std::vector<VkSemaphore> original_pSignalSemaphores = {}; |
| 229 | if (pSubmits) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 230 | for (uint32_t index0 = 0; index0 < submitCount; ++index0) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 231 | if (pSubmits[index0].pWaitSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 232 | for (uint32_t index1 = 0; index1 < pSubmits[index0].waitSemaphoreCount; ++index1) { |
| 233 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pWaitSemaphores); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 234 | original_pWaitSemaphores.push_back(pSubmits[index0].pWaitSemaphores[index1]); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 235 | *(ppSemaphore[index1]) = |
| 236 | (VkSemaphore)((VkUniqueObject *)pSubmits[index0].pWaitSemaphores[index1])->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | if (pSubmits[index0].pSignalSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 240 | for (uint32_t index1 = 0; index1 < pSubmits[index0].signalSemaphoreCount; ++index1) { |
| 241 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pSignalSemaphores); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 242 | original_pSignalSemaphores.push_back(pSubmits[index0].pSignalSemaphores[index1]); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 243 | *(ppSemaphore[index1]) = |
| 244 | (VkSemaphore)((VkUniqueObject *)pSubmits[index0].pSignalSemaphores[index1])->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | } |
| 248 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 249 | VkResult result = get_dispatch_table(unique_objects_device_table_map, queue)->QueueSubmit(queue, submitCount, pSubmits, fence); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 250 | if (pSubmits) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 251 | for (uint32_t index0 = 0; index0 < submitCount; ++index0) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 252 | if (pSubmits[index0].pWaitSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 253 | for (uint32_t index1 = 0; index1 < pSubmits[index0].waitSemaphoreCount; ++index1) { |
| 254 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pWaitSemaphores); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 255 | *(ppSemaphore[index1]) = original_pWaitSemaphores[index1]; |
| 256 | } |
| 257 | } |
| 258 | if (pSubmits[index0].pSignalSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 259 | for (uint32_t index1 = 0; index1 < pSubmits[index0].signalSemaphoreCount; ++index1) { |
| 260 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pSignalSemaphores); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 261 | *(ppSemaphore[index1]) = original_pSignalSemaphores[index1]; |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | return result; |
| 267 | } |
| 268 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 269 | VkResult explicit_QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, VkFence fence) { |
| 270 | // UNWRAP USES: |
| 271 | // 0 : pBindInfo[bindInfoCount]->pBufferBinds[bufferBindCount]->buffer,VkBuffer, |
| 272 | // pBindInfo[bindInfoCount]->pBufferBinds[bufferBindCount]->pBinds[bindCount]->memory,VkDeviceMemory, |
| 273 | // pBindInfo[bindInfoCount]->pImageOpaqueBinds[imageOpaqueBindCount]->image,VkImage, |
| 274 | // pBindInfo[bindInfoCount]->pImageOpaqueBinds[imageOpaqueBindCount]->pBinds[bindCount]->memory,VkDeviceMemory, |
| 275 | // pBindInfo[bindInfoCount]->pImageBinds[imageBindCount]->image,VkImage, |
| 276 | // pBindInfo[bindInfoCount]->pImageBinds[imageBindCount]->pBinds[bindCount]->memory,VkDeviceMemory |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 277 | std::vector<VkBuffer> original_buffer = {}; |
| 278 | std::vector<VkDeviceMemory> original_memory1 = {}; |
| 279 | std::vector<VkImage> original_image1 = {}; |
| 280 | std::vector<VkDeviceMemory> original_memory2 = {}; |
| 281 | std::vector<VkImage> original_image2 = {}; |
| 282 | std::vector<VkDeviceMemory> original_memory3 = {}; |
| 283 | std::vector<VkSemaphore> original_pWaitSemaphores = {}; |
| 284 | std::vector<VkSemaphore> original_pSignalSemaphores = {}; |
| 285 | if (pBindInfo) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 286 | for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 287 | if (pBindInfo[index0].pBufferBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 288 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].bufferBindCount; ++index1) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 289 | if (pBindInfo[index0].pBufferBinds[index1].buffer) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 290 | VkBuffer *pBuffer = (VkBuffer *)&(pBindInfo[index0].pBufferBinds[index1].buffer); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 291 | original_buffer.push_back(pBindInfo[index0].pBufferBinds[index1].buffer); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 292 | *(pBuffer) = (VkBuffer)((VkUniqueObject *)pBindInfo[index0].pBufferBinds[index1].buffer)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 293 | } |
| 294 | if (pBindInfo[index0].pBufferBinds[index1].pBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 295 | for (uint32_t index2 = 0; index2 < pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 296 | if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 297 | VkDeviceMemory *pDeviceMemory = |
| 298 | (VkDeviceMemory *)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 299 | original_memory1.push_back(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 300 | *(pDeviceMemory) = |
| 301 | (VkDeviceMemory)((VkUniqueObject *)pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) |
| 302 | ->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | if (pBindInfo[index0].pImageOpaqueBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 309 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageOpaqueBindCount; ++index1) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 310 | if (pBindInfo[index0].pImageOpaqueBinds[index1].image) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 311 | VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageOpaqueBinds[index1].image); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 312 | original_image1.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].image); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 313 | *(pImage) = (VkImage)((VkUniqueObject *)pBindInfo[index0].pImageOpaqueBinds[index1].image)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 314 | } |
| 315 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 316 | for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 317 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 318 | VkDeviceMemory *pDeviceMemory = |
| 319 | (VkDeviceMemory *)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 320 | original_memory2.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 321 | *(pDeviceMemory) = |
| 322 | (VkDeviceMemory)( |
| 323 | (VkUniqueObject *)pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) |
| 324 | ->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | if (pBindInfo[index0].pImageBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 331 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageBindCount; ++index1) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 332 | if (pBindInfo[index0].pImageBinds[index1].image) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 333 | VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageBinds[index1].image); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 334 | original_image2.push_back(pBindInfo[index0].pImageBinds[index1].image); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 335 | *(pImage) = (VkImage)((VkUniqueObject *)pBindInfo[index0].pImageBinds[index1].image)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 336 | } |
| 337 | if (pBindInfo[index0].pImageBinds[index1].pBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 338 | for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 339 | if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 340 | VkDeviceMemory *pDeviceMemory = |
| 341 | (VkDeviceMemory *)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 342 | original_memory3.push_back(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 343 | *(pDeviceMemory) = |
| 344 | (VkDeviceMemory)((VkUniqueObject *)pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) |
| 345 | ->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | if (pBindInfo[index0].pWaitSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 352 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].waitSemaphoreCount; ++index1) { |
| 353 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pWaitSemaphores); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 354 | original_pWaitSemaphores.push_back(pBindInfo[index0].pWaitSemaphores[index1]); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 355 | *(ppSemaphore[index1]) = |
| 356 | (VkSemaphore)((VkUniqueObject *)pBindInfo[index0].pWaitSemaphores[index1])->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | if (pBindInfo[index0].pSignalSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 360 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].signalSemaphoreCount; ++index1) { |
| 361 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pSignalSemaphores); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 362 | original_pSignalSemaphores.push_back(pBindInfo[index0].pSignalSemaphores[index1]); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 363 | *(ppSemaphore[index1]) = |
| 364 | (VkSemaphore)((VkUniqueObject *)pBindInfo[index0].pSignalSemaphores[index1])->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | if (VK_NULL_HANDLE != fence) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 370 | fence = (VkFence)((VkUniqueObject *)fence)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 371 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 372 | VkResult result = |
| 373 | get_dispatch_table(unique_objects_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 374 | if (pBindInfo) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 375 | for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 376 | if (pBindInfo[index0].pBufferBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 377 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].bufferBindCount; ++index1) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 378 | if (pBindInfo[index0].pBufferBinds[index1].buffer) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 379 | VkBuffer *pBuffer = (VkBuffer *)&(pBindInfo[index0].pBufferBinds[index1].buffer); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 380 | *(pBuffer) = original_buffer[index1]; |
| 381 | } |
| 382 | if (pBindInfo[index0].pBufferBinds[index1].pBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 383 | for (uint32_t index2 = 0; index2 < pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 384 | if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 385 | VkDeviceMemory *pDeviceMemory = |
| 386 | (VkDeviceMemory *)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 387 | *(pDeviceMemory) = original_memory1[index2]; |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | if (pBindInfo[index0].pImageOpaqueBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 394 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageOpaqueBindCount; ++index1) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 395 | if (pBindInfo[index0].pImageOpaqueBinds[index1].image) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 396 | VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageOpaqueBinds[index1].image); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 397 | *(pImage) = original_image1[index1]; |
| 398 | } |
| 399 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 400 | for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 401 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 402 | VkDeviceMemory *pDeviceMemory = |
| 403 | (VkDeviceMemory *)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 404 | *(pDeviceMemory) = original_memory2[index2]; |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | if (pBindInfo[index0].pImageBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 411 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageBindCount; ++index1) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 412 | if (pBindInfo[index0].pImageBinds[index1].image) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 413 | VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageBinds[index1].image); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 414 | *(pImage) = original_image2[index1]; |
| 415 | } |
| 416 | if (pBindInfo[index0].pImageBinds[index1].pBinds) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 417 | for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 418 | if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 419 | VkDeviceMemory *pDeviceMemory = |
| 420 | (VkDeviceMemory *)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 421 | *(pDeviceMemory) = original_memory3[index2]; |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | if (pBindInfo[index0].pWaitSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 428 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].waitSemaphoreCount; ++index1) { |
| 429 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pWaitSemaphores); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 430 | *(ppSemaphore[index1]) = original_pWaitSemaphores[index1]; |
| 431 | } |
| 432 | } |
| 433 | if (pBindInfo[index0].pSignalSemaphores) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 434 | for (uint32_t index1 = 0; index1 < pBindInfo[index0].signalSemaphoreCount; ++index1) { |
| 435 | VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pSignalSemaphores); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 436 | *(ppSemaphore[index1]) = original_pSignalSemaphores[index1]; |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | return result; |
| 442 | } |
| 443 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 444 | VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 445 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 446 | VkPipeline *pPipelines) { |
| 447 | // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'stage': {'module': 'VkShaderModule'}, |
| 448 | // 'layout': 'VkPipelineLayout', 'basePipelineHandle': 'VkPipeline'}} |
| 449 | // LOCAL DECLS:{'pCreateInfos': 'VkComputePipelineCreateInfo*'} |
| 450 | safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 451 | if (pCreateInfos) { |
| 452 | local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount]; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 453 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 454 | local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]); |
| 455 | if (pCreateInfos[idx0].basePipelineHandle) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 456 | local_pCreateInfos[idx0].basePipelineHandle = |
| 457 | (VkPipeline)((VkUniqueObject *)pCreateInfos[idx0].basePipelineHandle)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 458 | } |
| 459 | if (pCreateInfos[idx0].layout) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 460 | local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject *)pCreateInfos[idx0].layout)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 461 | } |
| 462 | if (pCreateInfos[idx0].stage.module) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 463 | local_pCreateInfos[idx0].stage.module = |
| 464 | (VkShaderModule)((VkUniqueObject *)pCreateInfos[idx0].stage.module)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 465 | } |
| 466 | } |
| 467 | } |
| 468 | if (pipelineCache) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 469 | pipelineCache = (VkPipelineCache)((VkUniqueObject *)pipelineCache)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 470 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 471 | // CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671 |
| 472 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device) |
| 473 | ->CreateComputePipelines(device, pipelineCache, createInfoCount, |
| 474 | (const VkComputePipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines); |
Eric Engestrom | 53b513f | 2016-02-21 19:58:09 +0000 | [diff] [blame] | 475 | delete[] local_pCreateInfos; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 476 | if (VK_SUCCESS == result) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 477 | VkUniqueObject *pUO = NULL; |
| 478 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 479 | pUO = new VkUniqueObject(); |
| 480 | pUO->actualObject = (uint64_t)pPipelines[i]; |
| 481 | pPipelines[i] = (VkPipeline)pUO; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 482 | } |
| 483 | } |
| 484 | return result; |
| 485 | } |
| 486 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 487 | VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 488 | const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 489 | VkPipeline *pPipelines) { |
| 490 | // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'layout': 'VkPipelineLayout', |
| 491 | // 'pStages[stageCount]': {'module': 'VkShaderModule'}, 'renderPass': 'VkRenderPass', 'basePipelineHandle': 'VkPipeline'}} |
| 492 | // LOCAL DECLS:{'pCreateInfos': 'VkGraphicsPipelineCreateInfo*'} |
| 493 | safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = NULL; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 494 | if (pCreateInfos) { |
| 495 | local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount]; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 496 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 497 | local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]); |
| 498 | if (pCreateInfos[idx0].basePipelineHandle) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 499 | local_pCreateInfos[idx0].basePipelineHandle = |
| 500 | (VkPipeline)((VkUniqueObject *)pCreateInfos[idx0].basePipelineHandle)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 501 | } |
| 502 | if (pCreateInfos[idx0].layout) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 503 | local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject *)pCreateInfos[idx0].layout)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 504 | } |
| 505 | if (pCreateInfos[idx0].pStages) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 506 | for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) { |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 507 | if (pCreateInfos[idx0].pStages[idx1].module) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 508 | local_pCreateInfos[idx0].pStages[idx1].module = |
| 509 | (VkShaderModule)((VkUniqueObject *)pCreateInfos[idx0].pStages[idx1].module)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 510 | } |
| 511 | } |
| 512 | } |
| 513 | if (pCreateInfos[idx0].renderPass) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 514 | local_pCreateInfos[idx0].renderPass = (VkRenderPass)((VkUniqueObject *)pCreateInfos[idx0].renderPass)->actualObject; |
Tobin Ehlis | 8bb7c2f | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 515 | } |
| 516 | } |
| 517 | } |
| 518 | if (pipelineCache) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 519 | pipelineCache = (VkPipelineCache)((VkUniqueObject *)pipelineCache)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 520 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 521 | // CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671 |
| 522 | VkResult result = |
| 523 | get_dispatch_table(unique_objects_device_table_map, device) |
| 524 | ->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, |
| 525 | (const VkGraphicsPipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines); |
Eric Engestrom | 53b513f | 2016-02-21 19:58:09 +0000 | [diff] [blame] | 526 | delete[] local_pCreateInfos; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 527 | if (VK_SUCCESS == result) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 528 | VkUniqueObject *pUO = NULL; |
| 529 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Tobin Ehlis | a39c26a | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 530 | pUO = new VkUniqueObject(); |
| 531 | pUO->actualObject = (uint64_t)pPipelines[i]; |
| 532 | pPipelines[i] = (VkPipeline)pUO; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | return result; |
| 536 | } |
| 537 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 538 | VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 539 | VkImage *pSwapchainImages) { |
| 540 | // UNWRAP USES: |
| 541 | // 0 : swapchain,VkSwapchainKHR, pSwapchainImages,VkImage |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 542 | if (VK_NULL_HANDLE != swapchain) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 543 | swapchain = (VkSwapchainKHR)((VkUniqueObject *)swapchain)->actualObject; |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 544 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 545 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device) |
| 546 | ->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 547 | // TODO : Need to add corresponding code to delete these images |
| 548 | if (VK_SUCCESS == result) { |
| 549 | if ((*pSwapchainImageCount > 0) && pSwapchainImages) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame^] | 550 | std::vector<VkUniqueObject *> uniqueImages = {}; |
| 551 | for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) { |
Tobin Ehlis | d34a4c5 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 552 | uniqueImages.push_back(new VkUniqueObject()); |
| 553 | uniqueImages[i]->actualObject = (uint64_t)pSwapchainImages[i]; |
| 554 | pSwapchainImages[i] = (VkImage)uniqueImages[i]; |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | return result; |
| 559 | } |