blob: 42008448d443070ea56a171c5a4948ccc3d45a7c [file] [log] [blame]
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07001/* 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 Ehlisd34a4c52015-12-08 10:50:10 -07005 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07006 * 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 Ehlisd34a4c52015-12-08 10:50:10 -070012 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070013 * The above copyright notice(s) and this permission notice shall be included
14 * in all copies or substantial portions of the Materials.
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070015 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070016 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070018 * 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 Ehlisd34a4c52015-12-08 10:50:10 -070024 *
25 * Author: Tobin Ehlis <tobine@google.com>
26 */
27
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070028#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 Ehlisd34a4c52015-12-08 10:50:10 -070041#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 Ehlis8bb7c2f2016-02-10 15:38:45 -070045#include "vk_safe_struct.h"
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070046
47struct layer_data {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070048 bool wsi_enabled;
49
Jon Ashburn5484e0c2016-03-08 17:48:44 -070050 layer_data() : wsi_enabled(false){};
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070051};
52
53struct instExts {
54 bool wsi_enabled;
Tobin Ehlisa39c26a2016-01-05 16:34:59 -070055 bool xlib_enabled;
56 bool xcb_enabled;
57 bool wayland_enabled;
58 bool mir_enabled;
59 bool android_enabled;
60 bool win32_enabled;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070061};
62
Jon Ashburn5484e0c2016-03-08 17:48:44 -070063static std::unordered_map<void *, struct instExts> instanceExtMap;
64static std::unordered_map<void *, layer_data *> layer_data_map;
65static device_table_map unique_objects_device_table_map;
66static instance_table_map unique_objects_instance_table_map;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070067// Structure to wrap returned non-dispatchable objects to guarantee they have unique handles
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070068// address of struct will be used as the unique handle
Jon Ashburn5484e0c2016-03-08 17:48:44 -070069struct VkUniqueObject {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070070 uint64_t actualObject;
71};
72
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070073// Handle CreateInstance
Jon Ashburn5484e0c2016-03-08 17:48:44 -070074static void createInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070075 uint32_t i;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070076 VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(unique_objects_instance_table_map, instance);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070077 PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
Michael Lentine56512bb2016-03-02 17:28:55 -060078
79 pDisp->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)gpa(instance, "vkDestroySurfaceKHR");
Jon Ashburn5484e0c2016-03-08 17:48:44 -070080 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 Ehlisa39c26a2016-01-05 16:34:59 -070088#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -070089 pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)gpa(instance, "vkCreateWin32SurfaceKHR");
90 pDisp->GetPhysicalDeviceWin32PresentationSupportKHR =
91 (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070092#endif // VK_USE_PLATFORM_WIN32_KHR
93#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -070094 pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)gpa(instance, "vkCreateXcbSurfaceKHR");
95 pDisp->GetPhysicalDeviceXcbPresentationSupportKHR =
96 (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070097#endif // VK_USE_PLATFORM_XCB_KHR
98#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -070099 pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)gpa(instance, "vkCreateXlibSurfaceKHR");
100 pDisp->GetPhysicalDeviceXlibPresentationSupportKHR =
101 (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700102#endif // VK_USE_PLATFORM_XLIB_KHR
103#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700104 pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)gpa(instance, "vkCreateMirSurfaceKHR");
105 pDisp->GetPhysicalDeviceMirPresentationSupportKHR =
106 (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700107#endif // VK_USE_PLATFORM_MIR_KHR
108#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700109 pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)gpa(instance, "vkCreateWaylandSurfaceKHR");
110 pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR =
111 (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700112#endif // VK_USE_PLATFORM_WAYLAND_KHR
113#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700114 pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)gpa(instance, "vkCreateAndroidSurfaceKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700115#endif // VK_USE_PLATFORM_ANDROID_KHR
116
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700117 instanceExtMap[pDisp] = {};
Jon Ashburnf19916e2016-01-11 13:12:43 -0700118 for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700119 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700120 instanceExtMap[pDisp].wsi_enabled = true;
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700121#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700122 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700123 instanceExtMap[pDisp].xlib_enabled = true;
124#endif
125#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700126 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700127 instanceExtMap[pDisp].xcb_enabled = true;
128#endif
129#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700130 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700131 instanceExtMap[pDisp].wayland_enabled = true;
132#endif
133#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700134 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700135 instanceExtMap[pDisp].mir_enabled = true;
136#endif
137#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700138 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700139 instanceExtMap[pDisp].android_enabled = true;
140#endif
141#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700142 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700143 instanceExtMap[pDisp].win32_enabled = true;
144#endif
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700145 }
146}
147
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700148VkResult explicit_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
149 VkInstance *pInstance) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700150 VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700151
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700152 assert(chain_info->u.pLayerInfo);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700153 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700154 PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700155 if (fpCreateInstance == NULL) {
156 return VK_ERROR_INITIALIZATION_FAILED;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700157 }
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700158
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 Lobodzinski1ed594e2016-02-03 09:57:14 -0700167 initInstanceTable(*pInstance, fpGetInstanceProcAddr, unique_objects_instance_table_map);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700168
169 createInstanceRegisterExtensions(pCreateInfo, *pInstance);
170
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700171 return result;
172}
173
174// Handle CreateDevice
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700175static void createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700176 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 Ehlisd34a4c52015-12-08 10:50:10 -0700178 PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700179 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 Ehlisd34a4c52015-12-08 10:50:10 -0700184 my_device_data->wsi_enabled = false;
Jon Ashburnf19916e2016-01-11 13:12:43 -0700185 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700186 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700187 my_device_data->wsi_enabled = true;
188 }
189}
190
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700191VkResult explicit_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
192 VkDevice *pDevice) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700193 VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700194
195 assert(chain_info->u.pLayerInfo);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700196 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
197 PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700198 PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(NULL, "vkCreateDevice");
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700199 if (fpCreateDevice == NULL) {
200 return VK_ERROR_INITIALIZATION_FAILED;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700201 }
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700202
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 Lobodzinski1ed594e2016-02-03 09:57:14 -0700212 initDeviceTable(*pDevice, fpGetDeviceProcAddr, unique_objects_device_table_map);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700213
214 createDeviceRegisterExtensions(pCreateInfo, *pDevice);
215
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700216 return result;
217}
218
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700219VkResult explicit_QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence) {
220 // UNWRAP USES:
221 // 0 : fence,VkFence
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700222 if (VK_NULL_HANDLE != fence) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700223 fence = (VkFence)((VkUniqueObject *)fence)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700224 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700225 // waitSemaphoreCount : pSubmits[submitCount]->pWaitSemaphores,VkSemaphore
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700226 std::vector<VkSemaphore> original_pWaitSemaphores = {};
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700227 // signalSemaphoreCount : pSubmits[submitCount]->pSignalSemaphores,VkSemaphore
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700228 std::vector<VkSemaphore> original_pSignalSemaphores = {};
229 if (pSubmits) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700230 for (uint32_t index0 = 0; index0 < submitCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700231 if (pSubmits[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700232 for (uint32_t index1 = 0; index1 < pSubmits[index0].waitSemaphoreCount; ++index1) {
233 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pWaitSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700234 original_pWaitSemaphores.push_back(pSubmits[index0].pWaitSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700235 *(ppSemaphore[index1]) =
236 (VkSemaphore)((VkUniqueObject *)pSubmits[index0].pWaitSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700237 }
238 }
239 if (pSubmits[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700240 for (uint32_t index1 = 0; index1 < pSubmits[index0].signalSemaphoreCount; ++index1) {
241 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pSignalSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700242 original_pSignalSemaphores.push_back(pSubmits[index0].pSignalSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700243 *(ppSemaphore[index1]) =
244 (VkSemaphore)((VkUniqueObject *)pSubmits[index0].pSignalSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700245 }
246 }
247 }
248 }
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700249 VkResult result = get_dispatch_table(unique_objects_device_table_map, queue)->QueueSubmit(queue, submitCount, pSubmits, fence);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700250 if (pSubmits) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700251 for (uint32_t index0 = 0; index0 < submitCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700252 if (pSubmits[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700253 for (uint32_t index1 = 0; index1 < pSubmits[index0].waitSemaphoreCount; ++index1) {
254 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pWaitSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700255 *(ppSemaphore[index1]) = original_pWaitSemaphores[index1];
256 }
257 }
258 if (pSubmits[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700259 for (uint32_t index1 = 0; index1 < pSubmits[index0].signalSemaphoreCount; ++index1) {
260 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pSignalSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700261 *(ppSemaphore[index1]) = original_pSignalSemaphores[index1];
262 }
263 }
264 }
265 }
266 return result;
267}
268
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700269VkResult 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 Ehlisd34a4c52015-12-08 10:50:10 -0700277 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 Ashburn5484e0c2016-03-08 17:48:44 -0700286 for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700287 if (pBindInfo[index0].pBufferBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700288 for (uint32_t index1 = 0; index1 < pBindInfo[index0].bufferBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700289 if (pBindInfo[index0].pBufferBinds[index1].buffer) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700290 VkBuffer *pBuffer = (VkBuffer *)&(pBindInfo[index0].pBufferBinds[index1].buffer);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700291 original_buffer.push_back(pBindInfo[index0].pBufferBinds[index1].buffer);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700292 *(pBuffer) = (VkBuffer)((VkUniqueObject *)pBindInfo[index0].pBufferBinds[index1].buffer)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700293 }
294 if (pBindInfo[index0].pBufferBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700295 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700296 if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700297 VkDeviceMemory *pDeviceMemory =
298 (VkDeviceMemory *)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700299 original_memory1.push_back(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700300 *(pDeviceMemory) =
301 (VkDeviceMemory)((VkUniqueObject *)pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory)
302 ->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700303 }
304 }
305 }
306 }
307 }
308 if (pBindInfo[index0].pImageOpaqueBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700309 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageOpaqueBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700310 if (pBindInfo[index0].pImageOpaqueBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700311 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageOpaqueBinds[index1].image);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700312 original_image1.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].image);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700313 *(pImage) = (VkImage)((VkUniqueObject *)pBindInfo[index0].pImageOpaqueBinds[index1].image)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700314 }
315 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700316 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700317 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700318 VkDeviceMemory *pDeviceMemory =
319 (VkDeviceMemory *)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700320 original_memory2.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700321 *(pDeviceMemory) =
322 (VkDeviceMemory)(
323 (VkUniqueObject *)pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory)
324 ->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700325 }
326 }
327 }
328 }
329 }
330 if (pBindInfo[index0].pImageBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700331 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700332 if (pBindInfo[index0].pImageBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700333 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageBinds[index1].image);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700334 original_image2.push_back(pBindInfo[index0].pImageBinds[index1].image);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700335 *(pImage) = (VkImage)((VkUniqueObject *)pBindInfo[index0].pImageBinds[index1].image)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700336 }
337 if (pBindInfo[index0].pImageBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700338 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700339 if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700340 VkDeviceMemory *pDeviceMemory =
341 (VkDeviceMemory *)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700342 original_memory3.push_back(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700343 *(pDeviceMemory) =
344 (VkDeviceMemory)((VkUniqueObject *)pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory)
345 ->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700346 }
347 }
348 }
349 }
350 }
351 if (pBindInfo[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700352 for (uint32_t index1 = 0; index1 < pBindInfo[index0].waitSemaphoreCount; ++index1) {
353 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pWaitSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700354 original_pWaitSemaphores.push_back(pBindInfo[index0].pWaitSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700355 *(ppSemaphore[index1]) =
356 (VkSemaphore)((VkUniqueObject *)pBindInfo[index0].pWaitSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700357 }
358 }
359 if (pBindInfo[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700360 for (uint32_t index1 = 0; index1 < pBindInfo[index0].signalSemaphoreCount; ++index1) {
361 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pSignalSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700362 original_pSignalSemaphores.push_back(pBindInfo[index0].pSignalSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700363 *(ppSemaphore[index1]) =
364 (VkSemaphore)((VkUniqueObject *)pBindInfo[index0].pSignalSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700365 }
366 }
367 }
368 }
369 if (VK_NULL_HANDLE != fence) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700370 fence = (VkFence)((VkUniqueObject *)fence)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700371 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700372 VkResult result =
373 get_dispatch_table(unique_objects_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700374 if (pBindInfo) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700375 for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700376 if (pBindInfo[index0].pBufferBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700377 for (uint32_t index1 = 0; index1 < pBindInfo[index0].bufferBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700378 if (pBindInfo[index0].pBufferBinds[index1].buffer) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700379 VkBuffer *pBuffer = (VkBuffer *)&(pBindInfo[index0].pBufferBinds[index1].buffer);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700380 *(pBuffer) = original_buffer[index1];
381 }
382 if (pBindInfo[index0].pBufferBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700383 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700384 if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700385 VkDeviceMemory *pDeviceMemory =
386 (VkDeviceMemory *)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700387 *(pDeviceMemory) = original_memory1[index2];
388 }
389 }
390 }
391 }
392 }
393 if (pBindInfo[index0].pImageOpaqueBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700394 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageOpaqueBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700395 if (pBindInfo[index0].pImageOpaqueBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700396 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageOpaqueBinds[index1].image);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700397 *(pImage) = original_image1[index1];
398 }
399 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700400 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700401 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700402 VkDeviceMemory *pDeviceMemory =
403 (VkDeviceMemory *)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700404 *(pDeviceMemory) = original_memory2[index2];
405 }
406 }
407 }
408 }
409 }
410 if (pBindInfo[index0].pImageBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700411 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700412 if (pBindInfo[index0].pImageBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700413 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageBinds[index1].image);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700414 *(pImage) = original_image2[index1];
415 }
416 if (pBindInfo[index0].pImageBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700417 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700418 if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700419 VkDeviceMemory *pDeviceMemory =
420 (VkDeviceMemory *)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700421 *(pDeviceMemory) = original_memory3[index2];
422 }
423 }
424 }
425 }
426 }
427 if (pBindInfo[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700428 for (uint32_t index1 = 0; index1 < pBindInfo[index0].waitSemaphoreCount; ++index1) {
429 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pWaitSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700430 *(ppSemaphore[index1]) = original_pWaitSemaphores[index1];
431 }
432 }
433 if (pBindInfo[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700434 for (uint32_t index1 = 0; index1 < pBindInfo[index0].signalSemaphoreCount; ++index1) {
435 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pSignalSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700436 *(ppSemaphore[index1]) = original_pSignalSemaphores[index1];
437 }
438 }
439 }
440 }
441 return result;
442}
443
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700444VkResult 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 Ehlis8bb7c2f2016-02-10 15:38:45 -0700451 if (pCreateInfos) {
452 local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount];
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700453 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700454 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
455 if (pCreateInfos[idx0].basePipelineHandle) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700456 local_pCreateInfos[idx0].basePipelineHandle =
457 (VkPipeline)((VkUniqueObject *)pCreateInfos[idx0].basePipelineHandle)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700458 }
459 if (pCreateInfos[idx0].layout) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700460 local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject *)pCreateInfos[idx0].layout)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700461 }
462 if (pCreateInfos[idx0].stage.module) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700463 local_pCreateInfos[idx0].stage.module =
464 (VkShaderModule)((VkUniqueObject *)pCreateInfos[idx0].stage.module)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700465 }
466 }
467 }
468 if (pipelineCache) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700469 pipelineCache = (VkPipelineCache)((VkUniqueObject *)pipelineCache)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700470 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700471 // 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 Engestrom53b513f2016-02-21 19:58:09 +0000475 delete[] local_pCreateInfos;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700476 if (VK_SUCCESS == result) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700477 VkUniqueObject *pUO = NULL;
478 for (uint32_t i = 0; i < createInfoCount; ++i) {
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700479 pUO = new VkUniqueObject();
480 pUO->actualObject = (uint64_t)pPipelines[i];
481 pPipelines[i] = (VkPipeline)pUO;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700482 }
483 }
484 return result;
485}
486
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700487VkResult 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 Ehlis8bb7c2f2016-02-10 15:38:45 -0700494 if (pCreateInfos) {
495 local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount];
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700496 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700497 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
498 if (pCreateInfos[idx0].basePipelineHandle) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700499 local_pCreateInfos[idx0].basePipelineHandle =
500 (VkPipeline)((VkUniqueObject *)pCreateInfos[idx0].basePipelineHandle)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700501 }
502 if (pCreateInfos[idx0].layout) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700503 local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject *)pCreateInfos[idx0].layout)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700504 }
505 if (pCreateInfos[idx0].pStages) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700506 for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) {
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700507 if (pCreateInfos[idx0].pStages[idx1].module) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700508 local_pCreateInfos[idx0].pStages[idx1].module =
509 (VkShaderModule)((VkUniqueObject *)pCreateInfos[idx0].pStages[idx1].module)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700510 }
511 }
512 }
513 if (pCreateInfos[idx0].renderPass) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700514 local_pCreateInfos[idx0].renderPass = (VkRenderPass)((VkUniqueObject *)pCreateInfos[idx0].renderPass)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700515 }
516 }
517 }
518 if (pipelineCache) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700519 pipelineCache = (VkPipelineCache)((VkUniqueObject *)pipelineCache)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700520 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700521 // 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 Engestrom53b513f2016-02-21 19:58:09 +0000526 delete[] local_pCreateInfos;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700527 if (VK_SUCCESS == result) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700528 VkUniqueObject *pUO = NULL;
529 for (uint32_t i = 0; i < createInfoCount; ++i) {
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700530 pUO = new VkUniqueObject();
531 pUO->actualObject = (uint64_t)pPipelines[i];
532 pPipelines[i] = (VkPipeline)pUO;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700533 }
534 }
535 return result;
536}
537
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700538VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
539 VkImage *pSwapchainImages) {
540 // UNWRAP USES:
541 // 0 : swapchain,VkSwapchainKHR, pSwapchainImages,VkImage
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700542 if (VK_NULL_HANDLE != swapchain) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700543 swapchain = (VkSwapchainKHR)((VkUniqueObject *)swapchain)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700544 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700545 VkResult result = get_dispatch_table(unique_objects_device_table_map, device)
546 ->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700547 // TODO : Need to add corresponding code to delete these images
548 if (VK_SUCCESS == result) {
549 if ((*pSwapchainImageCount > 0) && pSwapchainImages) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700550 std::vector<VkUniqueObject *> uniqueImages = {};
551 for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700552 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}