Mark Lobodzinski | 288e4f7 | 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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 5 | * |
Mark Lobodzinski | 288e4f7 | 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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 12 | * |
Mark Lobodzinski | 288e4f7 | 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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 15 | * |
Mark Lobodzinski | 288e4f7 | 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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 288e4f7 | 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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 24 | * |
| 25 | * Author: Tobin Ehlis <tobine@google.com> |
| 26 | */ |
| 27 | |
Tobin Ehlis | 0b99d03 | 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 | 0b99d03 | 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 | 9aac555 | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 45 | #include "vk_safe_struct.h" |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 46 | |
| 47 | struct layer_data { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 48 | bool wsi_enabled; |
| 49 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 50 | layer_data() : |
| 51 | wsi_enabled(false) |
| 52 | {}; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | struct instExts { |
| 56 | bool wsi_enabled; |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 57 | bool xlib_enabled; |
| 58 | bool xcb_enabled; |
| 59 | bool wayland_enabled; |
| 60 | bool mir_enabled; |
| 61 | bool android_enabled; |
| 62 | bool win32_enabled; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 65 | static std::unordered_map<void*, struct instExts> instanceExtMap; |
| 66 | static std::unordered_map<void*, layer_data *> layer_data_map; |
| 67 | static device_table_map unique_objects_device_table_map; |
| 68 | static instance_table_map unique_objects_instance_table_map; |
| 69 | // Structure to wrap returned non-dispatchable objects to guarantee they have unique handles |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 70 | // address of struct will be used as the unique handle |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 71 | struct VkUniqueObject |
| 72 | { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 73 | uint64_t actualObject; |
| 74 | }; |
| 75 | |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 76 | // Handle CreateInstance |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 77 | static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance) |
| 78 | { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 79 | uint32_t i; |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 80 | VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(unique_objects_instance_table_map, instance); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 81 | PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; |
Michael Lentine | 90ee20e | 2016-03-02 17:28:55 -0600 | [diff] [blame^] | 82 | |
| 83 | pDisp->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)gpa(instance, "vkDestroySurfaceKHR"); |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 84 | pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
| 85 | pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); |
| 86 | pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"); |
| 87 | pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"); |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 88 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 89 | pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR"); |
| 90 | pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 91 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 92 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 93 | pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR"); |
| 94 | pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 95 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 96 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 97 | pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR"); |
| 98 | pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 99 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 100 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 101 | pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR"); |
| 102 | pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR"); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 103 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 104 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 105 | pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR"); |
| 106 | pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 107 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 108 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 109 | pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR"); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 110 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 111 | |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 112 | instanceExtMap[pDisp] = {}; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 113 | for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 114 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 115 | instanceExtMap[pDisp].wsi_enabled = true; |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 116 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 117 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 118 | instanceExtMap[pDisp].xlib_enabled = true; |
| 119 | #endif |
| 120 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 121 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 122 | instanceExtMap[pDisp].xcb_enabled = true; |
| 123 | #endif |
| 124 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 125 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 126 | instanceExtMap[pDisp].wayland_enabled = true; |
| 127 | #endif |
| 128 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 129 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 130 | instanceExtMap[pDisp].mir_enabled = true; |
| 131 | #endif |
| 132 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 133 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 134 | instanceExtMap[pDisp].android_enabled = true; |
| 135 | #endif |
| 136 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 137 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 138 | instanceExtMap[pDisp].win32_enabled = true; |
| 139 | #endif |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 143 | VkResult |
| 144 | explicit_CreateInstance( |
| 145 | const VkInstanceCreateInfo *pCreateInfo, |
| 146 | const VkAllocationCallbacks *pAllocator, |
| 147 | VkInstance *pInstance) |
| 148 | { |
| 149 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 150 | |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 151 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 152 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 153 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 154 | if (fpCreateInstance == NULL) { |
| 155 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 156 | } |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 157 | |
| 158 | // Advance the link info for the next element on the chain |
| 159 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 160 | |
| 161 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 162 | if (result != VK_SUCCESS) { |
| 163 | return result; |
| 164 | } |
| 165 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 166 | initInstanceTable(*pInstance, fpGetInstanceProcAddr, unique_objects_instance_table_map); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 167 | |
| 168 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
| 169 | |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 170 | return result; |
| 171 | } |
| 172 | |
| 173 | // Handle CreateDevice |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 174 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 175 | { |
| 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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 178 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -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 | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 184 | my_device_data->wsi_enabled = false; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 185 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 186 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 187 | my_device_data->wsi_enabled = true; |
| 188 | } |
| 189 | } |
| 190 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 191 | VkResult |
| 192 | explicit_CreateDevice( |
| 193 | VkPhysicalDevice gpu, |
| 194 | const VkDeviceCreateInfo *pCreateInfo, |
| 195 | const VkAllocationCallbacks *pAllocator, |
| 196 | VkDevice *pDevice) |
| 197 | { |
| 198 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 199 | |
| 200 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 201 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 202 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 203 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice"); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 204 | if (fpCreateDevice == NULL) { |
| 205 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 206 | } |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 207 | |
| 208 | // Advance the link info for the next element on the chain |
| 209 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 210 | |
| 211 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 212 | if (result != VK_SUCCESS) { |
| 213 | return result; |
| 214 | } |
| 215 | |
| 216 | // Setup layer's device dispatch table |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 217 | initDeviceTable(*pDevice, fpGetDeviceProcAddr, unique_objects_device_table_map); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 218 | |
| 219 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 220 | |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 221 | return result; |
| 222 | } |
| 223 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 224 | VkResult explicit_QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) |
| 225 | { |
| 226 | // UNWRAP USES: |
| 227 | // 0 : fence,VkFence |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 228 | if (VK_NULL_HANDLE != fence) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 229 | fence = (VkFence)((VkUniqueObject*)fence)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 230 | } |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 231 | // waitSemaphoreCount : pSubmits[submitCount]->pWaitSemaphores,VkSemaphore |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 232 | std::vector<VkSemaphore> original_pWaitSemaphores = {}; |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 233 | // signalSemaphoreCount : pSubmits[submitCount]->pSignalSemaphores,VkSemaphore |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 234 | std::vector<VkSemaphore> original_pSignalSemaphores = {}; |
| 235 | if (pSubmits) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 236 | for (uint32_t index0=0; index0<submitCount; ++index0) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 237 | if (pSubmits[index0].pWaitSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 238 | for (uint32_t index1=0; index1<pSubmits[index0].waitSemaphoreCount; ++index1) { |
| 239 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pSubmits[index0].pWaitSemaphores); |
| 240 | original_pWaitSemaphores.push_back(pSubmits[index0].pWaitSemaphores[index1]); |
| 241 | *(ppSemaphore[index1]) = (VkSemaphore)((VkUniqueObject*)pSubmits[index0].pWaitSemaphores[index1])->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 242 | } |
| 243 | } |
| 244 | if (pSubmits[index0].pSignalSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 245 | for (uint32_t index1=0; index1<pSubmits[index0].signalSemaphoreCount; ++index1) { |
| 246 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pSubmits[index0].pSignalSemaphores); |
| 247 | original_pSignalSemaphores.push_back(pSubmits[index0].pSignalSemaphores[index1]); |
| 248 | *(ppSemaphore[index1]) = (VkSemaphore)((VkUniqueObject*)pSubmits[index0].pSignalSemaphores[index1])->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 249 | } |
| 250 | } |
| 251 | } |
| 252 | } |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 253 | VkResult result = get_dispatch_table(unique_objects_device_table_map, queue)->QueueSubmit(queue, submitCount, pSubmits, fence); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 254 | if (pSubmits) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 255 | for (uint32_t index0=0; index0<submitCount; ++index0) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 256 | if (pSubmits[index0].pWaitSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 257 | for (uint32_t index1=0; index1<pSubmits[index0].waitSemaphoreCount; ++index1) { |
| 258 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pSubmits[index0].pWaitSemaphores); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 259 | *(ppSemaphore[index1]) = original_pWaitSemaphores[index1]; |
| 260 | } |
| 261 | } |
| 262 | if (pSubmits[index0].pSignalSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 263 | for (uint32_t index1=0; index1<pSubmits[index0].signalSemaphoreCount; ++index1) { |
| 264 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pSubmits[index0].pSignalSemaphores); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 265 | *(ppSemaphore[index1]) = original_pSignalSemaphores[index1]; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | return result; |
| 271 | } |
| 272 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 273 | VkResult explicit_QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence) |
| 274 | { |
| 275 | // UNWRAP USES: |
| 276 | // 0 : pBindInfo[bindInfoCount]->pBufferBinds[bufferBindCount]->buffer,VkBuffer, pBindInfo[bindInfoCount]->pBufferBinds[bufferBindCount]->pBinds[bindCount]->memory,VkDeviceMemory, pBindInfo[bindInfoCount]->pImageOpaqueBinds[imageOpaqueBindCount]->image,VkImage, pBindInfo[bindInfoCount]->pImageOpaqueBinds[imageOpaqueBindCount]->pBinds[bindCount]->memory,VkDeviceMemory, pBindInfo[bindInfoCount]->pImageBinds[imageBindCount]->image,VkImage, pBindInfo[bindInfoCount]->pImageBinds[imageBindCount]->pBinds[bindCount]->memory,VkDeviceMemory |
Tobin Ehlis | 0b99d03 | 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) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 286 | for (uint32_t index0=0; index0<bindInfoCount; ++index0) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 287 | if (pBindInfo[index0].pBufferBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 288 | for (uint32_t index1=0; index1<pBindInfo[index0].bufferBindCount; ++index1) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 289 | if (pBindInfo[index0].pBufferBinds[index1].buffer) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 290 | VkBuffer* pBuffer = (VkBuffer*)&(pBindInfo[index0].pBufferBinds[index1].buffer); |
| 291 | original_buffer.push_back(pBindInfo[index0].pBufferBinds[index1].buffer); |
| 292 | *(pBuffer) = (VkBuffer)((VkUniqueObject*)pBindInfo[index0].pBufferBinds[index1].buffer)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 293 | } |
| 294 | if (pBindInfo[index0].pBufferBinds[index1].pBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 295 | for (uint32_t index2=0; index2<pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) { |
| 296 | if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) { |
| 297 | VkDeviceMemory* pDeviceMemory = (VkDeviceMemory*)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory); |
| 298 | original_memory1.push_back(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory); |
| 299 | *(pDeviceMemory) = (VkDeviceMemory)((VkUniqueObject*)pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | if (pBindInfo[index0].pImageOpaqueBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 306 | for (uint32_t index1=0; index1<pBindInfo[index0].imageOpaqueBindCount; ++index1) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 307 | if (pBindInfo[index0].pImageOpaqueBinds[index1].image) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 308 | VkImage* pImage = (VkImage*)&(pBindInfo[index0].pImageOpaqueBinds[index1].image); |
| 309 | original_image1.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].image); |
| 310 | *(pImage) = (VkImage)((VkUniqueObject*)pBindInfo[index0].pImageOpaqueBinds[index1].image)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 311 | } |
| 312 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 313 | for (uint32_t index2=0; index2<pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) { |
| 314 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) { |
| 315 | VkDeviceMemory* pDeviceMemory = (VkDeviceMemory*)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory); |
| 316 | original_memory2.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory); |
| 317 | *(pDeviceMemory) = (VkDeviceMemory)((VkUniqueObject*)pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | if (pBindInfo[index0].pImageBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 324 | for (uint32_t index1=0; index1<pBindInfo[index0].imageBindCount; ++index1) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 325 | if (pBindInfo[index0].pImageBinds[index1].image) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 326 | VkImage* pImage = (VkImage*)&(pBindInfo[index0].pImageBinds[index1].image); |
| 327 | original_image2.push_back(pBindInfo[index0].pImageBinds[index1].image); |
| 328 | *(pImage) = (VkImage)((VkUniqueObject*)pBindInfo[index0].pImageBinds[index1].image)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 329 | } |
| 330 | if (pBindInfo[index0].pImageBinds[index1].pBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 331 | for (uint32_t index2=0; index2<pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) { |
| 332 | if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) { |
| 333 | VkDeviceMemory* pDeviceMemory = (VkDeviceMemory*)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory); |
| 334 | original_memory3.push_back(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory); |
| 335 | *(pDeviceMemory) = (VkDeviceMemory)((VkUniqueObject*)pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | if (pBindInfo[index0].pWaitSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 342 | for (uint32_t index1=0; index1<pBindInfo[index0].waitSemaphoreCount; ++index1) { |
| 343 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pBindInfo[index0].pWaitSemaphores); |
| 344 | original_pWaitSemaphores.push_back(pBindInfo[index0].pWaitSemaphores[index1]); |
| 345 | *(ppSemaphore[index1]) = (VkSemaphore)((VkUniqueObject*)pBindInfo[index0].pWaitSemaphores[index1])->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | if (pBindInfo[index0].pSignalSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 349 | for (uint32_t index1=0; index1<pBindInfo[index0].signalSemaphoreCount; ++index1) { |
| 350 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pBindInfo[index0].pSignalSemaphores); |
| 351 | original_pSignalSemaphores.push_back(pBindInfo[index0].pSignalSemaphores[index1]); |
| 352 | *(ppSemaphore[index1]) = (VkSemaphore)((VkUniqueObject*)pBindInfo[index0].pSignalSemaphores[index1])->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 353 | } |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | if (VK_NULL_HANDLE != fence) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 358 | fence = (VkFence)((VkUniqueObject*)fence)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 359 | } |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 360 | VkResult result = get_dispatch_table(unique_objects_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 361 | if (pBindInfo) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 362 | for (uint32_t index0=0; index0<bindInfoCount; ++index0) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 363 | if (pBindInfo[index0].pBufferBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 364 | for (uint32_t index1=0; index1<pBindInfo[index0].bufferBindCount; ++index1) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 365 | if (pBindInfo[index0].pBufferBinds[index1].buffer) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 366 | VkBuffer* pBuffer = (VkBuffer*)&(pBindInfo[index0].pBufferBinds[index1].buffer); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 367 | *(pBuffer) = original_buffer[index1]; |
| 368 | } |
| 369 | if (pBindInfo[index0].pBufferBinds[index1].pBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 370 | for (uint32_t index2=0; index2<pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) { |
| 371 | if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) { |
| 372 | VkDeviceMemory* pDeviceMemory = (VkDeviceMemory*)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 373 | *(pDeviceMemory) = original_memory1[index2]; |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | if (pBindInfo[index0].pImageOpaqueBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 380 | for (uint32_t index1=0; index1<pBindInfo[index0].imageOpaqueBindCount; ++index1) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 381 | if (pBindInfo[index0].pImageOpaqueBinds[index1].image) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 382 | VkImage* pImage = (VkImage*)&(pBindInfo[index0].pImageOpaqueBinds[index1].image); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 383 | *(pImage) = original_image1[index1]; |
| 384 | } |
| 385 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 386 | for (uint32_t index2=0; index2<pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) { |
| 387 | if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) { |
| 388 | VkDeviceMemory* pDeviceMemory = (VkDeviceMemory*)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 389 | *(pDeviceMemory) = original_memory2[index2]; |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | if (pBindInfo[index0].pImageBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 396 | for (uint32_t index1=0; index1<pBindInfo[index0].imageBindCount; ++index1) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 397 | if (pBindInfo[index0].pImageBinds[index1].image) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 398 | VkImage* pImage = (VkImage*)&(pBindInfo[index0].pImageBinds[index1].image); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 399 | *(pImage) = original_image2[index1]; |
| 400 | } |
| 401 | if (pBindInfo[index0].pImageBinds[index1].pBinds) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 402 | for (uint32_t index2=0; index2<pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) { |
| 403 | if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) { |
| 404 | VkDeviceMemory* pDeviceMemory = (VkDeviceMemory*)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 405 | *(pDeviceMemory) = original_memory3[index2]; |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | if (pBindInfo[index0].pWaitSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 412 | for (uint32_t index1=0; index1<pBindInfo[index0].waitSemaphoreCount; ++index1) { |
| 413 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pBindInfo[index0].pWaitSemaphores); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 414 | *(ppSemaphore[index1]) = original_pWaitSemaphores[index1]; |
| 415 | } |
| 416 | } |
| 417 | if (pBindInfo[index0].pSignalSemaphores) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 418 | for (uint32_t index1=0; index1<pBindInfo[index0].signalSemaphoreCount; ++index1) { |
| 419 | VkSemaphore** ppSemaphore = (VkSemaphore**)&(pBindInfo[index0].pSignalSemaphores); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 420 | *(ppSemaphore[index1]) = original_pSignalSemaphores[index1]; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | return result; |
| 426 | } |
| 427 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 428 | VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) |
| 429 | { |
Tobin Ehlis | 9aac555 | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 430 | // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'stage': {'module': 'VkShaderModule'}, 'layout': 'VkPipelineLayout', 'basePipelineHandle': 'VkPipeline'}} |
| 431 | //LOCAL DECLS:{'pCreateInfos': 'VkComputePipelineCreateInfo*'} |
| 432 | safe_VkComputePipelineCreateInfo* local_pCreateInfos = NULL; |
| 433 | if (pCreateInfos) { |
| 434 | local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount]; |
| 435 | for (uint32_t idx0=0; idx0<createInfoCount; ++idx0) { |
| 436 | local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]); |
| 437 | if (pCreateInfos[idx0].basePipelineHandle) { |
| 438 | local_pCreateInfos[idx0].basePipelineHandle = (VkPipeline)((VkUniqueObject*)pCreateInfos[idx0].basePipelineHandle)->actualObject; |
| 439 | } |
| 440 | if (pCreateInfos[idx0].layout) { |
| 441 | local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject*)pCreateInfos[idx0].layout)->actualObject; |
| 442 | } |
| 443 | if (pCreateInfos[idx0].stage.module) { |
| 444 | local_pCreateInfos[idx0].stage.module = (VkShaderModule)((VkUniqueObject*)pCreateInfos[idx0].stage.module)->actualObject; |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | if (pipelineCache) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 449 | pipelineCache = (VkPipelineCache)((VkUniqueObject*)pipelineCache)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 450 | } |
Tobin Ehlis | 9aac555 | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 451 | // CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671 |
| 452 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device)->CreateComputePipelines(device, pipelineCache, createInfoCount, (const VkComputePipelineCreateInfo*)local_pCreateInfos, pAllocator, pPipelines); |
Eric Engestrom | 00a8973 | 2016-02-21 19:58:09 +0000 | [diff] [blame] | 453 | delete[] local_pCreateInfos; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 454 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 455 | VkUniqueObject* pUO = NULL; |
| 456 | for (uint32_t i=0; i<createInfoCount; ++i) { |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 457 | pUO = new VkUniqueObject(); |
| 458 | pUO->actualObject = (uint64_t)pPipelines[i]; |
| 459 | pPipelines[i] = (VkPipeline)pUO; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | return result; |
| 463 | } |
| 464 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 465 | VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) |
| 466 | { |
Tobin Ehlis | 9aac555 | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 467 | // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'layout': 'VkPipelineLayout', 'pStages[stageCount]': {'module': 'VkShaderModule'}, 'renderPass': 'VkRenderPass', 'basePipelineHandle': 'VkPipeline'}} |
| 468 | //LOCAL DECLS:{'pCreateInfos': 'VkGraphicsPipelineCreateInfo*'} |
| 469 | safe_VkGraphicsPipelineCreateInfo* local_pCreateInfos = NULL; |
| 470 | if (pCreateInfos) { |
| 471 | local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount]; |
| 472 | for (uint32_t idx0=0; idx0<createInfoCount; ++idx0) { |
| 473 | local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]); |
| 474 | if (pCreateInfos[idx0].basePipelineHandle) { |
| 475 | local_pCreateInfos[idx0].basePipelineHandle = (VkPipeline)((VkUniqueObject*)pCreateInfos[idx0].basePipelineHandle)->actualObject; |
| 476 | } |
| 477 | if (pCreateInfos[idx0].layout) { |
| 478 | local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject*)pCreateInfos[idx0].layout)->actualObject; |
| 479 | } |
| 480 | if (pCreateInfos[idx0].pStages) { |
| 481 | for (uint32_t idx1=0; idx1<pCreateInfos[idx0].stageCount; ++idx1) { |
| 482 | if (pCreateInfos[idx0].pStages[idx1].module) { |
| 483 | local_pCreateInfos[idx0].pStages[idx1].module = (VkShaderModule)((VkUniqueObject*)pCreateInfos[idx0].pStages[idx1].module)->actualObject; |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | if (pCreateInfos[idx0].renderPass) { |
| 488 | local_pCreateInfos[idx0].renderPass = (VkRenderPass)((VkUniqueObject*)pCreateInfos[idx0].renderPass)->actualObject; |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | if (pipelineCache) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 493 | pipelineCache = (VkPipelineCache)((VkUniqueObject*)pipelineCache)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 494 | } |
Tobin Ehlis | 9aac555 | 2016-02-10 15:38:45 -0700 | [diff] [blame] | 495 | // CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671 |
| 496 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device)->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, (const VkGraphicsPipelineCreateInfo*)local_pCreateInfos, pAllocator, pPipelines); |
Eric Engestrom | 00a8973 | 2016-02-21 19:58:09 +0000 | [diff] [blame] | 497 | delete[] local_pCreateInfos; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 498 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 499 | VkUniqueObject* pUO = NULL; |
| 500 | for (uint32_t i=0; i<createInfoCount; ++i) { |
Tobin Ehlis | 115790b | 2016-01-05 16:34:59 -0700 | [diff] [blame] | 501 | pUO = new VkUniqueObject(); |
| 502 | pUO->actualObject = (uint64_t)pPipelines[i]; |
| 503 | pPipelines[i] = (VkPipeline)pUO; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 504 | } |
| 505 | } |
| 506 | return result; |
| 507 | } |
| 508 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 509 | VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) |
| 510 | { |
| 511 | // UNWRAP USES: |
| 512 | // 0 : swapchain,VkSwapchainKHR, pSwapchainImages,VkImage |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 513 | if (VK_NULL_HANDLE != swapchain) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 514 | swapchain = (VkSwapchainKHR)((VkUniqueObject*)swapchain)->actualObject; |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 515 | } |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 516 | VkResult result = get_dispatch_table(unique_objects_device_table_map, device)->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 517 | // TODO : Need to add corresponding code to delete these images |
| 518 | if (VK_SUCCESS == result) { |
| 519 | if ((*pSwapchainImageCount > 0) && pSwapchainImages) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 520 | std::vector<VkUniqueObject*> uniqueImages = {}; |
| 521 | for (uint32_t i=0; i<*pSwapchainImageCount; ++i) { |
Tobin Ehlis | 0b99d03 | 2015-12-08 10:50:10 -0700 | [diff] [blame] | 522 | uniqueImages.push_back(new VkUniqueObject()); |
| 523 | uniqueImages[i]->actualObject = (uint64_t)pSwapchainImages[i]; |
| 524 | pSwapchainImages[i] = (VkImage)uniqueImages[i]; |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | return result; |
| 529 | } |