blob: b8effcf5a158adec29e4717069ee81399e62ed65 [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"
Jon Ashburndc9111c2016-03-22 12:57:13 -060046#include "vk_layer_utils.h"
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070047
48struct layer_data {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070049 bool wsi_enabled;
50
Jon Ashburn5484e0c2016-03-08 17:48:44 -070051 layer_data() : wsi_enabled(false){};
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070052};
53
54struct instExts {
55 bool wsi_enabled;
Tobin Ehlisa39c26a2016-01-05 16:34:59 -070056 bool xlib_enabled;
57 bool xcb_enabled;
58 bool wayland_enabled;
59 bool mir_enabled;
60 bool android_enabled;
61 bool win32_enabled;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070062};
63
Jon Ashburn5484e0c2016-03-08 17:48:44 -070064static std::unordered_map<void *, struct instExts> instanceExtMap;
65static std::unordered_map<void *, layer_data *> layer_data_map;
66static device_table_map unique_objects_device_table_map;
67static instance_table_map unique_objects_instance_table_map;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070068// Structure to wrap returned non-dispatchable objects to guarantee they have unique handles
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070069// address of struct will be used as the unique handle
Jon Ashburn5484e0c2016-03-08 17:48:44 -070070struct VkUniqueObject {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070071 uint64_t actualObject;
72};
73
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070074// Handle CreateInstance
Jon Ashburn5484e0c2016-03-08 17:48:44 -070075static void createInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070076 uint32_t i;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070077 VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(unique_objects_instance_table_map, instance);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070078 PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
Michael Lentine56512bb2016-03-02 17:28:55 -060079
80 pDisp->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)gpa(instance, "vkDestroySurfaceKHR");
Jon Ashburn5484e0c2016-03-08 17:48:44 -070081 pDisp->GetPhysicalDeviceSurfaceSupportKHR =
82 (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");
83 pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR =
84 (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
85 pDisp->GetPhysicalDeviceSurfaceFormatsKHR =
86 (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR");
87 pDisp->GetPhysicalDeviceSurfacePresentModesKHR =
88 (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR");
Tobin Ehlisa39c26a2016-01-05 16:34:59 -070089#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -070090 pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)gpa(instance, "vkCreateWin32SurfaceKHR");
91 pDisp->GetPhysicalDeviceWin32PresentationSupportKHR =
92 (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070093#endif // VK_USE_PLATFORM_WIN32_KHR
94#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -070095 pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)gpa(instance, "vkCreateXcbSurfaceKHR");
96 pDisp->GetPhysicalDeviceXcbPresentationSupportKHR =
97 (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -070098#endif // VK_USE_PLATFORM_XCB_KHR
99#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700100 pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)gpa(instance, "vkCreateXlibSurfaceKHR");
101 pDisp->GetPhysicalDeviceXlibPresentationSupportKHR =
102 (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700103#endif // VK_USE_PLATFORM_XLIB_KHR
104#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700105 pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)gpa(instance, "vkCreateMirSurfaceKHR");
106 pDisp->GetPhysicalDeviceMirPresentationSupportKHR =
107 (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700108#endif // VK_USE_PLATFORM_MIR_KHR
109#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700110 pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)gpa(instance, "vkCreateWaylandSurfaceKHR");
111 pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR =
112 (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700113#endif // VK_USE_PLATFORM_WAYLAND_KHR
114#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700115 pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)gpa(instance, "vkCreateAndroidSurfaceKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700116#endif // VK_USE_PLATFORM_ANDROID_KHR
117
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700118 instanceExtMap[pDisp] = {};
Jon Ashburnf19916e2016-01-11 13:12:43 -0700119 for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700120 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700121 instanceExtMap[pDisp].wsi_enabled = true;
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700122#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700123 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700124 instanceExtMap[pDisp].xlib_enabled = true;
125#endif
126#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700127 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700128 instanceExtMap[pDisp].xcb_enabled = true;
129#endif
130#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700131 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700132 instanceExtMap[pDisp].wayland_enabled = true;
133#endif
134#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700135 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700136 instanceExtMap[pDisp].mir_enabled = true;
137#endif
138#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700139 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700140 instanceExtMap[pDisp].android_enabled = true;
141#endif
142#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700143 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0)
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700144 instanceExtMap[pDisp].win32_enabled = true;
145#endif
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700146 }
147}
148
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700149VkResult explicit_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
150 VkInstance *pInstance) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700151 VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700152
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700153 assert(chain_info->u.pLayerInfo);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700154 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700155 PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700156 if (fpCreateInstance == NULL) {
157 return VK_ERROR_INITIALIZATION_FAILED;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700158 }
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700159
160 // Advance the link info for the next element on the chain
161 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
162
163 VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
164 if (result != VK_SUCCESS) {
165 return result;
166 }
167
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700168 initInstanceTable(*pInstance, fpGetInstanceProcAddr, unique_objects_instance_table_map);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700169
170 createInstanceRegisterExtensions(pCreateInfo, *pInstance);
171
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700172 return result;
173}
174
175// Handle CreateDevice
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700176static void createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700177 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
178 VkLayerDispatchTable *pDisp = get_dispatch_table(unique_objects_device_table_map, device);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700179 PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700180 pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)gpa(device, "vkCreateSwapchainKHR");
181 pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)gpa(device, "vkDestroySwapchainKHR");
182 pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)gpa(device, "vkGetSwapchainImagesKHR");
183 pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)gpa(device, "vkAcquireNextImageKHR");
184 pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(device, "vkQueuePresentKHR");
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700185 my_device_data->wsi_enabled = false;
Jon Ashburnf19916e2016-01-11 13:12:43 -0700186 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700187 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700188 my_device_data->wsi_enabled = true;
189 }
190}
191
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700192VkResult explicit_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
193 VkDevice *pDevice) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700194 VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700195
196 assert(chain_info->u.pLayerInfo);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700197 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
198 PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700199 PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(NULL, "vkCreateDevice");
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700200 if (fpCreateDevice == NULL) {
201 return VK_ERROR_INITIALIZATION_FAILED;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700202 }
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700203
204 // Advance the link info for the next element on the chain
205 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
206
207 VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
208 if (result != VK_SUCCESS) {
209 return result;
210 }
211
212 // Setup layer's device dispatch table
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700213 initDeviceTable(*pDevice, fpGetDeviceProcAddr, unique_objects_device_table_map);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700214
215 createDeviceRegisterExtensions(pCreateInfo, *pDevice);
216
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700217 return result;
218}
219
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700220VkResult explicit_QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence) {
221 // UNWRAP USES:
222 // 0 : fence,VkFence
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700223 if (VK_NULL_HANDLE != fence) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700224 fence = (VkFence)((VkUniqueObject *)fence)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700225 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700226 // waitSemaphoreCount : pSubmits[submitCount]->pWaitSemaphores,VkSemaphore
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700227 std::vector<VkSemaphore> original_pWaitSemaphores = {};
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700228 // signalSemaphoreCount : pSubmits[submitCount]->pSignalSemaphores,VkSemaphore
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700229 std::vector<VkSemaphore> original_pSignalSemaphores = {};
230 if (pSubmits) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700231 for (uint32_t index0 = 0; index0 < submitCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700232 if (pSubmits[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700233 for (uint32_t index1 = 0; index1 < pSubmits[index0].waitSemaphoreCount; ++index1) {
234 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pWaitSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700235 original_pWaitSemaphores.push_back(pSubmits[index0].pWaitSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700236 *(ppSemaphore[index1]) =
237 (VkSemaphore)((VkUniqueObject *)pSubmits[index0].pWaitSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700238 }
239 }
240 if (pSubmits[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700241 for (uint32_t index1 = 0; index1 < pSubmits[index0].signalSemaphoreCount; ++index1) {
242 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pSignalSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700243 original_pSignalSemaphores.push_back(pSubmits[index0].pSignalSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700244 *(ppSemaphore[index1]) =
245 (VkSemaphore)((VkUniqueObject *)pSubmits[index0].pSignalSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700246 }
247 }
248 }
249 }
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700250 VkResult result = get_dispatch_table(unique_objects_device_table_map, queue)->QueueSubmit(queue, submitCount, pSubmits, fence);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700251 if (pSubmits) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700252 for (uint32_t index0 = 0; index0 < submitCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700253 if (pSubmits[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700254 for (uint32_t index1 = 0; index1 < pSubmits[index0].waitSemaphoreCount; ++index1) {
255 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pWaitSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700256 *(ppSemaphore[index1]) = original_pWaitSemaphores[index1];
257 }
258 }
259 if (pSubmits[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700260 for (uint32_t index1 = 0; index1 < pSubmits[index0].signalSemaphoreCount; ++index1) {
261 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pSubmits[index0].pSignalSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700262 *(ppSemaphore[index1]) = original_pSignalSemaphores[index1];
263 }
264 }
265 }
266 }
267 return result;
268}
269
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700270VkResult explicit_QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, VkFence fence) {
271 // UNWRAP USES:
272 // 0 : pBindInfo[bindInfoCount]->pBufferBinds[bufferBindCount]->buffer,VkBuffer,
273 // pBindInfo[bindInfoCount]->pBufferBinds[bufferBindCount]->pBinds[bindCount]->memory,VkDeviceMemory,
274 // pBindInfo[bindInfoCount]->pImageOpaqueBinds[imageOpaqueBindCount]->image,VkImage,
275 // pBindInfo[bindInfoCount]->pImageOpaqueBinds[imageOpaqueBindCount]->pBinds[bindCount]->memory,VkDeviceMemory,
276 // pBindInfo[bindInfoCount]->pImageBinds[imageBindCount]->image,VkImage,
277 // pBindInfo[bindInfoCount]->pImageBinds[imageBindCount]->pBinds[bindCount]->memory,VkDeviceMemory
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700278 std::vector<VkBuffer> original_buffer = {};
279 std::vector<VkDeviceMemory> original_memory1 = {};
280 std::vector<VkImage> original_image1 = {};
281 std::vector<VkDeviceMemory> original_memory2 = {};
282 std::vector<VkImage> original_image2 = {};
283 std::vector<VkDeviceMemory> original_memory3 = {};
284 std::vector<VkSemaphore> original_pWaitSemaphores = {};
285 std::vector<VkSemaphore> original_pSignalSemaphores = {};
286 if (pBindInfo) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700287 for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700288 if (pBindInfo[index0].pBufferBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700289 for (uint32_t index1 = 0; index1 < pBindInfo[index0].bufferBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700290 if (pBindInfo[index0].pBufferBinds[index1].buffer) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700291 VkBuffer *pBuffer = (VkBuffer *)&(pBindInfo[index0].pBufferBinds[index1].buffer);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700292 original_buffer.push_back(pBindInfo[index0].pBufferBinds[index1].buffer);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700293 *(pBuffer) = (VkBuffer)((VkUniqueObject *)pBindInfo[index0].pBufferBinds[index1].buffer)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700294 }
295 if (pBindInfo[index0].pBufferBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700296 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700297 if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700298 VkDeviceMemory *pDeviceMemory =
299 (VkDeviceMemory *)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700300 original_memory1.push_back(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700301 *(pDeviceMemory) =
302 (VkDeviceMemory)((VkUniqueObject *)pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory)
303 ->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700304 }
305 }
306 }
307 }
308 }
309 if (pBindInfo[index0].pImageOpaqueBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700310 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageOpaqueBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700311 if (pBindInfo[index0].pImageOpaqueBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700312 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageOpaqueBinds[index1].image);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700313 original_image1.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].image);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700314 *(pImage) = (VkImage)((VkUniqueObject *)pBindInfo[index0].pImageOpaqueBinds[index1].image)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700315 }
316 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700317 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700318 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700319 VkDeviceMemory *pDeviceMemory =
320 (VkDeviceMemory *)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700321 original_memory2.push_back(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700322 *(pDeviceMemory) =
323 (VkDeviceMemory)(
324 (VkUniqueObject *)pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory)
325 ->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700326 }
327 }
328 }
329 }
330 }
331 if (pBindInfo[index0].pImageBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700332 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700333 if (pBindInfo[index0].pImageBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700334 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageBinds[index1].image);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700335 original_image2.push_back(pBindInfo[index0].pImageBinds[index1].image);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700336 *(pImage) = (VkImage)((VkUniqueObject *)pBindInfo[index0].pImageBinds[index1].image)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700337 }
338 if (pBindInfo[index0].pImageBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700339 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700340 if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700341 VkDeviceMemory *pDeviceMemory =
342 (VkDeviceMemory *)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700343 original_memory3.push_back(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700344 *(pDeviceMemory) =
345 (VkDeviceMemory)((VkUniqueObject *)pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory)
346 ->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700347 }
348 }
349 }
350 }
351 }
352 if (pBindInfo[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700353 for (uint32_t index1 = 0; index1 < pBindInfo[index0].waitSemaphoreCount; ++index1) {
354 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pWaitSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700355 original_pWaitSemaphores.push_back(pBindInfo[index0].pWaitSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700356 *(ppSemaphore[index1]) =
357 (VkSemaphore)((VkUniqueObject *)pBindInfo[index0].pWaitSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700358 }
359 }
360 if (pBindInfo[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700361 for (uint32_t index1 = 0; index1 < pBindInfo[index0].signalSemaphoreCount; ++index1) {
362 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pSignalSemaphores);
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700363 original_pSignalSemaphores.push_back(pBindInfo[index0].pSignalSemaphores[index1]);
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700364 *(ppSemaphore[index1]) =
365 (VkSemaphore)((VkUniqueObject *)pBindInfo[index0].pSignalSemaphores[index1])->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700366 }
367 }
368 }
369 }
370 if (VK_NULL_HANDLE != fence) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700371 fence = (VkFence)((VkUniqueObject *)fence)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700372 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700373 VkResult result =
374 get_dispatch_table(unique_objects_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700375 if (pBindInfo) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700376 for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700377 if (pBindInfo[index0].pBufferBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700378 for (uint32_t index1 = 0; index1 < pBindInfo[index0].bufferBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700379 if (pBindInfo[index0].pBufferBinds[index1].buffer) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700380 VkBuffer *pBuffer = (VkBuffer *)&(pBindInfo[index0].pBufferBinds[index1].buffer);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700381 *(pBuffer) = original_buffer[index1];
382 }
383 if (pBindInfo[index0].pBufferBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700384 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700385 if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700386 VkDeviceMemory *pDeviceMemory =
387 (VkDeviceMemory *)&(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700388 *(pDeviceMemory) = original_memory1[index2];
389 }
390 }
391 }
392 }
393 }
394 if (pBindInfo[index0].pImageOpaqueBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700395 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageOpaqueBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700396 if (pBindInfo[index0].pImageOpaqueBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700397 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageOpaqueBinds[index1].image);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700398 *(pImage) = original_image1[index1];
399 }
400 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700401 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700402 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700403 VkDeviceMemory *pDeviceMemory =
404 (VkDeviceMemory *)&(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700405 *(pDeviceMemory) = original_memory2[index2];
406 }
407 }
408 }
409 }
410 }
411 if (pBindInfo[index0].pImageBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700412 for (uint32_t index1 = 0; index1 < pBindInfo[index0].imageBindCount; ++index1) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700413 if (pBindInfo[index0].pImageBinds[index1].image) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700414 VkImage *pImage = (VkImage *)&(pBindInfo[index0].pImageBinds[index1].image);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700415 *(pImage) = original_image2[index1];
416 }
417 if (pBindInfo[index0].pImageBinds[index1].pBinds) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700418 for (uint32_t index2 = 0; index2 < pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) {
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -0700419 if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700420 VkDeviceMemory *pDeviceMemory =
421 (VkDeviceMemory *)&(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700422 *(pDeviceMemory) = original_memory3[index2];
423 }
424 }
425 }
426 }
427 }
428 if (pBindInfo[index0].pWaitSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700429 for (uint32_t index1 = 0; index1 < pBindInfo[index0].waitSemaphoreCount; ++index1) {
430 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pWaitSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700431 *(ppSemaphore[index1]) = original_pWaitSemaphores[index1];
432 }
433 }
434 if (pBindInfo[index0].pSignalSemaphores) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700435 for (uint32_t index1 = 0; index1 < pBindInfo[index0].signalSemaphoreCount; ++index1) {
436 VkSemaphore **ppSemaphore = (VkSemaphore **)&(pBindInfo[index0].pSignalSemaphores);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700437 *(ppSemaphore[index1]) = original_pSignalSemaphores[index1];
438 }
439 }
440 }
441 }
442 return result;
443}
444
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700445VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
446 const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
447 VkPipeline *pPipelines) {
448 // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'stage': {'module': 'VkShaderModule'},
449 // 'layout': 'VkPipelineLayout', 'basePipelineHandle': 'VkPipeline'}}
450 // LOCAL DECLS:{'pCreateInfos': 'VkComputePipelineCreateInfo*'}
451 safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700452 if (pCreateInfos) {
453 local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount];
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700454 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700455 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
456 if (pCreateInfos[idx0].basePipelineHandle) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700457 local_pCreateInfos[idx0].basePipelineHandle =
458 (VkPipeline)((VkUniqueObject *)pCreateInfos[idx0].basePipelineHandle)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700459 }
460 if (pCreateInfos[idx0].layout) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700461 local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject *)pCreateInfos[idx0].layout)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700462 }
463 if (pCreateInfos[idx0].stage.module) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700464 local_pCreateInfos[idx0].stage.module =
465 (VkShaderModule)((VkUniqueObject *)pCreateInfos[idx0].stage.module)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700466 }
467 }
468 }
469 if (pipelineCache) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700470 pipelineCache = (VkPipelineCache)((VkUniqueObject *)pipelineCache)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700471 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700472 // CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671
473 VkResult result = get_dispatch_table(unique_objects_device_table_map, device)
474 ->CreateComputePipelines(device, pipelineCache, createInfoCount,
475 (const VkComputePipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines);
Eric Engestrom53b513f2016-02-21 19:58:09 +0000476 delete[] local_pCreateInfos;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700477 if (VK_SUCCESS == result) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700478 VkUniqueObject *pUO = NULL;
479 for (uint32_t i = 0; i < createInfoCount; ++i) {
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700480 pUO = new VkUniqueObject();
481 pUO->actualObject = (uint64_t)pPipelines[i];
482 pPipelines[i] = (VkPipeline)pUO;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700483 }
484 }
485 return result;
486}
487
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700488VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
489 const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
490 VkPipeline *pPipelines) {
491 // STRUCT USES:{'pipelineCache': 'VkPipelineCache', 'pCreateInfos[createInfoCount]': {'layout': 'VkPipelineLayout',
492 // 'pStages[stageCount]': {'module': 'VkShaderModule'}, 'renderPass': 'VkRenderPass', 'basePipelineHandle': 'VkPipeline'}}
493 // LOCAL DECLS:{'pCreateInfos': 'VkGraphicsPipelineCreateInfo*'}
494 safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = NULL;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700495 if (pCreateInfos) {
496 local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount];
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700497 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700498 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
499 if (pCreateInfos[idx0].basePipelineHandle) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700500 local_pCreateInfos[idx0].basePipelineHandle =
501 (VkPipeline)((VkUniqueObject *)pCreateInfos[idx0].basePipelineHandle)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700502 }
503 if (pCreateInfos[idx0].layout) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700504 local_pCreateInfos[idx0].layout = (VkPipelineLayout)((VkUniqueObject *)pCreateInfos[idx0].layout)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700505 }
506 if (pCreateInfos[idx0].pStages) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700507 for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) {
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700508 if (pCreateInfos[idx0].pStages[idx1].module) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700509 local_pCreateInfos[idx0].pStages[idx1].module =
510 (VkShaderModule)((VkUniqueObject *)pCreateInfos[idx0].pStages[idx1].module)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700511 }
512 }
513 }
514 if (pCreateInfos[idx0].renderPass) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700515 local_pCreateInfos[idx0].renderPass = (VkRenderPass)((VkUniqueObject *)pCreateInfos[idx0].renderPass)->actualObject;
Tobin Ehlis8bb7c2f2016-02-10 15:38:45 -0700516 }
517 }
518 }
519 if (pipelineCache) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700520 pipelineCache = (VkPipelineCache)((VkUniqueObject *)pipelineCache)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700521 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700522 // CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671
523 VkResult result =
524 get_dispatch_table(unique_objects_device_table_map, device)
525 ->CreateGraphicsPipelines(device, pipelineCache, createInfoCount,
526 (const VkGraphicsPipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines);
Eric Engestrom53b513f2016-02-21 19:58:09 +0000527 delete[] local_pCreateInfos;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700528 if (VK_SUCCESS == result) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700529 VkUniqueObject *pUO = NULL;
530 for (uint32_t i = 0; i < createInfoCount; ++i) {
Tobin Ehlisa39c26a2016-01-05 16:34:59 -0700531 pUO = new VkUniqueObject();
532 pUO->actualObject = (uint64_t)pPipelines[i];
533 pPipelines[i] = (VkPipeline)pUO;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700534 }
535 }
536 return result;
537}
538
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700539VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
540 VkImage *pSwapchainImages) {
541 // UNWRAP USES:
542 // 0 : swapchain,VkSwapchainKHR, pSwapchainImages,VkImage
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700543 if (VK_NULL_HANDLE != swapchain) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700544 swapchain = (VkSwapchainKHR)((VkUniqueObject *)swapchain)->actualObject;
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700545 }
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700546 VkResult result = get_dispatch_table(unique_objects_device_table_map, device)
547 ->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700548 // TODO : Need to add corresponding code to delete these images
549 if (VK_SUCCESS == result) {
550 if ((*pSwapchainImageCount > 0) && pSwapchainImages) {
Jon Ashburn5484e0c2016-03-08 17:48:44 -0700551 std::vector<VkUniqueObject *> uniqueImages = {};
552 for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) {
Tobin Ehlisd34a4c52015-12-08 10:50:10 -0700553 uniqueImages.push_back(new VkUniqueObject());
554 uniqueImages[i]->actualObject = (uint64_t)pSwapchainImages[i];
555 pSwapchainImages[i] = (VkImage)uniqueImages[i];
556 }
557 }
558 }
559 return result;
560}